{"repo_id":"WorkArena","entity_id":"py:make_human_eval_curriculum","uri":"program://WorkArena/module/make_human_eval_curriculum#L1-L44","kind":"module","name":"make_human_eval_curriculum","path":"make_human_eval_curriculum.py","language":"python","start_line":1,"end_line":44,"context_start_line":1,"context_end_line":44,"code":"import random\n\nfrom browsergym.workarena import get_all_tasks_humans\n\n\ntasks_l2 = get_all_tasks_humans(filter=\"l2\", meta_seed=42)\ntasks_l3 = get_all_tasks_humans(filter=\"l3\", meta_seed=42)\n\ntasks = tasks_l2 + tasks_l3\nrandom.shuffle(tasks)\n\nannotators = [\n \"darwiche\",\n \"parikh\",\n \"marchand\",\n \"paquet\",\n \"nayal\",\n \"huang\",\n \"subbaraj\",\n \"williams\",\n \"li\",\n \"marcotte\",\n \"rancourt\",\n \"prince_tremblay\",\n \"ashok\",\n \"bajaj\",\n]\nrandom.shuffle(annotators)\n\nprint(\"Number of tasks: \", len(tasks))\nprint(\"Number of annotators: \", len(annotators))\n\ntasks_by_annotator = {}\nn_base_assignment = len(tasks) // len(annotators)\nn_extra_assignment = len(tasks) % len(annotators)\nfor i, annotator in enumerate(annotators):\n n_assignments = n_base_assignment + (1 if i < n_extra_assignment else 0)\n tasks_by_annotator[annotator] = tasks[:n_assignments]\n tasks = tasks[n_assignments:]\n print(f\"{annotator}: {n_assignments}\")\n\n with open(f\"{annotator}.tasks\", \"w\") as f:\n for task in tasks_by_annotator[annotator]:\n f.write(f\"{task[0].__name__},{task[1]}\\n\")","source_hash":"1f7ccff0b33ab5c2d69833890944dcb13b14ac9e898372ca156638b7b6c4128b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_utils","uri":"program://WorkArena/module/tests.test_utils#L1-L32","kind":"module","name":"tests.test_utils","path":"tests/test_utils.py","language":"python","start_line":1,"end_line":32,"context_start_line":1,"context_end_line":32,"code":"import pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.utils import ui_login, url_login\n\n\n@pytest.mark.parametrize(\"login_func\", [ui_login, url_login])\ndef test_login_correct_credentials(login_func, page: Page):\n \"\"\"\n Test logging into the instance with the correct credentials\n\n \"\"\"\n # Log in with correct credentials\n instance = SNowInstance()\n login_func(instance=instance, page=page)\n\n\n@pytest.mark.parametrize(\"login_func\", [ui_login, url_login])\ndef test_login_wrong_credentials(login_func, page: Page):\n \"\"\"\n Test logging into the instance with the wrong credentials\n\n \"\"\"\n # Log in with wrong credentials\n instance = SNowInstance(snow_credentials=(\"wrong\", \"wrong\"))\n with pytest.raises(RuntimeError):\n login_func(instance=instance, page=page)","source_hash":"5252b4090cc44cfacee58149af6f716acd0ac364ed5805cb264964cb7d17ff3e","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_utils.test_login_correct_credentials","uri":"program://WorkArena/function/tests.test_utils.test_login_correct_credentials#L13-L20","kind":"function","name":"test_login_correct_credentials","path":"tests/test_utils.py","language":"python","start_line":13,"end_line":20,"context_start_line":1,"context_end_line":32,"code":"import pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.utils import ui_login, url_login\n\n\n@pytest.mark.parametrize(\"login_func\", [ui_login, url_login])\ndef test_login_correct_credentials(login_func, page: Page):\n \"\"\"\n Test logging into the instance with the correct credentials\n\n \"\"\"\n # Log in with correct credentials\n instance = SNowInstance()\n login_func(instance=instance, page=page)\n\n\n@pytest.mark.parametrize(\"login_func\", [ui_login, url_login])\ndef test_login_wrong_credentials(login_func, page: Page):\n \"\"\"\n Test logging into the instance with the wrong credentials\n\n \"\"\"\n # Log in with wrong credentials\n instance = SNowInstance(snow_credentials=(\"wrong\", \"wrong\"))\n with pytest.raises(RuntimeError):\n login_func(instance=instance, page=page)","source_hash":"5252b4090cc44cfacee58149af6f716acd0ac364ed5805cb264964cb7d17ff3e","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_utils.test_login_wrong_credentials","uri":"program://WorkArena/function/tests.test_utils.test_login_wrong_credentials#L24-L32","kind":"function","name":"test_login_wrong_credentials","path":"tests/test_utils.py","language":"python","start_line":24,"end_line":32,"context_start_line":4,"context_end_line":32,"code":"from utils import setup_playwright\n\nfrom playwright.sync_api import Page\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.utils import ui_login, url_login\n\n\n@pytest.mark.parametrize(\"login_func\", [ui_login, url_login])\ndef test_login_correct_credentials(login_func, page: Page):\n \"\"\"\n Test logging into the instance with the correct credentials\n\n \"\"\"\n # Log in with correct credentials\n instance = SNowInstance()\n login_func(instance=instance, page=page)\n\n\n@pytest.mark.parametrize(\"login_func\", [ui_login, url_login])\ndef test_login_wrong_credentials(login_func, page: Page):\n \"\"\"\n Test logging into the instance with the wrong credentials\n\n \"\"\"\n # Log in with wrong credentials\n instance = SNowInstance(snow_credentials=(\"wrong\", \"wrong\"))\n with pytest.raises(RuntimeError):\n login_func(instance=instance, page=page)","source_hash":"5252b4090cc44cfacee58149af6f716acd0ac364ed5805cb264964cb7d17ff3e","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional_utils","uri":"program://WorkArena/module/tests.test_compositional_utils#L1-L92","kind":"module","name":"tests.test_compositional_utils","path":"tests/test_compositional_utils.py","language":"python","start_line":1,"end_line":92,"context_start_line":1,"context_end_line":92,"code":"from copy import deepcopy\nimport json\nimport numpy as np\nimport pytest\n\nfrom browsergym.workarena.tasks.compositional.utils.knapsack import KnapsackInstanceGenarator\nfrom browsergym.workarena.tasks.compositional.utils.infeasible_configs import (\n get_infeasible_form_config,\n get_infeasible_service_catalog_config,\n get_infeasible_filter_config,\n get_infeasible_sort_config,\n)\nfrom browsergym.workarena.config import (\n CREATE_USER_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n FILTER_USER_LIST_CONFIG_PATH,\n SORT_USER_LIST_CONFIG_PATH,\n)\n\n\n@pytest.mark.parametrize(\n \"mode\", [\"random\", \"trivial\", \"single_item\", \"single_item_uniform\", \"n_items\"]\n)\ndef test_knapsack(mode: str, num_items_in_solution: int = 2):\n num_items_in_solution = 2 if mode == \"n_items\" else 1\n knapsack = KnapsackInstanceGenarator(\n random=np.random,\n num_items=3,\n max_capacity=150000,\n mode=mode,\n num_items_in_solution=num_items_in_solution,\n )\n investments, max_return, selected_indices = knapsack.get_instance()\n\n # In these modes, all items are identical, so the optimal solution can be any\n if mode in [\"n_items\", \"single_item_uniform\"]:\n selected_indices = [i for i in range(num_items_in_solution)]\n\n assert len(investments) == 3\n assert sum(investments[i][0] for i in selected_indices) <= 150000\n assert max_return == sum(investments[i][1] for i in selected_indices)\n\n if mode != \"trivial\":\n unselected_index = [i for i in range(3) if i not in selected_indices][0]\n assert (\n sum(investments[i][0] for i in selected_indices) + investments[unselected_index][0]\n > 150000\n )\n else:\n assert len(selected_indices) == len(investments)\n\n\nconfig_generator_and_config_path = [\n [get_infeasible_form_config, CREATE_USER_CONFIG_PATH],\n [get_infeasible_service_catalog_config, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH],\n [get_infeasible_filter_config, FILTER_USER_LIST_CONFIG_PATH],\n [get_infeasible_sort_config, SORT_USER_LIST_CONFIG_PATH],\n]\n\n\n@pytest.mark.parametrize(\"function_to_path\", config_generator_and_config_path)\ndef test_invalid_config_generator(function_to_path):\n def parse_nested_dict(nested_dict, keywords):\n \"\"\"Look for keywords in a nested dictionary.\n Return True if any keyword is found, False otherwise.\n \"\"\"\n for key, value in nested_dict.items():\n if key in keywords or value in keywords:\n return True\n if isinstance(value, dict):\n if parse_nested_dict(value, keywords):\n return True\n elif isinstance(value, list):\n for item in value:\n if isinstance(item, dict):\n if parse_nested_dict(item, keywords):\n return True\n elif isinstance(value, str):\n for keyword in keywords:\n if keyword in value:\n return True\n return False\n\n config_generator, config_path = function_to_path\n with open(config_path, \"r\") as f:\n config = json.load(f)[0]\n base_config = deepcopy(config)\n\n invalid_config, infeasible_reasons = config_generator(random=np.random, config=config)\n assert invalid_config != base_config\n assert parse_nested_dict(invalid_config, infeasible_reasons)\n assert parse_nested_dict(base_config, infeasible_reasons) == False","source_hash":"cc8b41d48bbadc4534d35bffce3669ce72f838b210224f0577c63c9a7eab58c4","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional_utils.test_knapsack","uri":"program://WorkArena/function/tests.test_compositional_utils.test_knapsack#L24-L50","kind":"function","name":"test_knapsack","path":"tests/test_compositional_utils.py","language":"python","start_line":24,"end_line":50,"context_start_line":4,"context_end_line":70,"code":"import pytest\n\nfrom browsergym.workarena.tasks.compositional.utils.knapsack import KnapsackInstanceGenarator\nfrom browsergym.workarena.tasks.compositional.utils.infeasible_configs import (\n get_infeasible_form_config,\n get_infeasible_service_catalog_config,\n get_infeasible_filter_config,\n get_infeasible_sort_config,\n)\nfrom browsergym.workarena.config import (\n CREATE_USER_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n FILTER_USER_LIST_CONFIG_PATH,\n SORT_USER_LIST_CONFIG_PATH,\n)\n\n\n@pytest.mark.parametrize(\n \"mode\", [\"random\", \"trivial\", \"single_item\", \"single_item_uniform\", \"n_items\"]\n)\ndef test_knapsack(mode: str, num_items_in_solution: int = 2):\n num_items_in_solution = 2 if mode == \"n_items\" else 1\n knapsack = KnapsackInstanceGenarator(\n random=np.random,\n num_items=3,\n max_capacity=150000,\n mode=mode,\n num_items_in_solution=num_items_in_solution,\n )\n investments, max_return, selected_indices = knapsack.get_instance()\n\n # In these modes, all items are identical, so the optimal solution can be any\n if mode in [\"n_items\", \"single_item_uniform\"]:\n selected_indices = [i for i in range(num_items_in_solution)]\n\n assert len(investments) == 3\n assert sum(investments[i][0] for i in selected_indices) <= 150000\n assert max_return == sum(investments[i][1] for i in selected_indices)\n\n if mode != \"trivial\":\n unselected_index = [i for i in range(3) if i not in selected_indices][0]\n assert (\n sum(investments[i][0] for i in selected_indices) + investments[unselected_index][0]\n > 150000\n )\n else:\n assert len(selected_indices) == len(investments)\n\n\nconfig_generator_and_config_path = [\n [get_infeasible_form_config, CREATE_USER_CONFIG_PATH],\n [get_infeasible_service_catalog_config, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH],\n [get_infeasible_filter_config, FILTER_USER_LIST_CONFIG_PATH],\n [get_infeasible_sort_config, SORT_USER_LIST_CONFIG_PATH],\n]\n\n\n@pytest.mark.parametrize(\"function_to_path\", config_generator_and_config_path)\ndef test_invalid_config_generator(function_to_path):\n def parse_nested_dict(nested_dict, keywords):\n \"\"\"Look for keywords in a nested dictionary.\n Return True if any keyword is found, False otherwise.\n \"\"\"\n for key, value in nested_dict.items():\n if key in keywords or value in keywords:\n return True\n if isinstance(value, dict):","source_hash":"cc8b41d48bbadc4534d35bffce3669ce72f838b210224f0577c63c9a7eab58c4","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional_utils.test_invalid_config_generator","uri":"program://WorkArena/function/tests.test_compositional_utils.test_invalid_config_generator#L62-L92","kind":"function","name":"test_invalid_config_generator","path":"tests/test_compositional_utils.py","language":"python","start_line":62,"end_line":92,"context_start_line":42,"context_end_line":92,"code":"\n if mode != \"trivial\":\n unselected_index = [i for i in range(3) if i not in selected_indices][0]\n assert (\n sum(investments[i][0] for i in selected_indices) + investments[unselected_index][0]\n > 150000\n )\n else:\n assert len(selected_indices) == len(investments)\n\n\nconfig_generator_and_config_path = [\n [get_infeasible_form_config, CREATE_USER_CONFIG_PATH],\n [get_infeasible_service_catalog_config, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH],\n [get_infeasible_filter_config, FILTER_USER_LIST_CONFIG_PATH],\n [get_infeasible_sort_config, SORT_USER_LIST_CONFIG_PATH],\n]\n\n\n@pytest.mark.parametrize(\"function_to_path\", config_generator_and_config_path)\ndef test_invalid_config_generator(function_to_path):\n def parse_nested_dict(nested_dict, keywords):\n \"\"\"Look for keywords in a nested dictionary.\n Return True if any keyword is found, False otherwise.\n \"\"\"\n for key, value in nested_dict.items():\n if key in keywords or value in keywords:\n return True\n if isinstance(value, dict):\n if parse_nested_dict(value, keywords):\n return True\n elif isinstance(value, list):\n for item in value:\n if isinstance(item, dict):\n if parse_nested_dict(item, keywords):\n return True\n elif isinstance(value, str):\n for keyword in keywords:\n if keyword in value:\n return True\n return False\n\n config_generator, config_path = function_to_path\n with open(config_path, \"r\") as f:\n config = json.load(f)[0]\n base_config = deepcopy(config)\n\n invalid_config, infeasible_reasons = config_generator(random=np.random, config=config)\n assert invalid_config != base_config\n assert parse_nested_dict(invalid_config, infeasible_reasons)\n assert parse_nested_dict(base_config, infeasible_reasons) == False","source_hash":"cc8b41d48bbadc4534d35bffce3669ce72f838b210224f0577c63c9a7eab58c4","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional_utils.parse_nested_dict","uri":"program://WorkArena/function/tests.test_compositional_utils.parse_nested_dict#L63-L82","kind":"function","name":"parse_nested_dict","path":"tests/test_compositional_utils.py","language":"python","start_line":63,"end_line":82,"context_start_line":43,"context_end_line":92,"code":" if mode != \"trivial\":\n unselected_index = [i for i in range(3) if i not in selected_indices][0]\n assert (\n sum(investments[i][0] for i in selected_indices) + investments[unselected_index][0]\n > 150000\n )\n else:\n assert len(selected_indices) == len(investments)\n\n\nconfig_generator_and_config_path = [\n [get_infeasible_form_config, CREATE_USER_CONFIG_PATH],\n [get_infeasible_service_catalog_config, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH],\n [get_infeasible_filter_config, FILTER_USER_LIST_CONFIG_PATH],\n [get_infeasible_sort_config, SORT_USER_LIST_CONFIG_PATH],\n]\n\n\n@pytest.mark.parametrize(\"function_to_path\", config_generator_and_config_path)\ndef test_invalid_config_generator(function_to_path):\n def parse_nested_dict(nested_dict, keywords):\n \"\"\"Look for keywords in a nested dictionary.\n Return True if any keyword is found, False otherwise.\n \"\"\"\n for key, value in nested_dict.items():\n if key in keywords or value in keywords:\n return True\n if isinstance(value, dict):\n if parse_nested_dict(value, keywords):\n return True\n elif isinstance(value, list):\n for item in value:\n if isinstance(item, dict):\n if parse_nested_dict(item, keywords):\n return True\n elif isinstance(value, str):\n for keyword in keywords:\n if keyword in value:\n return True\n return False\n\n config_generator, config_path = function_to_path\n with open(config_path, \"r\") as f:\n config = json.load(f)[0]\n base_config = deepcopy(config)\n\n invalid_config, infeasible_reasons = config_generator(random=np.random, config=config)\n assert invalid_config != base_config\n assert parse_nested_dict(invalid_config, infeasible_reasons)\n assert parse_nested_dict(base_config, infeasible_reasons) == False","source_hash":"cc8b41d48bbadc4534d35bffce3669ce72f838b210224f0577c63c9a7eab58c4","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_general","uri":"program://WorkArena/module/tests.test_task_general#L1-L39","kind":"module","name":"tests.test_task_general","path":"tests/test_task_general.py","language":"python","start_line":1,"end_line":39,"context_start_line":1,"context_end_line":39,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport json\nimport logging\nimport pickle\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\n\nfrom browsergym.workarena import ATOMIC_TASKS\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint\", ATOMIC_TASKS)\n@pytest.mark.parametrize(\"random_seed\", range(1))\n@pytest.mark.slow\ndef test_cheat(task_entrypoint, random_seed: int, page: Page):\n task = task_entrypoint(seed=random_seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is False and reward == 0.0\n assert type(message) == str and type(info) == dict\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task.teardown()\n assert done is True and reward == 1.0","source_hash":"4c38cb8bc12dc807c183f4bfdf8783bbc9c07fb1724f60b3470079c09ccaae22","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_general.test_cheat","uri":"program://WorkArena/function/tests.test_task_general.test_cheat#L29-L39","kind":"function","name":"test_cheat","path":"tests/test_task_general.py","language":"python","start_line":29,"end_line":39,"context_start_line":9,"context_end_line":39,"code":"import pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\n\nfrom browsergym.workarena import ATOMIC_TASKS\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint\", ATOMIC_TASKS)\n@pytest.mark.parametrize(\"random_seed\", range(1))\n@pytest.mark.slow\ndef test_cheat(task_entrypoint, random_seed: int, page: Page):\n task = task_entrypoint(seed=random_seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is False and reward == 0.0\n assert type(message) == str and type(info) == dict\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task.teardown()\n assert done is True and reward == 1.0","source_hash":"4c38cb8bc12dc807c183f4bfdf8783bbc9c07fb1724f60b3470079c09ccaae22","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_setup","uri":"program://WorkArena/module/tests.test_task_setup#L1-L94","kind":"module","name":"tests.test_task_setup","path":"tests/test_task_setup.py","language":"python","start_line":1,"end_line":94,"context_start_line":1,"context_end_line":94,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport pytest\nimport json\nimport logging\nimport random\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena.config import ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import OrderAppleWatchTask\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.slow\ndef test_add_to_cart_disabled(page: Page):\n task_config = json.load(open(ORDER_APPLE_WATCH_TASK_CONFIG_PATH, \"r\"))[0]\n task = OrderAppleWatchTask(seed=1, fixed_config=task_config)\n # setup the task and try clicking on the \"Add to cart button\"\n task.setup(page=page)\n order_apple_watch_page = (\n task.instance.snow_url\n + \"/now/nav/ui/classic/params/target/com.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26sysparm_id%3D774906834fbb4200086eeed18110c737%26sysparm_link_parent%3Dd258b953c611227a0146101fb1be7c31%26sysparm_catalog%3De0d08b13c3330100c8b837659bba8fb4%26sysparm_catalog_view%3Dcatalog_default%26sysparm_view%3Dcatalog_default\"\n )\n task.page.goto(order_apple_watch_page)\n task.page.wait_for_timeout(1000)\n iframe_element = task.page.wait_for_selector(\"#gsft_main\")\n iframe = iframe_element.content_frame()\n task.teardown()\n # verify that Add to cart is disabled and order now is enabled\n assert iframe.locator('button[aria-label=\"Add to Cart\"]').is_disabled()\n assert iframe.locator('button[aria-label=\"Order Now\"]').is_enabled()\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.slow\ndef test_top_items_panel_removed(page: Page):\n def check_top_items_panel(page: Page) -> bool:\n \"\"\"Checks if the 'top items' panel exists on the landing page\"\"\"\n frame = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n\n # Use evaluate to find divs containing an element with role=\"heading\" and the text \"Top Requests\"\n panel_exists = frame.evaluate(\n \"\"\"() => {\n const headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n let panelExists = false;\n headings.forEach((heading) => {\n if (heading.textContent.includes(\"Top Requests\")) {\n panelExists = true;\n }\n });\n return panelExists;\n }\"\"\"\n )\n\n return panel_exists\n\n # # Create a new task outside the service catalog and check if the Top Items panel exists\n # TODO: Uncomment this code and fix the test; it is currently failing, but the functionality is optional\n menu_task = AllMenuTask(seed=1)\n menu_task.setup(page=page)\n menu_task.page.goto(\n menu_task.instance.snow_url\n + r\"/now/nav/ui/classic/params/target/catalog_home.do%3Fsysparm_view%3Dcatalog_default\"\n )\n menu_task.page.wait_for_timeout(2000)\n panel_exists = check_top_items_panel(page=menu_task.page)\n menu_task.teardown()\n assert panel_exists is True\n\n service_catalog_task = OrderAppleWatchTask(seed=1)\n # Setup the task and check if the Top Items panel exists\n service_catalog_task.setup(page=page)\n service_catalog_task.page.wait_for_timeout(2000)\n panel_exists = check_top_items_panel(page=service_catalog_task.page)\n service_catalog_task.teardown()\n assert panel_exists is False","source_hash":"4e5551b1de660838ff5af8b8c2cab3675f5247b19a7ddb9ba53f756eaa789368","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_setup.test_add_to_cart_disabled","uri":"program://WorkArena/function/tests.test_task_setup.test_add_to_cart_disabled#L28-L44","kind":"function","name":"test_add_to_cart_disabled","path":"tests/test_task_setup.py","language":"python","start_line":28,"end_line":44,"context_start_line":8,"context_end_line":64,"code":"import logging\nimport random\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena.config import ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import OrderAppleWatchTask\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.slow\ndef test_add_to_cart_disabled(page: Page):\n task_config = json.load(open(ORDER_APPLE_WATCH_TASK_CONFIG_PATH, \"r\"))[0]\n task = OrderAppleWatchTask(seed=1, fixed_config=task_config)\n # setup the task and try clicking on the \"Add to cart button\"\n task.setup(page=page)\n order_apple_watch_page = (\n task.instance.snow_url\n + \"/now/nav/ui/classic/params/target/com.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26sysparm_id%3D774906834fbb4200086eeed18110c737%26sysparm_link_parent%3Dd258b953c611227a0146101fb1be7c31%26sysparm_catalog%3De0d08b13c3330100c8b837659bba8fb4%26sysparm_catalog_view%3Dcatalog_default%26sysparm_view%3Dcatalog_default\"\n )\n task.page.goto(order_apple_watch_page)\n task.page.wait_for_timeout(1000)\n iframe_element = task.page.wait_for_selector(\"#gsft_main\")\n iframe = iframe_element.content_frame()\n task.teardown()\n # verify that Add to cart is disabled and order now is enabled\n assert iframe.locator('button[aria-label=\"Add to Cart\"]').is_disabled()\n assert iframe.locator('button[aria-label=\"Order Now\"]').is_enabled()\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.slow\ndef test_top_items_panel_removed(page: Page):\n def check_top_items_panel(page: Page) -> bool:\n \"\"\"Checks if the 'top items' panel exists on the landing page\"\"\"\n frame = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n\n # Use evaluate to find divs containing an element with role=\"heading\" and the text \"Top Requests\"\n panel_exists = frame.evaluate(\n \"\"\"() => {\n const headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n let panelExists = false;\n headings.forEach((heading) => {","source_hash":"4e5551b1de660838ff5af8b8c2cab3675f5247b19a7ddb9ba53f756eaa789368","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_setup.test_top_items_panel_removed","uri":"program://WorkArena/function/tests.test_task_setup.test_top_items_panel_removed#L54-L94","kind":"function","name":"test_top_items_panel_removed","path":"tests/test_task_setup.py","language":"python","start_line":54,"end_line":94,"context_start_line":34,"context_end_line":94,"code":" task.instance.snow_url\n + \"/now/nav/ui/classic/params/target/com.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26sysparm_id%3D774906834fbb4200086eeed18110c737%26sysparm_link_parent%3Dd258b953c611227a0146101fb1be7c31%26sysparm_catalog%3De0d08b13c3330100c8b837659bba8fb4%26sysparm_catalog_view%3Dcatalog_default%26sysparm_view%3Dcatalog_default\"\n )\n task.page.goto(order_apple_watch_page)\n task.page.wait_for_timeout(1000)\n iframe_element = task.page.wait_for_selector(\"#gsft_main\")\n iframe = iframe_element.content_frame()\n task.teardown()\n # verify that Add to cart is disabled and order now is enabled\n assert iframe.locator('button[aria-label=\"Add to Cart\"]').is_disabled()\n assert iframe.locator('button[aria-label=\"Order Now\"]').is_enabled()\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.slow\ndef test_top_items_panel_removed(page: Page):\n def check_top_items_panel(page: Page) -> bool:\n \"\"\"Checks if the 'top items' panel exists on the landing page\"\"\"\n frame = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n\n # Use evaluate to find divs containing an element with role=\"heading\" and the text \"Top Requests\"\n panel_exists = frame.evaluate(\n \"\"\"() => {\n const headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n let panelExists = false;\n headings.forEach((heading) => {\n if (heading.textContent.includes(\"Top Requests\")) {\n panelExists = true;\n }\n });\n return panelExists;\n }\"\"\"\n )\n\n return panel_exists\n\n # # Create a new task outside the service catalog and check if the Top Items panel exists\n # TODO: Uncomment this code and fix the test; it is currently failing, but the functionality is optional\n menu_task = AllMenuTask(seed=1)\n menu_task.setup(page=page)\n menu_task.page.goto(\n menu_task.instance.snow_url\n + r\"/now/nav/ui/classic/params/target/catalog_home.do%3Fsysparm_view%3Dcatalog_default\"\n )\n menu_task.page.wait_for_timeout(2000)\n panel_exists = check_top_items_panel(page=menu_task.page)\n menu_task.teardown()\n assert panel_exists is True\n\n service_catalog_task = OrderAppleWatchTask(seed=1)\n # Setup the task and check if the Top Items panel exists\n service_catalog_task.setup(page=page)\n service_catalog_task.page.wait_for_timeout(2000)\n panel_exists = check_top_items_panel(page=service_catalog_task.page)\n service_catalog_task.teardown()\n assert panel_exists is False","source_hash":"4e5551b1de660838ff5af8b8c2cab3675f5247b19a7ddb9ba53f756eaa789368","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_setup.check_top_items_panel","uri":"program://WorkArena/function/tests.test_task_setup.check_top_items_panel#L55-L73","kind":"function","name":"check_top_items_panel","path":"tests/test_task_setup.py","language":"python","start_line":55,"end_line":73,"context_start_line":35,"context_end_line":93,"code":" + \"/now/nav/ui/classic/params/target/com.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26sysparm_id%3D774906834fbb4200086eeed18110c737%26sysparm_link_parent%3Dd258b953c611227a0146101fb1be7c31%26sysparm_catalog%3De0d08b13c3330100c8b837659bba8fb4%26sysparm_catalog_view%3Dcatalog_default%26sysparm_view%3Dcatalog_default\"\n )\n task.page.goto(order_apple_watch_page)\n task.page.wait_for_timeout(1000)\n iframe_element = task.page.wait_for_selector(\"#gsft_main\")\n iframe = iframe_element.content_frame()\n task.teardown()\n # verify that Add to cart is disabled and order now is enabled\n assert iframe.locator('button[aria-label=\"Add to Cart\"]').is_disabled()\n assert iframe.locator('button[aria-label=\"Order Now\"]').is_enabled()\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.slow\ndef test_top_items_panel_removed(page: Page):\n def check_top_items_panel(page: Page) -> bool:\n \"\"\"Checks if the 'top items' panel exists on the landing page\"\"\"\n frame = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n\n # Use evaluate to find divs containing an element with role=\"heading\" and the text \"Top Requests\"\n panel_exists = frame.evaluate(\n \"\"\"() => {\n const headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n let panelExists = false;\n headings.forEach((heading) => {\n if (heading.textContent.includes(\"Top Requests\")) {\n panelExists = true;\n }\n });\n return panelExists;\n }\"\"\"\n )\n\n return panel_exists\n\n # # Create a new task outside the service catalog and check if the Top Items panel exists\n # TODO: Uncomment this code and fix the test; it is currently failing, but the functionality is optional\n menu_task = AllMenuTask(seed=1)\n menu_task.setup(page=page)\n menu_task.page.goto(\n menu_task.instance.snow_url\n + r\"/now/nav/ui/classic/params/target/catalog_home.do%3Fsysparm_view%3Dcatalog_default\"\n )\n menu_task.page.wait_for_timeout(2000)\n panel_exists = check_top_items_panel(page=menu_task.page)\n menu_task.teardown()\n assert panel_exists is True\n\n service_catalog_task = OrderAppleWatchTask(seed=1)\n # Setup the task and check if the Top Items panel exists\n service_catalog_task.setup(page=page)\n service_catalog_task.page.wait_for_timeout(2000)\n panel_exists = check_top_items_panel(page=service_catalog_task.page)\n service_catalog_task.teardown()","source_hash":"4e5551b1de660838ff5af8b8c2cab3675f5247b19a7ddb9ba53f756eaa789368","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional","uri":"program://WorkArena/module/tests.test_compositional#L1-L169","kind":"module","name":"tests.test_compositional","path":"tests/test_compositional.py","language":"python","start_line":1,"end_line":169,"context_start_line":1,"context_end_line":169,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport logging\n\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena import ALL_COMPOSITIONAL_TASKS, get_all_tasks_agents\n\nAGENT_L2_SAMPLED_SET = get_all_tasks_agents(filter=\"l2\")\n\nAGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS = [sampled_set[0] for sampled_set in AGENT_L2_SAMPLED_SET], [\n sampled_set[1] for sampled_set in AGENT_L2_SAMPLED_SET\n]\n\nAGENT_L3_SAMPLED_SET = get_all_tasks_agents(filter=\"l3\")\n\nAGENT_L3_SAMPLED_TASKS, AGENT_L3_SEEDS = [sampled_set[0] for sampled_set in AGENT_L3_SAMPLED_SET], [\n sampled_set[1] for sampled_set in AGENT_L3_SAMPLED_SET\n]\n\nHUMAN_L2_SAMPLED_SET = get_all_tasks_agents(filter=\"l2\", is_agent_curriculum=False)\n\nHUMAN_L2_SAMPLED_TASKS, HUMAN_L2_SEEDS = [sampled_set[0] for sampled_set in HUMAN_L2_SAMPLED_SET], [\n sampled_set[1] for sampled_set in HUMAN_L2_SAMPLED_SET\n]\n\nHUMAN_L3_SAMPLED_SET = get_all_tasks_agents(filter=\"l3\", is_agent_curriculum=False)\n\nHUMAN_L3_SAMPLED_TASKS, HUMAN_L3_SEEDS = [sampled_set[0] for sampled_set in HUMAN_L3_SAMPLED_SET], [\n sampled_set[1] for sampled_set in HUMAN_L3_SAMPLED_SET\n]\n\n\n@retry(\n stop=stop_after_attempt(5),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint\", ALL_COMPOSITIONAL_TASKS)\n@pytest.mark.parametrize(\"random_seed\", range(1))\n@pytest.mark.parametrize(\"level\", range(2, 4))\n@pytest.mark.pricy\ndef test_cheat_compositional(task_entrypoint, random_seed, level, page: Page):\n task = task_entrypoint(seed=random_seed, level=level)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(AGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_agent_set_l2(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(AGENT_L3_SAMPLED_TASKS, AGENT_L3_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_agent_set_l3(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(HUMAN_L2_SAMPLED_TASKS, HUMAN_L2_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_human_set_l2(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(HUMAN_L3_SAMPLED_TASKS, HUMAN_L3_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_human_set_l3(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0","source_hash":"8dead70013571e730165285f0cebcec54f7e0ad2daac826ab412b3e1718d8b10","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional.test_cheat_compositional","uri":"program://WorkArena/function/tests.test_compositional.test_cheat_compositional#L51-L65","kind":"function","name":"test_cheat_compositional","path":"tests/test_compositional.py","language":"python","start_line":51,"end_line":65,"context_start_line":31,"context_end_line":85,"code":"HUMAN_L2_SAMPLED_TASKS, HUMAN_L2_SEEDS = [sampled_set[0] for sampled_set in HUMAN_L2_SAMPLED_SET], [\n sampled_set[1] for sampled_set in HUMAN_L2_SAMPLED_SET\n]\n\nHUMAN_L3_SAMPLED_SET = get_all_tasks_agents(filter=\"l3\", is_agent_curriculum=False)\n\nHUMAN_L3_SAMPLED_TASKS, HUMAN_L3_SEEDS = [sampled_set[0] for sampled_set in HUMAN_L3_SAMPLED_SET], [\n sampled_set[1] for sampled_set in HUMAN_L3_SAMPLED_SET\n]\n\n\n@retry(\n stop=stop_after_attempt(5),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint\", ALL_COMPOSITIONAL_TASKS)\n@pytest.mark.parametrize(\"random_seed\", range(1))\n@pytest.mark.parametrize(\"level\", range(2, 4))\n@pytest.mark.pricy\ndef test_cheat_compositional(task_entrypoint, random_seed, level, page: Page):\n task = task_entrypoint(seed=random_seed, level=level)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(AGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_agent_set_l2(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)","source_hash":"8dead70013571e730165285f0cebcec54f7e0ad2daac826ab412b3e1718d8b10","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional.test_cheat_compositional_sampled_agent_set_l2","uri":"program://WorkArena/function/tests.test_compositional.test_cheat_compositional_sampled_agent_set_l2#L77-L91","kind":"function","name":"test_cheat_compositional_sampled_agent_set_l2","path":"tests/test_compositional.py","language":"python","start_line":77,"end_line":91,"context_start_line":57,"context_end_line":111,"code":" task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(AGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_agent_set_l2(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(AGENT_L3_SAMPLED_TASKS, AGENT_L3_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_agent_set_l3(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)","source_hash":"8dead70013571e730165285f0cebcec54f7e0ad2daac826ab412b3e1718d8b10","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional.test_cheat_compositional_sampled_agent_set_l3","uri":"program://WorkArena/function/tests.test_compositional.test_cheat_compositional_sampled_agent_set_l3#L103-L117","kind":"function","name":"test_cheat_compositional_sampled_agent_set_l3","path":"tests/test_compositional.py","language":"python","start_line":103,"end_line":117,"context_start_line":83,"context_end_line":137,"code":" task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(AGENT_L3_SAMPLED_TASKS, AGENT_L3_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_agent_set_l3(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(HUMAN_L2_SAMPLED_TASKS, HUMAN_L2_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_human_set_l2(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)","source_hash":"8dead70013571e730165285f0cebcec54f7e0ad2daac826ab412b3e1718d8b10","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional.test_cheat_compositional_sampled_human_set_l2","uri":"program://WorkArena/function/tests.test_compositional.test_cheat_compositional_sampled_human_set_l2#L129-L143","kind":"function","name":"test_cheat_compositional_sampled_human_set_l2","path":"tests/test_compositional.py","language":"python","start_line":129,"end_line":143,"context_start_line":109,"context_end_line":163,"code":" task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(HUMAN_L2_SAMPLED_TASKS, HUMAN_L2_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_human_set_l2(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(HUMAN_L3_SAMPLED_TASKS, HUMAN_L3_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_human_set_l3(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)","source_hash":"8dead70013571e730165285f0cebcec54f7e0ad2daac826ab412b3e1718d8b10","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_compositional.test_cheat_compositional_sampled_human_set_l3","uri":"program://WorkArena/function/tests.test_compositional.test_cheat_compositional_sampled_human_set_l3#L155-L169","kind":"function","name":"test_cheat_compositional_sampled_human_set_l3","path":"tests/test_compositional.py","language":"python","start_line":155,"end_line":169,"context_start_line":135,"context_end_line":169,"code":" task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint, seed\", zip(HUMAN_L3_SAMPLED_TASKS, HUMAN_L3_SEEDS))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_compositional_sampled_human_set_l3(task_entrypoint, seed, page: Page):\n task = task_entrypoint(seed=seed)\n goal, info = task.setup(page=page)\n chat_messages = []\n for i in range(len(task)):\n page.wait_for_timeout(1000)\n task.cheat(page=page, chat_messages=chat_messages, subtask_idx=i)\n page.wait_for_timeout(1000)\n reward, done, message, info = task.validate(page=page, chat_messages=chat_messages)\n if i < len(task) - 1:\n assert done is False and reward == 0.0\n\n task.teardown()\n\n assert done is True and reward == 1.0","source_hash":"8dead70013571e730165285f0cebcec54f7e0ad2daac826ab412b3e1718d8b10","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_validate","uri":"program://WorkArena/module/tests.test_validate#L1-L39","kind":"module","name":"tests.test_validate","path":"tests/test_validate.py","language":"python","start_line":1,"end_line":39,"context_start_line":1,"context_end_line":39,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport pytest\nimport json\nimport logging\nimport random\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena.config import ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\nfrom browsergym.workarena.tasks.service_catalog import OrderAppleWatchTask\nfrom browsergym.workarena.tasks.scripts.validate import validate_configs\n\n\n@retry(\n stop=stop_after_attempt(2),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\ndef test_validate_configs(page: Page):\n failed_tasks = validate_configs(\n OrderAppleWatchTask,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n num_tasks=2,\n save_failed_tasks=False,\n page=page,\n )\n # assert that there are no failed tasks\n assert len(failed_tasks[\"cheat\"]) == 0\n assert len(failed_tasks[\"no_reward\"]) == 0\n assert len(failed_tasks[\"exception\"]) == 0\n assert len(failed_tasks[\"not_done\"]) == 0","source_hash":"138d4862430c4d257eb804c0ffa1f736f1c24084202f313e536e25109c07cb76","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_validate.test_validate_configs","uri":"program://WorkArena/function/tests.test_validate.test_validate_configs#L27-L39","kind":"function","name":"test_validate_configs","path":"tests/test_validate.py","language":"python","start_line":27,"end_line":39,"context_start_line":7,"context_end_line":39,"code":"import json\nimport logging\nimport random\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena.config import ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\nfrom browsergym.workarena.tasks.service_catalog import OrderAppleWatchTask\nfrom browsergym.workarena.tasks.scripts.validate import validate_configs\n\n\n@retry(\n stop=stop_after_attempt(2),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\ndef test_validate_configs(page: Page):\n failed_tasks = validate_configs(\n OrderAppleWatchTask,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n num_tasks=2,\n save_failed_tasks=False,\n page=page,\n )\n # assert that there are no failed tasks\n assert len(failed_tasks[\"cheat\"]) == 0\n assert len(failed_tasks[\"no_reward\"]) == 0\n assert len(failed_tasks[\"exception\"]) == 0\n assert len(failed_tasks[\"not_done\"]) == 0","source_hash":"138d4862430c4d257eb804c0ffa1f736f1c24084202f313e536e25109c07cb76","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_random_config_generation","uri":"program://WorkArena/module/tests.test_random_config_generation#L1-L99","kind":"module","name":"tests.test_random_config_generation","path":"tests/test_random_config_generation.py","language":"python","start_line":1,"end_line":99,"context_start_line":1,"context_end_line":99,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport json\nimport logging\nimport pickle\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\n\nfrom browsergym.workarena.tasks.form import (\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,\n CreateUserTask,\n)\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterChangeRequestListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterServiceCatalogItemListTask,\n FilterUserListTask,\n SortAssetListTask,\n SortChangeRequestListTask,\n SortHardwareListTask,\n SortIncidentListTask,\n SortServiceCatalogItemListTask,\n SortUserListTask,\n)\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nRANDOMLY_CONFIGURALBE_TASKS = [\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,\n CreateUserTask,\n FilterAssetListTask,\n FilterChangeRequestListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterServiceCatalogItemListTask,\n FilterUserListTask,\n SortAssetListTask,\n SortChangeRequestListTask,\n SortHardwareListTask,\n SortIncidentListTask,\n SortServiceCatalogItemListTask,\n SortUserListTask,\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n]\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint\", RANDOMLY_CONFIGURALBE_TASKS)\n@pytest.mark.parametrize(\"random_seed\", range(1))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_from_random_config(task_entrypoint, random_seed: int, page: Page):\n task = task_entrypoint(seed=random_seed)\n task._generate_random_config(page=page)\n chat_messages = []\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is False and reward == 0.0\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is True and reward == 1.0\n task.teardown()","source_hash":"9f0ef34db444b4c05ba4f0dc8da685508f6faf715a90abb2420d8e6ca1dae05f","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_random_config_generation.test_cheat_from_random_config","uri":"program://WorkArena/function/tests.test_random_config_generation.test_cheat_from_random_config#L90-L99","kind":"function","name":"test_cheat_from_random_config","path":"tests/test_random_config_generation.py","language":"python","start_line":90,"end_line":99,"context_start_line":70,"context_end_line":99,"code":" OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n]\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\n@pytest.mark.parametrize(\"task_entrypoint\", RANDOMLY_CONFIGURALBE_TASKS)\n@pytest.mark.parametrize(\"random_seed\", range(1))\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_cheat_from_random_config(task_entrypoint, random_seed: int, page: Page):\n task = task_entrypoint(seed=random_seed)\n task._generate_random_config(page=page)\n chat_messages = []\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is False and reward == 0.0\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is True and reward == 1.0\n task.teardown()","source_hash":"9f0ef34db444b4c05ba4f0dc8da685508f6faf715a90abb2420d8e6ca1dae05f","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_snow_instance","uri":"program://WorkArena/module/tests.test_snow_instance#L1-L52","kind":"module","name":"tests.test_snow_instance","path":"tests/test_snow_instance.py","language":"python","start_line":1,"end_line":52,"context_start_line":1,"context_end_line":52,"code":"\"\"\"\nTest that the ServiceNow instance is reachable and that the credentials are correct\n\n\"\"\"\n\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.utils import ui_login\n\n\ndef test_check_is_reachable():\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n # This tests that the user's config is correct\n # If it is not, the creation of the instance object\n # will simply return an exception\n instance = SNowInstance()\n\n # We modify the URL and ensure that the instance is not reachable\n instance.snow_url = \"https://invalid.url\"\n # We check that this raises an exception\n with pytest.raises(RuntimeError):\n instance._check_is_reachable()\n\n\ndef test_instance_active(page: Page):\n \"\"\"\n Test that the ServiceNow instance is active (not hibernating)\n\n \"\"\"\n instance = SNowInstance()\n page.goto(instance.snow_url)\n assert (\n \"hibernating\" not in page.title().lower()\n ), f\"Instance is not active. Wake it up by navigating to {instance.snow_url} in a browser.\"\n\n\ndef test_credentials(page: Page):\n \"\"\"\n Test that the credentials are correct\n\n \"\"\"\n instance = SNowInstance()\n ui_login(instance=instance, page=page) # Raises exception if login fails","source_hash":"9dca26d12894068c3708ceee65556c0650474fecf03fb2a1cd84cb41ed5ab204","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_snow_instance.test_check_is_reachable","uri":"program://WorkArena/function/tests.test_snow_instance.test_check_is_reachable#L17-L31","kind":"function","name":"test_check_is_reachable","path":"tests/test_snow_instance.py","language":"python","start_line":17,"end_line":31,"context_start_line":1,"context_end_line":51,"code":"\"\"\"\nTest that the ServiceNow instance is reachable and that the credentials are correct\n\n\"\"\"\n\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.utils import ui_login\n\n\ndef test_check_is_reachable():\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n # This tests that the user's config is correct\n # If it is not, the creation of the instance object\n # will simply return an exception\n instance = SNowInstance()\n\n # We modify the URL and ensure that the instance is not reachable\n instance.snow_url = \"https://invalid.url\"\n # We check that this raises an exception\n with pytest.raises(RuntimeError):\n instance._check_is_reachable()\n\n\ndef test_instance_active(page: Page):\n \"\"\"\n Test that the ServiceNow instance is active (not hibernating)\n\n \"\"\"\n instance = SNowInstance()\n page.goto(instance.snow_url)\n assert (\n \"hibernating\" not in page.title().lower()\n ), f\"Instance is not active. Wake it up by navigating to {instance.snow_url} in a browser.\"\n\n\ndef test_credentials(page: Page):\n \"\"\"\n Test that the credentials are correct\n\n \"\"\"\n instance = SNowInstance()","source_hash":"9dca26d12894068c3708ceee65556c0650474fecf03fb2a1cd84cb41ed5ab204","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_snow_instance.test_instance_active","uri":"program://WorkArena/function/tests.test_snow_instance.test_instance_active#L34-L43","kind":"function","name":"test_instance_active","path":"tests/test_snow_instance.py","language":"python","start_line":34,"end_line":43,"context_start_line":14,"context_end_line":52,"code":"from browsergym.workarena.utils import ui_login\n\n\ndef test_check_is_reachable():\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n # This tests that the user's config is correct\n # If it is not, the creation of the instance object\n # will simply return an exception\n instance = SNowInstance()\n\n # We modify the URL and ensure that the instance is not reachable\n instance.snow_url = \"https://invalid.url\"\n # We check that this raises an exception\n with pytest.raises(RuntimeError):\n instance._check_is_reachable()\n\n\ndef test_instance_active(page: Page):\n \"\"\"\n Test that the ServiceNow instance is active (not hibernating)\n\n \"\"\"\n instance = SNowInstance()\n page.goto(instance.snow_url)\n assert (\n \"hibernating\" not in page.title().lower()\n ), f\"Instance is not active. Wake it up by navigating to {instance.snow_url} in a browser.\"\n\n\ndef test_credentials(page: Page):\n \"\"\"\n Test that the credentials are correct\n\n \"\"\"\n instance = SNowInstance()\n ui_login(instance=instance, page=page) # Raises exception if login fails","source_hash":"9dca26d12894068c3708ceee65556c0650474fecf03fb2a1cd84cb41ed5ab204","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_snow_instance.test_credentials","uri":"program://WorkArena/function/tests.test_snow_instance.test_credentials#L46-L52","kind":"function","name":"test_credentials","path":"tests/test_snow_instance.py","language":"python","start_line":46,"end_line":52,"context_start_line":26,"context_end_line":52,"code":"\n # We modify the URL and ensure that the instance is not reachable\n instance.snow_url = \"https://invalid.url\"\n # We check that this raises an exception\n with pytest.raises(RuntimeError):\n instance._check_is_reachable()\n\n\ndef test_instance_active(page: Page):\n \"\"\"\n Test that the ServiceNow instance is active (not hibernating)\n\n \"\"\"\n instance = SNowInstance()\n page.goto(instance.snow_url)\n assert (\n \"hibernating\" not in page.title().lower()\n ), f\"Instance is not active. Wake it up by navigating to {instance.snow_url} in a browser.\"\n\n\ndef test_credentials(page: Page):\n \"\"\"\n Test that the credentials are correct\n\n \"\"\"\n instance = SNowInstance()\n ui_login(instance=instance, page=page) # Raises exception if login fails","source_hash":"9dca26d12894068c3708ceee65556c0650474fecf03fb2a1cd84cb41ed5ab204","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.utils","uri":"program://WorkArena/module/tests.utils#L1-L13","kind":"module","name":"tests.utils","path":"tests/utils.py","language":"python","start_line":1,"end_line":13,"context_start_line":1,"context_end_line":13,"code":"import browsergym.core\nimport logging\nimport playwright.sync_api\nimport pytest\n\n\n# setup code, executed ahead of first test\n@pytest.fixture(scope=\"session\", autouse=True)\ndef setup_playwright(playwright: playwright.sync_api.Playwright):\n # bugfix: re-use pytest-playwright's playwright instance in browsergym\n # https://github.com/microsoft/playwright-python/issues/2053\n browsergym.core._set_global_playwright(playwright)\n logging.info(\"Browsergym is using the playwright instance provided by pytest-playwright.\")","source_hash":"e86ea963482bc9b60610380eb17a5289a6989cf2cad509f0245eb3ed6023c11d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.utils.setup_playwright","uri":"program://WorkArena/function/tests.utils.setup_playwright#L9-L13","kind":"function","name":"setup_playwright","path":"tests/utils.py","language":"python","start_line":9,"end_line":13,"context_start_line":1,"context_end_line":13,"code":"import browsergym.core\nimport logging\nimport playwright.sync_api\nimport pytest\n\n\n# setup code, executed ahead of first test\n@pytest.fixture(scope=\"session\", autouse=True)\ndef setup_playwright(playwright: playwright.sync_api.Playwright):\n # bugfix: re-use pytest-playwright's playwright instance in browsergym\n # https://github.com/microsoft/playwright-python/issues/2053\n browsergym.core._set_global_playwright(playwright)\n logging.info(\"Browsergym is using the playwright instance provided by pytest-playwright.\")","source_hash":"e86ea963482bc9b60610380eb17a5289a6989cf2cad509f0245eb3ed6023c11d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_api","uri":"program://WorkArena/module/tests.test_api#L1-L41","kind":"module","name":"tests.test_api","path":"tests/test_api.py","language":"python","start_line":1,"end_line":41,"context_start_line":1,"context_end_line":41,"code":"import numpy as np\nimport pytest\nimport random\n\nfrom time import sleep\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.api.utils import table_api_call\nfrom browsergym.workarena.api.user import create_user, set_user_preference\n\n\n@pytest.mark.parametrize(\"system\", [True, False])\ndef test_set_user_preference(system):\n admin_instance = SNowInstance()\n\n # Create a user to get a sys_id\n if not system:\n uname, pwd, sysid = create_user(SNowInstance())\n user_instance = SNowInstance(snow_credentials=(uname, pwd))\n user = sysid\n else:\n user_instance = admin_instance\n\n # Do it twice to test updating existing preference\n pref_key = f\"workarena.unittest.{random.randint(1, 100000000)}\"\n for _ in range(2):\n pref = set_user_preference(\n user_instance, key=pref_key, value=\"1234\", user=None if system else user\n )\n assert pref[\"name\"] == pref_key\n assert pref[\"value\"] == \"1234\"\n assert pref[\"user\"] == \"\" if system else user\n assert str(pref[\"system\"]).lower() == str(system).lower()\n assert pref[\"description\"] == \"Updated by WorkArena\"\n\n # Delete the preference\n table_api_call(admin_instance, table=f\"sys_user_preference/{pref['sys_id']}\", method=\"DELETE\")\n\n # Delete the user\n if not system:\n table_api_call(admin_instance, table=f\"sys_user/{user}\", method=\"DELETE\")","source_hash":"b5b5c97cfc4898ce304231bcdc0002e7242067ca2b99c14451a9c646d5cc9466","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_api.test_set_user_preference","uri":"program://WorkArena/function/tests.test_api.test_set_user_preference#L13-L41","kind":"function","name":"test_set_user_preference","path":"tests/test_api.py","language":"python","start_line":13,"end_line":41,"context_start_line":1,"context_end_line":41,"code":"import numpy as np\nimport pytest\nimport random\n\nfrom time import sleep\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.api.utils import table_api_call\nfrom browsergym.workarena.api.user import create_user, set_user_preference\n\n\n@pytest.mark.parametrize(\"system\", [True, False])\ndef test_set_user_preference(system):\n admin_instance = SNowInstance()\n\n # Create a user to get a sys_id\n if not system:\n uname, pwd, sysid = create_user(SNowInstance())\n user_instance = SNowInstance(snow_credentials=(uname, pwd))\n user = sysid\n else:\n user_instance = admin_instance\n\n # Do it twice to test updating existing preference\n pref_key = f\"workarena.unittest.{random.randint(1, 100000000)}\"\n for _ in range(2):\n pref = set_user_preference(\n user_instance, key=pref_key, value=\"1234\", user=None if system else user\n )\n assert pref[\"name\"] == pref_key\n assert pref[\"value\"] == \"1234\"\n assert pref[\"user\"] == \"\" if system else user\n assert str(pref[\"system\"]).lower() == str(system).lower()\n assert pref[\"description\"] == \"Updated by WorkArena\"\n\n # Delete the preference\n table_api_call(admin_instance, table=f\"sys_user_preference/{pref['sys_id']}\", method=\"DELETE\")\n\n # Delete the user\n if not system:\n table_api_call(admin_instance, table=f\"sys_user/{user}\", method=\"DELETE\")","source_hash":"b5b5c97cfc4898ce304231bcdc0002e7242067ca2b99c14451a9c646d5cc9466","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config","uri":"program://WorkArena/module/tests.test_task_from_config#L1-L323","kind":"module","name":"tests.test_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":1,"end_line":323,"context_start_line":1,"context_end_line":323,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport pytest\nimport json\nimport logging\nimport random\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena.config import (\n # navigation tasks\n ALL_MENU_PATH,\n IMPERSONATION_CONFIG_PATH,\n # form tasks\n CREATE_CHANGE_REQUEST_CONFIG_PATH,\n CREATE_HARDWARE_CONFIG_PATH,\n CREATE_INCIDENT_CONFIG_PATH,\n CREATE_PROBLEM_CONFIG_PATH,\n CREATE_USER_CONFIG_PATH,\n # list tasks\n FILTER_ASSET_LIST_CONFIG_PATH,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n FILTER_HARDWARE_LIST_CONFIG_PATH,\n FILTER_INCIDENT_LIST_CONFIG_PATH,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n FILTER_USER_LIST_CONFIG_PATH,\n SORT_ASSET_LIST_CONFIG_PATH,\n SORT_CHANGE_REQUEST_LIST_CONFIG_PATH,\n SORT_HARDWARE_LIST_CONFIG_PATH,\n SORT_INCIDENT_LIST_CONFIG_PATH,\n SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n SORT_USER_LIST_CONFIG_PATH,\n # knowledge tasks\n KB_CONFIG_PATH,\n # Service Catalog tasks\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n)\nfrom browsergym.workarena.tasks.form import (\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,\n CreateUserTask,\n)\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterChangeRequestListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterServiceCatalogItemListTask,\n FilterUserListTask,\n SortAssetListTask,\n SortChangeRequestListTask,\n SortHardwareListTask,\n SortIncidentListTask,\n SortServiceCatalogItemListTask,\n SortUserListTask,\n)\nfrom browsergym.workarena.tasks.navigation import AllMenuTask, ImpersonationTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\ndef generic_task_cheat_test(task_class, config_path, page: Page, expected_goal: str = None):\n task_config = json.load(open(config_path, \"r\"))[0]\n task = task_class(seed=1, fixed_config=task_config)\n goal, _ = task.setup(page=page)\n if expected_goal:\n assert goal == expected_goal\n chat_messages = []\n reward, done, message, info = task.validate(page, chat_messages)\n assert (\n isinstance(reward, (int, float))\n and type(done) == bool\n and type(message) == str\n and type(info) == dict\n )\n assert done is False and reward == 0.0\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is True and reward == 1.0\n task.teardown()\n\n\n# Navigation tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_menu_task_from_config(page: Page):\n expected_goal = 'Navigate to the \"AI Search for Next Experience > Guided Setup for Zing to AI Search Migration\" module of the \"AI Search\" application.'\n generic_task_cheat_test(AllMenuTask, ALL_MENU_PATH, page, expected_goal=expected_goal)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_impersonation_from_config(page: Page):\n expected_goal = \"Impersonate the user ATF Change Management.\"\n generic_task_cheat_test(\n ImpersonationTask, IMPERSONATION_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n# Service Catalog tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_developer_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderDeveloperLaptopTask, ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_mini_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadMiniTask, ORDER_IPAD_MINI_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_pro_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadProTask, ORDER_IPAD_PRO_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_sales_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderSalesLaptopTask, ORDER_SALES_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_standard_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderStandardLaptopTask, ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_watch_task_from_config(page: Page):\n expected_goal = 'Go to the hardware store and order 1 \"Apple Watch\"'\n generic_task_cheat_test(\n OrderAppleWatchTask,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_macbook_pro15_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderAppleMacBookPro15Task, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_development_laptop_pc_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderDevelopmentLaptopPCTask, ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_loaner_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderLoanerLaptopTask, ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n# form tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_change_request_task_from_config(page: Page):\n generic_task_cheat_test(CreateChangeRequestTask, CREATE_CHANGE_REQUEST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_hardware_asset_task_from_config(page: Page):\n generic_task_cheat_test(CreateHardwareAssetTask, CREATE_HARDWARE_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_incident_task_from_config(page: Page):\n generic_task_cheat_test(CreateIncidentTask, CREATE_INCIDENT_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_problem_task_from_config(page: Page):\n expected_goal = 'Create a new problem with a value of \"Request for a Blackberry\" for field \"Problem statement\", a value of \"3 - Low\" for field \"Impact\", a value of \"\" for field \"Service\", a value of \"Hardware\" for field \"Category\", a value of \"bizonal wateringly nonsuccessful checkerberry abridgeable\" for field \"Description\", and a value of \"\" for field \"Configuration item\".'\n generic_task_cheat_test(\n CreateProblemTask, CREATE_PROBLEM_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_user_task_from_config(page: Page):\n generic_task_cheat_test(CreateUserTask, CREATE_USER_CONFIG_PATH, page)\n\n\n# knowledge tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_knowledge_base_from_config(page: Page):\n expected_goal = \"Answer the following question using the knowledge base: \\\"Can you provide the direct contact number for the CEO? Answer with the full phone number starting with the '+' sign.\\\"\"\n generic_task_cheat_test(KnowledgeBaseSearchTask, KB_CONFIG_PATH, page)\n\n\n# list tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterAssetListTask, FILTER_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_change_request_list_task_from_config(page: Page):\n expected_goal = 'Create a filter for the list to extract all entries where \"Assignment group\" is \"Hardware\" and \"Assigned to\" is \"Bow Ruggeri\".'\n generic_task_cheat_test(\n FilterChangeRequestListTask,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterHardwareListTask, FILTER_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterIncidentListTask, FILTER_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n FilterServiceCatalogItemListTask,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n page,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_user_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterUserListTask, FILTER_USER_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(SortAssetListTask, SORT_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_change_request_list_task_from_config(page: Page):\n generic_task_cheat_test(SortChangeRequestListTask, SORT_CHANGE_REQUEST_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(SortHardwareListTask, SORT_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(SortIncidentListTask, SORT_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n SortServiceCatalogItemListTask, SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_user_list_task_from_config(page: Page):\n expected_goal = 'Sort the \"users\" list by the following fields:\\n - Active (descending)'\n generic_task_cheat_test(\n SortUserListTask, SORT_USER_LIST_CONFIG_PATH, page, expected_goal=expected_goal\n )","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.generic_task_cheat_test","uri":"program://WorkArena/function/tests.test_task_from_config.generic_task_cheat_test#L93-L111","kind":"function","name":"generic_task_cheat_test","path":"tests/test_task_from_config.py","language":"python","start_line":93,"end_line":111,"context_start_line":73,"context_end_line":131,"code":"from browsergym.workarena.tasks.navigation import AllMenuTask, ImpersonationTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\n\n@retry(\n stop=stop_after_attempt(5),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\ndef generic_task_cheat_test(task_class, config_path, page: Page, expected_goal: str = None):\n task_config = json.load(open(config_path, \"r\"))[0]\n task = task_class(seed=1, fixed_config=task_config)\n goal, _ = task.setup(page=page)\n if expected_goal:\n assert goal == expected_goal\n chat_messages = []\n reward, done, message, info = task.validate(page, chat_messages)\n assert (\n isinstance(reward, (int, float))\n and type(done) == bool\n and type(message) == str\n and type(info) == dict\n )\n assert done is False and reward == 0.0\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is True and reward == 1.0\n task.teardown()\n\n\n# Navigation tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_menu_task_from_config(page: Page):\n expected_goal = 'Navigate to the \"AI Search for Next Experience > Guided Setup for Zing to AI Search Migration\" module of the \"AI Search\" application.'\n generic_task_cheat_test(AllMenuTask, ALL_MENU_PATH, page, expected_goal=expected_goal)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_impersonation_from_config(page: Page):\n expected_goal = \"Impersonate the user ATF Change Management.\"\n generic_task_cheat_test(\n ImpersonationTask, IMPERSONATION_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n# Service Catalog tasks","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_menu_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_menu_task_from_config#L117-L119","kind":"function","name":"test_menu_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":117,"end_line":119,"context_start_line":97,"context_end_line":139,"code":" if expected_goal:\n assert goal == expected_goal\n chat_messages = []\n reward, done, message, info = task.validate(page, chat_messages)\n assert (\n isinstance(reward, (int, float))\n and type(done) == bool\n and type(message) == str\n and type(info) == dict\n )\n assert done is False and reward == 0.0\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is True and reward == 1.0\n task.teardown()\n\n\n# Navigation tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_menu_task_from_config(page: Page):\n expected_goal = 'Navigate to the \"AI Search for Next Experience > Guided Setup for Zing to AI Search Migration\" module of the \"AI Search\" application.'\n generic_task_cheat_test(AllMenuTask, ALL_MENU_PATH, page, expected_goal=expected_goal)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_impersonation_from_config(page: Page):\n expected_goal = \"Impersonate the user ATF Change Management.\"\n generic_task_cheat_test(\n ImpersonationTask, IMPERSONATION_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n# Service Catalog tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_developer_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderDeveloperLaptopTask, ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_impersonation_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_impersonation_from_config#L124-L128","kind":"function","name":"test_impersonation_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":124,"end_line":128,"context_start_line":104,"context_end_line":148,"code":" and type(message) == str\n and type(info) == dict\n )\n assert done is False and reward == 0.0\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n assert done is True and reward == 1.0\n task.teardown()\n\n\n# Navigation tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_menu_task_from_config(page: Page):\n expected_goal = 'Navigate to the \"AI Search for Next Experience > Guided Setup for Zing to AI Search Migration\" module of the \"AI Search\" application.'\n generic_task_cheat_test(AllMenuTask, ALL_MENU_PATH, page, expected_goal=expected_goal)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_impersonation_from_config(page: Page):\n expected_goal = \"Impersonate the user ATF Change Management.\"\n generic_task_cheat_test(\n ImpersonationTask, IMPERSONATION_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n# Service Catalog tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_developer_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderDeveloperLaptopTask, ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_mini_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadMiniTask, ORDER_IPAD_MINI_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_pro_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadProTask, ORDER_IPAD_PRO_TASK_CONFIG_PATH, page)\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_developer_laptop_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_developer_laptop_task_from_config#L134-L135","kind":"function","name":"test_order_developer_laptop_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":134,"end_line":135,"context_start_line":114,"context_end_line":155,"code":"# Navigation tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_menu_task_from_config(page: Page):\n expected_goal = 'Navigate to the \"AI Search for Next Experience > Guided Setup for Zing to AI Search Migration\" module of the \"AI Search\" application.'\n generic_task_cheat_test(AllMenuTask, ALL_MENU_PATH, page, expected_goal=expected_goal)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_impersonation_from_config(page: Page):\n expected_goal = \"Impersonate the user ATF Change Management.\"\n generic_task_cheat_test(\n ImpersonationTask, IMPERSONATION_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n# Service Catalog tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_developer_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderDeveloperLaptopTask, ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_mini_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadMiniTask, ORDER_IPAD_MINI_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_pro_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadProTask, ORDER_IPAD_PRO_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_sales_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderSalesLaptopTask, ORDER_SALES_LAPTOP_TASK_CONFIG_PATH, page)\n\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_ipad_mini_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_ipad_mini_task_from_config#L140-L141","kind":"function","name":"test_order_ipad_mini_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":140,"end_line":141,"context_start_line":120,"context_end_line":161,"code":"\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_impersonation_from_config(page: Page):\n expected_goal = \"Impersonate the user ATF Change Management.\"\n generic_task_cheat_test(\n ImpersonationTask, IMPERSONATION_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n# Service Catalog tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_developer_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderDeveloperLaptopTask, ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_mini_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadMiniTask, ORDER_IPAD_MINI_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_pro_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadProTask, ORDER_IPAD_PRO_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_sales_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderSalesLaptopTask, ORDER_SALES_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_standard_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderStandardLaptopTask, ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH, page)\n\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_ipad_pro_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_ipad_pro_task_from_config#L146-L147","kind":"function","name":"test_order_ipad_pro_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":146,"end_line":147,"context_start_line":126,"context_end_line":167,"code":" generic_task_cheat_test(\n ImpersonationTask, IMPERSONATION_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n# Service Catalog tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_developer_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderDeveloperLaptopTask, ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_mini_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadMiniTask, ORDER_IPAD_MINI_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_pro_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadProTask, ORDER_IPAD_PRO_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_sales_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderSalesLaptopTask, ORDER_SALES_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_standard_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderStandardLaptopTask, ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_watch_task_from_config(page: Page):\n expected_goal = 'Go to the hardware store and order 1 \"Apple Watch\"'\n generic_task_cheat_test(\n OrderAppleWatchTask,","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_sales_laptop_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_sales_laptop_task_from_config#L152-L153","kind":"function","name":"test_order_sales_laptop_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":152,"end_line":153,"context_start_line":132,"context_end_line":173,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_developer_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderDeveloperLaptopTask, ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_mini_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadMiniTask, ORDER_IPAD_MINI_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_pro_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadProTask, ORDER_IPAD_PRO_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_sales_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderSalesLaptopTask, ORDER_SALES_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_standard_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderStandardLaptopTask, ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_watch_task_from_config(page: Page):\n expected_goal = 'Go to the hardware store and order 1 \"Apple Watch\"'\n generic_task_cheat_test(\n OrderAppleWatchTask,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_standard_laptop_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_standard_laptop_task_from_config#L158-L159","kind":"function","name":"test_order_standard_laptop_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":158,"end_line":159,"context_start_line":138,"context_end_line":179,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_mini_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadMiniTask, ORDER_IPAD_MINI_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_pro_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadProTask, ORDER_IPAD_PRO_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_sales_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderSalesLaptopTask, ORDER_SALES_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_standard_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderStandardLaptopTask, ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_watch_task_from_config(page: Page):\n expected_goal = 'Go to the hardware store and order 1 \"Apple Watch\"'\n generic_task_cheat_test(\n OrderAppleWatchTask,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_macbook_pro15_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderAppleMacBookPro15Task, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH, page\n )","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_apple_watch_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_apple_watch_task_from_config#L164-L171","kind":"function","name":"test_order_apple_watch_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":164,"end_line":171,"context_start_line":144,"context_end_line":191,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_ipad_pro_task_from_config(page: Page):\n generic_task_cheat_test(OrderIpadProTask, ORDER_IPAD_PRO_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_sales_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderSalesLaptopTask, ORDER_SALES_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_standard_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderStandardLaptopTask, ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_watch_task_from_config(page: Page):\n expected_goal = 'Go to the hardware store and order 1 \"Apple Watch\"'\n generic_task_cheat_test(\n OrderAppleWatchTask,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_macbook_pro15_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderAppleMacBookPro15Task, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_development_laptop_pc_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderDevelopmentLaptopPCTask, ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_apple_macbook_pro15_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_apple_macbook_pro15_task_from_config#L176-L179","kind":"function","name":"test_order_apple_macbook_pro15_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":176,"end_line":179,"context_start_line":156,"context_end_line":199,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_standard_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderStandardLaptopTask, ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_watch_task_from_config(page: Page):\n expected_goal = 'Go to the hardware store and order 1 \"Apple Watch\"'\n generic_task_cheat_test(\n OrderAppleWatchTask,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_macbook_pro15_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderAppleMacBookPro15Task, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_development_laptop_pc_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderDevelopmentLaptopPCTask, ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_loaner_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderLoanerLaptopTask, ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n# form tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_change_request_task_from_config(page: Page):","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_development_laptop_pc_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_development_laptop_pc_task_from_config#L184-L187","kind":"function","name":"test_order_development_laptop_pc_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":184,"end_line":187,"context_start_line":164,"context_end_line":207,"code":"def test_order_apple_watch_task_from_config(page: Page):\n expected_goal = 'Go to the hardware store and order 1 \"Apple Watch\"'\n generic_task_cheat_test(\n OrderAppleWatchTask,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_macbook_pro15_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderAppleMacBookPro15Task, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_development_laptop_pc_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderDevelopmentLaptopPCTask, ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_loaner_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderLoanerLaptopTask, ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n# form tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_change_request_task_from_config(page: Page):\n generic_task_cheat_test(CreateChangeRequestTask, CREATE_CHANGE_REQUEST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_hardware_asset_task_from_config(page: Page):\n generic_task_cheat_test(CreateHardwareAssetTask, CREATE_HARDWARE_CONFIG_PATH, page)\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_order_loaner_laptop_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_order_loaner_laptop_task_from_config#L192-L193","kind":"function","name":"test_order_loaner_laptop_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":192,"end_line":193,"context_start_line":172,"context_end_line":213,"code":"\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_apple_macbook_pro15_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderAppleMacBookPro15Task, ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_development_laptop_pc_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderDevelopmentLaptopPCTask, ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_loaner_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderLoanerLaptopTask, ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n# form tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_change_request_task_from_config(page: Page):\n generic_task_cheat_test(CreateChangeRequestTask, CREATE_CHANGE_REQUEST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_hardware_asset_task_from_config(page: Page):\n generic_task_cheat_test(CreateHardwareAssetTask, CREATE_HARDWARE_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_incident_task_from_config(page: Page):\n generic_task_cheat_test(CreateIncidentTask, CREATE_INCIDENT_CONFIG_PATH, page)\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_create_change_request_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_create_change_request_task_from_config#L199-L200","kind":"function","name":"test_create_change_request_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":199,"end_line":200,"context_start_line":179,"context_end_line":220,"code":" )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_development_laptop_pc_task_from_config(page: Page):\n generic_task_cheat_test(\n OrderDevelopmentLaptopPCTask, ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_loaner_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderLoanerLaptopTask, ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n# form tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_change_request_task_from_config(page: Page):\n generic_task_cheat_test(CreateChangeRequestTask, CREATE_CHANGE_REQUEST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_hardware_asset_task_from_config(page: Page):\n generic_task_cheat_test(CreateHardwareAssetTask, CREATE_HARDWARE_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_incident_task_from_config(page: Page):\n generic_task_cheat_test(CreateIncidentTask, CREATE_INCIDENT_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_problem_task_from_config(page: Page):\n expected_goal = 'Create a new problem with a value of \"Request for a Blackberry\" for field \"Problem statement\", a value of \"3 - Low\" for field \"Impact\", a value of \"\" for field \"Service\", a value of \"Hardware\" for field \"Category\", a value of \"bizonal wateringly nonsuccessful checkerberry abridgeable\" for field \"Description\", and a value of \"\" for field \"Configuration item\".'\n generic_task_cheat_test(\n CreateProblemTask, CREATE_PROBLEM_CONFIG_PATH, page, expected_goal=expected_goal","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_create_hardware_asset_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_create_hardware_asset_task_from_config#L205-L206","kind":"function","name":"test_create_hardware_asset_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":205,"end_line":206,"context_start_line":185,"context_end_line":226,"code":" generic_task_cheat_test(\n OrderDevelopmentLaptopPCTask, ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_loaner_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderLoanerLaptopTask, ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n# form tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_change_request_task_from_config(page: Page):\n generic_task_cheat_test(CreateChangeRequestTask, CREATE_CHANGE_REQUEST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_hardware_asset_task_from_config(page: Page):\n generic_task_cheat_test(CreateHardwareAssetTask, CREATE_HARDWARE_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_incident_task_from_config(page: Page):\n generic_task_cheat_test(CreateIncidentTask, CREATE_INCIDENT_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_problem_task_from_config(page: Page):\n expected_goal = 'Create a new problem with a value of \"Request for a Blackberry\" for field \"Problem statement\", a value of \"3 - Low\" for field \"Impact\", a value of \"\" for field \"Service\", a value of \"Hardware\" for field \"Category\", a value of \"bizonal wateringly nonsuccessful checkerberry abridgeable\" for field \"Description\", and a value of \"\" for field \"Configuration item\".'\n generic_task_cheat_test(\n CreateProblemTask, CREATE_PROBLEM_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_user_task_from_config(page: Page):","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_create_incident_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_create_incident_task_from_config#L211-L212","kind":"function","name":"test_create_incident_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":211,"end_line":212,"context_start_line":191,"context_end_line":232,"code":"@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_order_loaner_laptop_task_from_config(page: Page):\n generic_task_cheat_test(OrderLoanerLaptopTask, ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH, page)\n\n\n# form tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_change_request_task_from_config(page: Page):\n generic_task_cheat_test(CreateChangeRequestTask, CREATE_CHANGE_REQUEST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_hardware_asset_task_from_config(page: Page):\n generic_task_cheat_test(CreateHardwareAssetTask, CREATE_HARDWARE_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_incident_task_from_config(page: Page):\n generic_task_cheat_test(CreateIncidentTask, CREATE_INCIDENT_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_problem_task_from_config(page: Page):\n expected_goal = 'Create a new problem with a value of \"Request for a Blackberry\" for field \"Problem statement\", a value of \"3 - Low\" for field \"Impact\", a value of \"\" for field \"Service\", a value of \"Hardware\" for field \"Category\", a value of \"bizonal wateringly nonsuccessful checkerberry abridgeable\" for field \"Description\", and a value of \"\" for field \"Configuration item\".'\n generic_task_cheat_test(\n CreateProblemTask, CREATE_PROBLEM_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_user_task_from_config(page: Page):\n generic_task_cheat_test(CreateUserTask, CREATE_USER_CONFIG_PATH, page)\n\n\n# knowledge tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_create_problem_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_create_problem_task_from_config#L217-L221","kind":"function","name":"test_create_problem_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":217,"end_line":221,"context_start_line":197,"context_end_line":241,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_change_request_task_from_config(page: Page):\n generic_task_cheat_test(CreateChangeRequestTask, CREATE_CHANGE_REQUEST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_hardware_asset_task_from_config(page: Page):\n generic_task_cheat_test(CreateHardwareAssetTask, CREATE_HARDWARE_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_incident_task_from_config(page: Page):\n generic_task_cheat_test(CreateIncidentTask, CREATE_INCIDENT_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_problem_task_from_config(page: Page):\n expected_goal = 'Create a new problem with a value of \"Request for a Blackberry\" for field \"Problem statement\", a value of \"3 - Low\" for field \"Impact\", a value of \"\" for field \"Service\", a value of \"Hardware\" for field \"Category\", a value of \"bizonal wateringly nonsuccessful checkerberry abridgeable\" for field \"Description\", and a value of \"\" for field \"Configuration item\".'\n generic_task_cheat_test(\n CreateProblemTask, CREATE_PROBLEM_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_user_task_from_config(page: Page):\n generic_task_cheat_test(CreateUserTask, CREATE_USER_CONFIG_PATH, page)\n\n\n# knowledge tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_knowledge_base_from_config(page: Page):\n expected_goal = \"Answer the following question using the knowledge base: \\\"Can you provide the direct contact number for the CEO? Answer with the full phone number starting with the '+' sign.\\\"\"\n generic_task_cheat_test(KnowledgeBaseSearchTask, KB_CONFIG_PATH, page)\n\n\n# list tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_asset_list_task_from_config(page: Page):","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_create_user_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_create_user_task_from_config#L226-L227","kind":"function","name":"test_create_user_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":226,"end_line":227,"context_start_line":206,"context_end_line":247,"code":" generic_task_cheat_test(CreateHardwareAssetTask, CREATE_HARDWARE_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_incident_task_from_config(page: Page):\n generic_task_cheat_test(CreateIncidentTask, CREATE_INCIDENT_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_problem_task_from_config(page: Page):\n expected_goal = 'Create a new problem with a value of \"Request for a Blackberry\" for field \"Problem statement\", a value of \"3 - Low\" for field \"Impact\", a value of \"\" for field \"Service\", a value of \"Hardware\" for field \"Category\", a value of \"bizonal wateringly nonsuccessful checkerberry abridgeable\" for field \"Description\", and a value of \"\" for field \"Configuration item\".'\n generic_task_cheat_test(\n CreateProblemTask, CREATE_PROBLEM_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_user_task_from_config(page: Page):\n generic_task_cheat_test(CreateUserTask, CREATE_USER_CONFIG_PATH, page)\n\n\n# knowledge tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_knowledge_base_from_config(page: Page):\n expected_goal = \"Answer the following question using the knowledge base: \\\"Can you provide the direct contact number for the CEO? Answer with the full phone number starting with the '+' sign.\\\"\"\n generic_task_cheat_test(KnowledgeBaseSearchTask, KB_CONFIG_PATH, page)\n\n\n# list tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterAssetListTask, FILTER_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_change_request_list_task_from_config(page: Page):","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_knowledge_base_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_knowledge_base_from_config#L233-L235","kind":"function","name":"test_knowledge_base_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":233,"end_line":235,"context_start_line":213,"context_end_line":255,"code":"\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_problem_task_from_config(page: Page):\n expected_goal = 'Create a new problem with a value of \"Request for a Blackberry\" for field \"Problem statement\", a value of \"3 - Low\" for field \"Impact\", a value of \"\" for field \"Service\", a value of \"Hardware\" for field \"Category\", a value of \"bizonal wateringly nonsuccessful checkerberry abridgeable\" for field \"Description\", and a value of \"\" for field \"Configuration item\".'\n generic_task_cheat_test(\n CreateProblemTask, CREATE_PROBLEM_CONFIG_PATH, page, expected_goal=expected_goal\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_user_task_from_config(page: Page):\n generic_task_cheat_test(CreateUserTask, CREATE_USER_CONFIG_PATH, page)\n\n\n# knowledge tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_knowledge_base_from_config(page: Page):\n expected_goal = \"Answer the following question using the knowledge base: \\\"Can you provide the direct contact number for the CEO? Answer with the full phone number starting with the '+' sign.\\\"\"\n generic_task_cheat_test(KnowledgeBaseSearchTask, KB_CONFIG_PATH, page)\n\n\n# list tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterAssetListTask, FILTER_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_change_request_list_task_from_config(page: Page):\n expected_goal = 'Create a filter for the list to extract all entries where \"Assignment group\" is \"Hardware\" and \"Assigned to\" is \"Bow Ruggeri\".'\n generic_task_cheat_test(\n FilterChangeRequestListTask,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_filter_asset_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_filter_asset_list_task_from_config#L241-L242","kind":"function","name":"test_filter_asset_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":241,"end_line":242,"context_start_line":221,"context_end_line":262,"code":" )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_create_user_task_from_config(page: Page):\n generic_task_cheat_test(CreateUserTask, CREATE_USER_CONFIG_PATH, page)\n\n\n# knowledge tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_knowledge_base_from_config(page: Page):\n expected_goal = \"Answer the following question using the knowledge base: \\\"Can you provide the direct contact number for the CEO? Answer with the full phone number starting with the '+' sign.\\\"\"\n generic_task_cheat_test(KnowledgeBaseSearchTask, KB_CONFIG_PATH, page)\n\n\n# list tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterAssetListTask, FILTER_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_change_request_list_task_from_config(page: Page):\n expected_goal = 'Create a filter for the list to extract all entries where \"Assignment group\" is \"Hardware\" and \"Assigned to\" is \"Bow Ruggeri\".'\n generic_task_cheat_test(\n FilterChangeRequestListTask,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterHardwareListTask, FILTER_HARDWARE_LIST_CONFIG_PATH, page)\n\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_filter_change_request_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_filter_change_request_list_task_from_config#L247-L254","kind":"function","name":"test_filter_change_request_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":247,"end_line":254,"context_start_line":227,"context_end_line":274,"code":" generic_task_cheat_test(CreateUserTask, CREATE_USER_CONFIG_PATH, page)\n\n\n# knowledge tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_knowledge_base_from_config(page: Page):\n expected_goal = \"Answer the following question using the knowledge base: \\\"Can you provide the direct contact number for the CEO? Answer with the full phone number starting with the '+' sign.\\\"\"\n generic_task_cheat_test(KnowledgeBaseSearchTask, KB_CONFIG_PATH, page)\n\n\n# list tasks\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterAssetListTask, FILTER_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_change_request_list_task_from_config(page: Page):\n expected_goal = 'Create a filter for the list to extract all entries where \"Assignment group\" is \"Hardware\" and \"Assigned to\" is \"Bow Ruggeri\".'\n generic_task_cheat_test(\n FilterChangeRequestListTask,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterHardwareListTask, FILTER_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterIncidentListTask, FILTER_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n FilterServiceCatalogItemListTask,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_filter_hardware_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_filter_hardware_list_task_from_config#L259-L260","kind":"function","name":"test_filter_hardware_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":259,"end_line":260,"context_start_line":239,"context_end_line":280,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterAssetListTask, FILTER_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_change_request_list_task_from_config(page: Page):\n expected_goal = 'Create a filter for the list to extract all entries where \"Assignment group\" is \"Hardware\" and \"Assigned to\" is \"Bow Ruggeri\".'\n generic_task_cheat_test(\n FilterChangeRequestListTask,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterHardwareListTask, FILTER_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterIncidentListTask, FILTER_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n FilterServiceCatalogItemListTask,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n page,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_filter_incident_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_filter_incident_list_task_from_config#L265-L266","kind":"function","name":"test_filter_incident_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":265,"end_line":266,"context_start_line":245,"context_end_line":286,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_change_request_list_task_from_config(page: Page):\n expected_goal = 'Create a filter for the list to extract all entries where \"Assignment group\" is \"Hardware\" and \"Assigned to\" is \"Bow Ruggeri\".'\n generic_task_cheat_test(\n FilterChangeRequestListTask,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterHardwareListTask, FILTER_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterIncidentListTask, FILTER_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n FilterServiceCatalogItemListTask,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n page,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_user_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterUserListTask, FILTER_USER_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_filter_service_catalog_item_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_filter_service_catalog_item_list_task_from_config#L271-L276","kind":"function","name":"test_filter_service_catalog_item_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":271,"end_line":276,"context_start_line":251,"context_end_line":296,"code":" FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n page,\n expected_goal=expected_goal,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterHardwareListTask, FILTER_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterIncidentListTask, FILTER_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n FilterServiceCatalogItemListTask,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n page,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_user_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterUserListTask, FILTER_USER_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(SortAssetListTask, SORT_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_change_request_list_task_from_config(page: Page):\n generic_task_cheat_test(SortChangeRequestListTask, SORT_CHANGE_REQUEST_LIST_CONFIG_PATH, page)\n\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_filter_user_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_filter_user_list_task_from_config#L281-L282","kind":"function","name":"test_filter_user_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":281,"end_line":282,"context_start_line":261,"context_end_line":302,"code":"\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterIncidentListTask, FILTER_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n FilterServiceCatalogItemListTask,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n page,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_user_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterUserListTask, FILTER_USER_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(SortAssetListTask, SORT_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_change_request_list_task_from_config(page: Page):\n generic_task_cheat_test(SortChangeRequestListTask, SORT_CHANGE_REQUEST_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(SortHardwareListTask, SORT_HARDWARE_LIST_CONFIG_PATH, page)\n\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_sort_asset_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_sort_asset_list_task_from_config#L287-L288","kind":"function","name":"test_sort_asset_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":287,"end_line":288,"context_start_line":267,"context_end_line":308,"code":"\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n FilterServiceCatalogItemListTask,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n page,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_user_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterUserListTask, FILTER_USER_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(SortAssetListTask, SORT_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_change_request_list_task_from_config(page: Page):\n generic_task_cheat_test(SortChangeRequestListTask, SORT_CHANGE_REQUEST_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(SortHardwareListTask, SORT_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(SortIncidentListTask, SORT_INCIDENT_LIST_CONFIG_PATH, page)\n\n","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_sort_change_request_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_sort_change_request_list_task_from_config#L293-L294","kind":"function","name":"test_sort_change_request_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":293,"end_line":294,"context_start_line":273,"context_end_line":314,"code":" FilterServiceCatalogItemListTask,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n page,\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_user_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterUserListTask, FILTER_USER_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(SortAssetListTask, SORT_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_change_request_list_task_from_config(page: Page):\n generic_task_cheat_test(SortChangeRequestListTask, SORT_CHANGE_REQUEST_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(SortHardwareListTask, SORT_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(SortIncidentListTask, SORT_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n SortServiceCatalogItemListTask, SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH, page\n )","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_sort_hardware_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_sort_hardware_list_task_from_config#L299-L300","kind":"function","name":"test_sort_hardware_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":299,"end_line":300,"context_start_line":279,"context_end_line":320,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_filter_user_list_task_from_config(page: Page):\n generic_task_cheat_test(FilterUserListTask, FILTER_USER_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(SortAssetListTask, SORT_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_change_request_list_task_from_config(page: Page):\n generic_task_cheat_test(SortChangeRequestListTask, SORT_CHANGE_REQUEST_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(SortHardwareListTask, SORT_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(SortIncidentListTask, SORT_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n SortServiceCatalogItemListTask, SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_user_list_task_from_config(page: Page):\n expected_goal = 'Sort the \"users\" list by the following fields:\\n - Active (descending)'","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_sort_incident_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_sort_incident_list_task_from_config#L305-L306","kind":"function","name":"test_sort_incident_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":305,"end_line":306,"context_start_line":285,"context_end_line":323,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_asset_list_task_from_config(page: Page):\n generic_task_cheat_test(SortAssetListTask, SORT_ASSET_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_change_request_list_task_from_config(page: Page):\n generic_task_cheat_test(SortChangeRequestListTask, SORT_CHANGE_REQUEST_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(SortHardwareListTask, SORT_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(SortIncidentListTask, SORT_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n SortServiceCatalogItemListTask, SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_user_list_task_from_config(page: Page):\n expected_goal = 'Sort the \"users\" list by the following fields:\\n - Active (descending)'\n generic_task_cheat_test(\n SortUserListTask, SORT_USER_LIST_CONFIG_PATH, page, expected_goal=expected_goal\n )","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_sort_service_catalog_item_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_sort_service_catalog_item_list_task_from_config#L311-L314","kind":"function","name":"test_sort_service_catalog_item_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":311,"end_line":314,"context_start_line":291,"context_end_line":323,"code":"@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_change_request_list_task_from_config(page: Page):\n generic_task_cheat_test(SortChangeRequestListTask, SORT_CHANGE_REQUEST_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(SortHardwareListTask, SORT_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(SortIncidentListTask, SORT_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n SortServiceCatalogItemListTask, SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_user_list_task_from_config(page: Page):\n expected_goal = 'Sort the \"users\" list by the following fields:\\n - Active (descending)'\n generic_task_cheat_test(\n SortUserListTask, SORT_USER_LIST_CONFIG_PATH, page, expected_goal=expected_goal\n )","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_task_from_config.test_sort_user_list_task_from_config","uri":"program://WorkArena/function/tests.test_task_from_config.test_sort_user_list_task_from_config#L319-L323","kind":"function","name":"test_sort_user_list_task_from_config","path":"tests/test_task_from_config.py","language":"python","start_line":319,"end_line":323,"context_start_line":299,"context_end_line":323,"code":"def test_sort_hardware_list_task_from_config(page: Page):\n generic_task_cheat_test(SortHardwareListTask, SORT_HARDWARE_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_incident_list_task_from_config(page: Page):\n generic_task_cheat_test(SortIncidentListTask, SORT_INCIDENT_LIST_CONFIG_PATH, page)\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_service_catalog_item_list_task_from_config(page: Page):\n generic_task_cheat_test(\n SortServiceCatalogItemListTask, SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH, page\n )\n\n\n@pytest.mark.slow\n@pytest.mark.skip(reason=\"Tests are too slow\")\ndef test_sort_user_list_task_from_config(page: Page):\n expected_goal = 'Sort the \"users\" list by the following fields:\\n - Active (descending)'\n generic_task_cheat_test(\n SortUserListTask, SORT_USER_LIST_CONFIG_PATH, page, expected_goal=expected_goal\n )","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_filter_list_task","uri":"program://WorkArena/module/tests.test_filter_list_task#L1-L81","kind":"module","name":"tests.test_filter_list_task","path":"tests/test_filter_list_task.py","language":"python","start_line":1,"end_line":81,"context_start_line":1,"context_end_line":81,"code":"import pytest\nfrom playwright.sync_api import Page\nfrom browsergym.workarena.tasks.list import FilterIncidentListTask\n\n\n# These are all the same ways to express the same filter query (empty string) in ServiceNow.\n@pytest.mark.parametrize(\n \"query\",\n [\n \"assigned_toEMPTYSTRING^short_descriptionISEMPTY^description=This is a beautiful incident\",\n \"assigned_toISEMPTY^short_descriptionEMPTYSTRING^description=This is a beautiful incident^\",\n \"assigned_toISEMPTY^short_descriptionISEMPTY^description=This is a beautiful incident\",\n \"assigned_toEMPTYSTRING^short_descriptionEMPTYSTRING^description=This is a beautiful incident^\",\n \"assigned_to=^short_description=^description=This is a beautiful incident\",\n ],\n)\n@pytest.mark.slow\ndef test_validate_filter_list_task(page: Page, query):\n fixed_config = {\n \"filter_columns\": [\n \"short_description\",\n \"assigned_to\",\n \"description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n \"\",\n \"\",\n \"This is a beautiful incident\",\n ],\n }\n task = FilterIncidentListTask(seed=1, fixed_config=fixed_config)\n _, _ = task.setup(page=page)\n query = query.replace(\"^\", r\"%5E\").replace(\"=\", r\"%3D\")\n task.page.goto(\n task.instance.snow_url\n + rf\"/now/nav/ui/classic/params/target/incident_list.do?sysparm_query={query}\"\n )\n reward, done, _, info = task.validate(page, [])\n task.teardown()\n assert done is True and reward == 1.0 and \"Correct filter\" in info[\"message\"]\n\n\n# Different ways in which the filter is wrong\n@pytest.mark.parametrize(\n \"query, expected_message\",\n [\n (\"\", \"There are no filters yet\"),\n (\"assignment_groupEMPTYSTRING\", \"Incorrect number of filter conditions\"),\n (\n \"assigned_toEMPTYSTRING^short_description!=Description\",\n \"Unexpected operator in filter condition\",\n ),\n (\"assigned_toEMPTYSTRING^short_description=Description\", \"Incorrect filter columns\"),\n (\"assigned_toISEMPTY^description=My Description\", \"Incorrect filter values\"),\n ],\n)\n@pytest.mark.slow\ndef test_invalid_filter_list_task(page: Page, query, expected_message):\n fixed_config = {\n \"filter_columns\": [\n \"assigned_to\",\n \"description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n \"\",\n \"Description\",\n ],\n }\n task = FilterIncidentListTask(seed=1, fixed_config=fixed_config)\n _, _ = task.setup(page=page)\n query = query.replace(\"^\", r\"%5E\").replace(\"=\", r\"%3D\")\n task.page.goto(\n task.instance.snow_url\n + f\"/now/nav/ui/classic/params/target/incident_list.do?sysparm_query={query}\"\n )\n reward, done, _, info = task.validate(page, [])\n task.teardown()\n print(info[\"message\"])\n assert done is False and reward == 0.0 and expected_message in info[\"message\"]","source_hash":"dbcf38e837ea0255a0b0626633ee622a4a912d7a310f437fb1dc44c984cb6102","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_filter_list_task.test_validate_filter_list_task","uri":"program://WorkArena/function/tests.test_filter_list_task.test_validate_filter_list_task#L18-L41","kind":"function","name":"test_validate_filter_list_task","path":"tests/test_filter_list_task.py","language":"python","start_line":18,"end_line":41,"context_start_line":1,"context_end_line":61,"code":"import pytest\nfrom playwright.sync_api import Page\nfrom browsergym.workarena.tasks.list import FilterIncidentListTask\n\n\n# These are all the same ways to express the same filter query (empty string) in ServiceNow.\n@pytest.mark.parametrize(\n \"query\",\n [\n \"assigned_toEMPTYSTRING^short_descriptionISEMPTY^description=This is a beautiful incident\",\n \"assigned_toISEMPTY^short_descriptionEMPTYSTRING^description=This is a beautiful incident^\",\n \"assigned_toISEMPTY^short_descriptionISEMPTY^description=This is a beautiful incident\",\n \"assigned_toEMPTYSTRING^short_descriptionEMPTYSTRING^description=This is a beautiful incident^\",\n \"assigned_to=^short_description=^description=This is a beautiful incident\",\n ],\n)\n@pytest.mark.slow\ndef test_validate_filter_list_task(page: Page, query):\n fixed_config = {\n \"filter_columns\": [\n \"short_description\",\n \"assigned_to\",\n \"description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n \"\",\n \"\",\n \"This is a beautiful incident\",\n ],\n }\n task = FilterIncidentListTask(seed=1, fixed_config=fixed_config)\n _, _ = task.setup(page=page)\n query = query.replace(\"^\", r\"%5E\").replace(\"=\", r\"%3D\")\n task.page.goto(\n task.instance.snow_url\n + rf\"/now/nav/ui/classic/params/target/incident_list.do?sysparm_query={query}\"\n )\n reward, done, _, info = task.validate(page, [])\n task.teardown()\n assert done is True and reward == 1.0 and \"Correct filter\" in info[\"message\"]\n\n\n# Different ways in which the filter is wrong\n@pytest.mark.parametrize(\n \"query, expected_message\",\n [\n (\"\", \"There are no filters yet\"),\n (\"assignment_groupEMPTYSTRING\", \"Incorrect number of filter conditions\"),\n (\n \"assigned_toEMPTYSTRING^short_description!=Description\",\n \"Unexpected operator in filter condition\",\n ),\n (\"assigned_toEMPTYSTRING^short_description=Description\", \"Incorrect filter columns\"),\n (\"assigned_toISEMPTY^description=My Description\", \"Incorrect filter values\"),\n ],\n)\n@pytest.mark.slow\ndef test_invalid_filter_list_task(page: Page, query, expected_message):\n fixed_config = {\n \"filter_columns\": [","source_hash":"dbcf38e837ea0255a0b0626633ee622a4a912d7a310f437fb1dc44c984cb6102","truncated":false} {"repo_id":"WorkArena","entity_id":"py:tests.test_filter_list_task.test_invalid_filter_list_task","uri":"program://WorkArena/function/tests.test_filter_list_task.test_invalid_filter_list_task#L59-L81","kind":"function","name":"test_invalid_filter_list_task","path":"tests/test_filter_list_task.py","language":"python","start_line":59,"end_line":81,"context_start_line":39,"context_end_line":81,"code":" reward, done, _, info = task.validate(page, [])\n task.teardown()\n assert done is True and reward == 1.0 and \"Correct filter\" in info[\"message\"]\n\n\n# Different ways in which the filter is wrong\n@pytest.mark.parametrize(\n \"query, expected_message\",\n [\n (\"\", \"There are no filters yet\"),\n (\"assignment_groupEMPTYSTRING\", \"Incorrect number of filter conditions\"),\n (\n \"assigned_toEMPTYSTRING^short_description!=Description\",\n \"Unexpected operator in filter condition\",\n ),\n (\"assigned_toEMPTYSTRING^short_description=Description\", \"Incorrect filter columns\"),\n (\"assigned_toISEMPTY^description=My Description\", \"Incorrect filter values\"),\n ],\n)\n@pytest.mark.slow\ndef test_invalid_filter_list_task(page: Page, query, expected_message):\n fixed_config = {\n \"filter_columns\": [\n \"assigned_to\",\n \"description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n \"\",\n \"Description\",\n ],\n }\n task = FilterIncidentListTask(seed=1, fixed_config=fixed_config)\n _, _ = task.setup(page=page)\n query = query.replace(\"^\", r\"%5E\").replace(\"=\", r\"%3D\")\n task.page.goto(\n task.instance.snow_url\n + f\"/now/nav/ui/classic/params/target/incident_list.do?sysparm_query={query}\"\n )\n reward, done, _, info = task.validate(page, [])\n task.teardown()\n print(info[\"message\"])\n assert done is False and reward == 0.0 and expected_message in info[\"message\"]","source_hash":"dbcf38e837ea0255a0b0626633ee622a4a912d7a310f437fb1dc44c984cb6102","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.wa_action_traces","uri":"program://WorkArena/module/src.wa_action_traces#L1-L131","kind":"module","name":"src.wa_action_traces","path":"src/wa_action_traces.py","language":"python","start_line":1,"end_line":131,"context_start_line":1,"context_end_line":131,"code":"\"\"\"\nA demonstration of how action traces (with observations) can be extracted\nfor WorkArena tasks without modifying the task code.\n\nAuthor: Alexandre Drouin (alexandre.drouin@servicenow.com)\n\nNotes:\n- This approach relies on monkey patching the playwright actions to log the actions and observations.\n It has not been tested for parallel execution. It might work with multiprocessing, but it will for\n sure not work with multithreading.\n\n\"\"\"\n\nimport importlib\nimport logging\nimport os\nimport pickle\nimport playwright.sync_api as playwright_sync\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS\nfrom collections import defaultdict\nfrom tenacity import retry, stop_after_attempt, wait_fixed\nfrom time import time\n\n\nN_PER_TASK = 10\n\n\ndef monkey_patch_playwright(observation_callback, trace_storage):\n \"\"\"\n A function that overrides the default playwright actions to log the actions and observations.\n\n Parameters:\n ------------\n observation_callback: callable\n A function that returns the observation of the environment.\n trace_storage: list\n A list to store the trace of the actions and observations.\n These will be appended in-place.\n\n \"\"\"\n\n def wrapper(func, interface):\n def wrapped(*args, **kwargs):\n # Get the observation\n obs = observation_callback()\n\n # Get the BID of the element on which we are acting.\n if interface.__name__ == \"Locator\":\n # Get the locator\n locator = args[0]\n # Get the BID\n bid = locator.element_handle().evaluate('(el) => el.getAttribute(\"bid\")')\n elif interface.__name__ == \"Keyboard\":\n # Get the BID of the element\n bid = \"keyboard\"\n else:\n # Get the BID of the element\n bid = args[0].evaluate('(el) => el.getAttribute(\"bid\")')\n\n logging.info(f\"Action: {func.__name__} BID: {bid} -- Args: {args[1:]} {kwargs}\")\n trace_storage.append(\n {\n \"obs\": obs,\n \"action\": func.__name__,\n \"args\": args[1:],\n \"kwargs\": kwargs,\n \"bid\": bid,\n \"time\": time(),\n }\n )\n\n # Resume action\n return func(*args, **kwargs)\n\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))\ndef extract_trace(task_cls, headless=True):\n \"\"\"\n Extracts the trace of actions and observations for a given task.\n\n Parameters:\n ------------\n task_cls: class\n The class of the task to extract the trace from.\n\n \"\"\"\n # Instantiate a new environment\n env = BrowserEnv(task_entrypoint=task_cls, headless=headless, slow_mo=1000)\n\n # Setup customized tracing\n trace = []\n monkey_patch_playwright(observation_callback=env._get_obs, trace_storage=trace)\n\n env.reset()\n env.task.cheat(env.page, env.chat.messages)\n env.close()\n\n return trace\n\n\nif __name__ == \"__main__\":\n os.makedirs(\"trace_profiling\", exist_ok=True)\n\n task_traces = defaultdict(list)\n for task in ALL_WORKARENA_TASKS:\n print(\"Task:\", task)\n for i in range(N_PER_TASK):\n print(f\"Extracting trace {i+1}/{N_PER_TASK}\")\n trace = extract_trace(task, headless=True)\n task_traces[task].append(trace)\n\n pickle.dump(task_traces, open(\"trace_profiling/task_traces.pkl\", \"wb\"))","source_hash":"1054d7dd5f1d54040e1490e1641067ca454306ef20f9ff184b20114b1c52e378","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.wa_action_traces.monkey_patch_playwright","uri":"program://WorkArena/function/src.wa_action_traces.monkey_patch_playwright#L30-L92","kind":"function","name":"monkey_patch_playwright","path":"src/wa_action_traces.py","language":"python","start_line":30,"end_line":92,"context_start_line":10,"context_end_line":112,"code":" sure not work with multithreading.\n\n\"\"\"\n\nimport importlib\nimport logging\nimport os\nimport pickle\nimport playwright.sync_api as playwright_sync\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS\nfrom collections import defaultdict\nfrom tenacity import retry, stop_after_attempt, wait_fixed\nfrom time import time\n\n\nN_PER_TASK = 10\n\n\ndef monkey_patch_playwright(observation_callback, trace_storage):\n \"\"\"\n A function that overrides the default playwright actions to log the actions and observations.\n\n Parameters:\n ------------\n observation_callback: callable\n A function that returns the observation of the environment.\n trace_storage: list\n A list to store the trace of the actions and observations.\n These will be appended in-place.\n\n \"\"\"\n\n def wrapper(func, interface):\n def wrapped(*args, **kwargs):\n # Get the observation\n obs = observation_callback()\n\n # Get the BID of the element on which we are acting.\n if interface.__name__ == \"Locator\":\n # Get the locator\n locator = args[0]\n # Get the BID\n bid = locator.element_handle().evaluate('(el) => el.getAttribute(\"bid\")')\n elif interface.__name__ == \"Keyboard\":\n # Get the BID of the element\n bid = \"keyboard\"\n else:\n # Get the BID of the element\n bid = args[0].evaluate('(el) => el.getAttribute(\"bid\")')\n\n logging.info(f\"Action: {func.__name__} BID: {bid} -- Args: {args[1:]} {kwargs}\")\n trace_storage.append(\n {\n \"obs\": obs,\n \"action\": func.__name__,\n \"args\": args[1:],\n \"kwargs\": kwargs,\n \"bid\": bid,\n \"time\": time(),\n }\n )\n\n # Resume action\n return func(*args, **kwargs)\n\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))\ndef extract_trace(task_cls, headless=True):\n \"\"\"\n Extracts the trace of actions and observations for a given task.\n\n Parameters:\n ------------\n task_cls: class\n The class of the task to extract the trace from.\n\n \"\"\"\n # Instantiate a new environment\n env = BrowserEnv(task_entrypoint=task_cls, headless=headless, slow_mo=1000)\n\n # Setup customized tracing\n trace = []\n monkey_patch_playwright(observation_callback=env._get_obs, trace_storage=trace)\n","source_hash":"1054d7dd5f1d54040e1490e1641067ca454306ef20f9ff184b20114b1c52e378","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.wa_action_traces.extract_trace","uri":"program://WorkArena/function/src.wa_action_traces.extract_trace#L96-L117","kind":"function","name":"extract_trace","path":"src/wa_action_traces.py","language":"python","start_line":96,"end_line":117,"context_start_line":76,"context_end_line":131,"code":"\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))\ndef extract_trace(task_cls, headless=True):\n \"\"\"\n Extracts the trace of actions and observations for a given task.\n\n Parameters:\n ------------\n task_cls: class\n The class of the task to extract the trace from.\n\n \"\"\"\n # Instantiate a new environment\n env = BrowserEnv(task_entrypoint=task_cls, headless=headless, slow_mo=1000)\n\n # Setup customized tracing\n trace = []\n monkey_patch_playwright(observation_callback=env._get_obs, trace_storage=trace)\n\n env.reset()\n env.task.cheat(env.page, env.chat.messages)\n env.close()\n\n return trace\n\n\nif __name__ == \"__main__\":\n os.makedirs(\"trace_profiling\", exist_ok=True)\n\n task_traces = defaultdict(list)\n for task in ALL_WORKARENA_TASKS:\n print(\"Task:\", task)\n for i in range(N_PER_TASK):\n print(f\"Extracting trace {i+1}/{N_PER_TASK}\")\n trace = extract_trace(task, headless=True)\n task_traces[task].append(trace)\n\n pickle.dump(task_traces, open(\"trace_profiling/task_traces.pkl\", \"wb\"))","source_hash":"1054d7dd5f1d54040e1490e1641067ca454306ef20f9ff184b20114b1c52e378","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.wa_action_traces.wrapper","uri":"program://WorkArena/function/src.wa_action_traces.wrapper#L44-L77","kind":"function","name":"wrapper","path":"src/wa_action_traces.py","language":"python","start_line":44,"end_line":77,"context_start_line":24,"context_end_line":97,"code":"from time import time\n\n\nN_PER_TASK = 10\n\n\ndef monkey_patch_playwright(observation_callback, trace_storage):\n \"\"\"\n A function that overrides the default playwright actions to log the actions and observations.\n\n Parameters:\n ------------\n observation_callback: callable\n A function that returns the observation of the environment.\n trace_storage: list\n A list to store the trace of the actions and observations.\n These will be appended in-place.\n\n \"\"\"\n\n def wrapper(func, interface):\n def wrapped(*args, **kwargs):\n # Get the observation\n obs = observation_callback()\n\n # Get the BID of the element on which we are acting.\n if interface.__name__ == \"Locator\":\n # Get the locator\n locator = args[0]\n # Get the BID\n bid = locator.element_handle().evaluate('(el) => el.getAttribute(\"bid\")')\n elif interface.__name__ == \"Keyboard\":\n # Get the BID of the element\n bid = \"keyboard\"\n else:\n # Get the BID of the element\n bid = args[0].evaluate('(el) => el.getAttribute(\"bid\")')\n\n logging.info(f\"Action: {func.__name__} BID: {bid} -- Args: {args[1:]} {kwargs}\")\n trace_storage.append(\n {\n \"obs\": obs,\n \"action\": func.__name__,\n \"args\": args[1:],\n \"kwargs\": kwargs,\n \"bid\": bid,\n \"time\": time(),\n }\n )\n\n # Resume action\n return func(*args, **kwargs)\n\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))\ndef extract_trace(task_cls, headless=True):\n \"\"\"","source_hash":"1054d7dd5f1d54040e1490e1641067ca454306ef20f9ff184b20114b1c52e378","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.wa_action_traces.wrapped","uri":"program://WorkArena/function/src.wa_action_traces.wrapped#L45-L75","kind":"function","name":"wrapped","path":"src/wa_action_traces.py","language":"python","start_line":45,"end_line":75,"context_start_line":25,"context_end_line":95,"code":"\n\nN_PER_TASK = 10\n\n\ndef monkey_patch_playwright(observation_callback, trace_storage):\n \"\"\"\n A function that overrides the default playwright actions to log the actions and observations.\n\n Parameters:\n ------------\n observation_callback: callable\n A function that returns the observation of the environment.\n trace_storage: list\n A list to store the trace of the actions and observations.\n These will be appended in-place.\n\n \"\"\"\n\n def wrapper(func, interface):\n def wrapped(*args, **kwargs):\n # Get the observation\n obs = observation_callback()\n\n # Get the BID of the element on which we are acting.\n if interface.__name__ == \"Locator\":\n # Get the locator\n locator = args[0]\n # Get the BID\n bid = locator.element_handle().evaluate('(el) => el.getAttribute(\"bid\")')\n elif interface.__name__ == \"Keyboard\":\n # Get the BID of the element\n bid = \"keyboard\"\n else:\n # Get the BID of the element\n bid = args[0].evaluate('(el) => el.getAttribute(\"bid\")')\n\n logging.info(f\"Action: {func.__name__} BID: {bid} -- Args: {args[1:]} {kwargs}\")\n trace_storage.append(\n {\n \"obs\": obs,\n \"action\": func.__name__,\n \"args\": args[1:],\n \"kwargs\": kwargs,\n \"bid\": bid,\n \"time\": time(),\n }\n )\n\n # Resume action\n return func(*args, **kwargs)\n\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))","source_hash":"1054d7dd5f1d54040e1490e1641067ca454306ef20f9ff184b20114b1c52e378","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.workarena_test","uri":"program://WorkArena/module/src.workarena_test#L1-L37","kind":"module","name":"src.workarena_test","path":"src/workarena_test.py","language":"python","start_line":1,"end_line":37,"context_start_line":1,"context_end_line":37,"code":"from browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import get_all_tasks_agents\n\nAGENT_L2_SAMPLED_SET = get_all_tasks_agents(filter=\"l2\")\n\nAGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS = [sampled_set[0] for sampled_set in AGENT_L2_SAMPLED_SET], [\n sampled_set[1] for sampled_set in AGENT_L2_SAMPLED_SET\n]\nfrom time import sleep\n\nfor task, seed in zip(AGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS):\n print(\"Task:\", task)\n\n # Instantiate a new environment\n env = BrowserEnv(task_entrypoint=task, headless=False, slow_mo=1000)\n env.reset()\n\n # Cheat functions use Playwright to automatically solve the task\n env.chat.add_message(role=\"assistant\", msg=\"On it. Please wait...\")\n\n for i in range(len(env.task)):\n sleep(1)\n env.task.cheat(page=env.page, chat_messages=env.chat.messages, subtask_idx=i)\n sleep(1)\n reward, done, message, info = env.task.validate(\n page=env.page, chat_messages=env.chat.messages\n )\n\n if reward == 1:\n env.chat.add_message(role=\"user\", msg=\"Yes, that works. Thanks!\")\n else:\n env.chat.add_message(\n role=\"user\", msg=f\"No, that doesn't work. {message.get('message', '')}\"\n )\n\n sleep(3)\n env.close()","source_hash":"df01d22c5f230a99b5ac148770824ab29ba8f81799b5091383f31016af20c1aa","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.config","uri":"program://WorkArena/module/src.browsergym.workarena.config#L1-L229","kind":"module","name":"src.browsergym.workarena.config","path":"src/browsergym/workarena/config.py","language":"python","start_line":1,"end_line":229,"context_start_line":1,"context_end_line":229,"code":"from importlib import resources\nfrom json import load as json_load\nfrom os.path import exists\n\nfrom ..workarena import data_files\nfrom ..workarena.tasks import utils\n\n# ServiceNow configuration\nSNOW_DATA_LOOKBACK_MINUTES = 5\nSNOW_BROWSER_TIMEOUT = 30000 # Milliseconds\nSNOW_JS_UTILS_FILEPATH = str(resources.files(utils).joinpath(\"js_utils.js\"))\nSNOW_SUPPORTED_RELEASES = [\"washingtondc\"]\n\n# Path to the Menu navigation task configuration\nALL_MENU_PATH = str(resources.files(data_files).joinpath(\"task_configs/all_menu.json\"))\n\n# Path to the dashboard/report retrieval task configurations\nDASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/dashboard_retrieval_minmax_task.json\")\n)\nDASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/dashboard_retrieval_value_task.json\")\n)\nREPORT_RETRIEVAL_MINMAX_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/report_retrieval_minmax_task.json\")\n)\nREPORT_RETRIEVAL_VALUE_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/report_retrieval_value_task.json\")\n)\n\n# Path to knowledge base task configurations\nKB_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/knowledge_base_configs.json\")\n)\n# Path to the Impersonation task configuration\nIMPERSONATION_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/impersonation_users.json\")\n)\n# Path to the service catalog configs\nORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_developer_laptop_task.json\")\n)\nORDER_IPAD_MINI_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_ipad_mini_task.json\")\n)\nORDER_IPAD_PRO_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_ipad_pro_task.json\")\n)\nORDER_SALES_LAPTOP_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_sales_laptop_task.json\")\n)\nORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_standard_laptop_task.json\")\n)\nORDER_APPLE_WATCH_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_apple_watch_task.json\")\n)\nORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_apple_mac_book_pro15_task.json\")\n)\nORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_development_laptop_pc_task.json\")\n)\nORDER_LOANER_LAPTOP_TASK_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/order_loaner_laptop_task.json\")\n)\n\n# Knowledge base that is included with the benchmark\nKB_NAME = \"General Knowledge\"\nKB_FILEPATH = str(resources.files(data_files).joinpath(\"setup_files/knowledge/knowledge_base.json\"))\nPROTOCOL_KB_NAME = \"Company Protocols\"\nPROTOCOL_KB_FILEPATH = str(\n resources.files(data_files).joinpath(\"setup_files/knowledge/protocols.json\")\n)\n\n# Form tasks\nCREATE_CHANGE_REQUEST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/create_change_request_task.json\")\n)\nCREATE_HARDWARE_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/create_hardware_asset_task.json\")\n)\nCREATE_INCIDENT_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/create_incident_task.json\")\n)\nCREATE_PROBLEM_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/create_problem_task.json\")\n)\nCREATE_USER_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/create_user_task.json\")\n)\n# List tasks\nFILTER_ASSET_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/filter_asset_list_task.json\")\n)\nFILTER_CHANGE_REQUEST_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/filter_change_request_list_task.json\")\n)\nFILTER_HARDWARE_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/filter_hardware_list_task.json\")\n)\nFILTER_INCIDENT_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/filter_incident_list_task.json\")\n)\nFILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/filter_service_catalog_item_list_task.json\")\n)\nFILTER_USER_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/filter_user_list_task.json\")\n)\nSORT_ASSET_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/sort_asset_list_task.json\")\n)\nSORT_CHANGE_REQUEST_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/sort_change_request_list_task.json\")\n)\nSORT_HARDWARE_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/sort_hardware_list_task.json\")\n)\nSORT_INCIDENT_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/sort_incident_list_task.json\")\n)\nSORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/sort_service_catalog_item_list_task.json\")\n)\nSORT_USER_LIST_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/sort_user_list_task.json\")\n)\n\n\n# Custom workflows that are included with the benchmark\nWORKFLOWS = {\n \"kb_publish\": {\n \"name\": \"WorkArena Auto-Publish\",\n \"update_set\": str(\n resources.files(data_files).joinpath(\n \"setup_files/knowledge/kb_autopublish_workflow.xml\"\n )\n ),\n }\n}\n\n\n# Custom UI Themes\nUI_THEMES_UPDATE_SET = {\n \"name\": \"WorkArena UI Themes\",\n \"update_set\": str(\n resources.files(data_files).joinpath(\"setup_files/ui_themes/workarena_themes.xml\")\n ),\n \"variants\": [\n \"Astranova\",\n \"Charlies\",\n \"Great pasta\",\n \"Mighty capital\",\n \"Speedy tires\",\n \"Skyward\",\n \"Turbobots\",\n \"Ultrashoes\",\n \"Vitasphere\",\n \"Workarena\",\n ],\n}\n\n\n# Expected columns for list tasks; used in setup\nEXPECTED_ASSET_LIST_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/lists/expected_asset_list_columns.json\")\n)\nEXPECTED_CHANGE_REQUEST_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\n \"setup_files/lists/expected_change_request_list_columns.json\"\n )\n)\nEXPECTED_EXPENSE_LINE_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\n \"setup_files/lists/expected_expense_line_list_columns.json\"\n )\n)\nEXPECTED_HARDWARE_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/lists/expected_hardware_list_columns.json\")\n)\nEXPECTED_INCIDENT_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/lists/expected_incident_list_columns.json\")\n)\nEXPECTED_PROBLEM_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/lists/expected_problem_list_columns.json\")\n)\nEXPECTED_REQUESTED_ITEMS_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\n \"setup_files/lists/expected_requested_items_list_columns.json\"\n )\n)\nEXPECTED_SERVICE_CATALOG_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\n \"setup_files/lists/expected_service_catalog_list_columns.json\"\n )\n)\nEXPECTED_USER_COLUMNS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/lists/expected_user_list_columns.json\")\n)\n# Expected form fields for form tasks; used in setup\nEXPECTED_ASSET_FORM_FIELDS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/forms/expected_asset_form_fields.json\")\n)\nEXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH = str(\n resources.files(data_files).joinpath(\n \"setup_files/forms/expected_change_request_form_fields.json\"\n )\n)\n\nEXPECTED_HARDWARE_FORM_FIELDS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/forms/expected_hardware_form_fields.json\")\n)\nEXPECTED_INCIDENT_FORM_FIELDS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/forms/expected_incident_form_fields.json\")\n)\nEXPECTED_PROBLEM_FORM_FIELDS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/forms/expected_problem_form_fields.json\")\n)\nEXPECTED_USER_FORM_FIELDS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/forms/expected_user_form_fields.json\")\n)\nEXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH = str(\n resources.files(data_files).joinpath(\"setup_files/forms/expected_request_item_form_fields.json\")\n)\n\n# Report date filter patch flag\nREPORT_PATCH_FLAG = \"WORKARENA_DATE_FILTER_PATCH\"\nREPORT_FILTER_PROPERTY = \"workarena.report.filter.config\"","source_hash":"166c78b25dc1d447b69b67c69e711825fb10d1390257455d2a1359fa0372b515","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.instance","uri":"program://WorkArena/module/src.browsergym.workarena.instance#L1-L149","kind":"module","name":"src.browsergym.workarena.instance","path":"src/browsergym/workarena/instance.py","language":"python","start_line":1,"end_line":149,"context_start_line":1,"context_end_line":149,"code":"import json\nimport os\nimport requests\nimport re\n\nfrom playwright.sync_api import sync_playwright\nfrom typing import Optional\n\nfrom .config import SNOW_BROWSER_TIMEOUT, REPORT_FILTER_PROPERTY\n\n\nclass SNowInstance:\n \"\"\"\n Utility class to access a ServiceNow instance.\n\n \"\"\"\n\n def __init__(\n self,\n snow_url: Optional[str] = None,\n snow_credentials: Optional[tuple[str, str]] = None,\n ) -> None:\n \"\"\"\n Set up a ServiceNow instance API\n\n Parameters:\n -----------\n snow_url: str\n The URL of a SNow instance. If None, will try to get the value from the environment variable SNOW_INSTANCE_URL.\n snow_credentials: (str, str)\n The username and password used to access the SNow instance. If None, will try to get the values from the\n environment variables SNOW_INSTANCE_UNAME and SNOW_INSTANCE_PWD.\n\n \"\"\"\n # try to get these values from environment variables if not provided\n if snow_url is None:\n if \"SNOW_INSTANCE_URL\" in os.environ:\n snow_url = os.environ[\"SNOW_INSTANCE_URL\"]\n else:\n raise ValueError(\n f\"Please provide a ServiceNow instance URL (you can use the environment variable SNOW_INSTANCE_URL)\"\n )\n\n if snow_credentials is None:\n if \"SNOW_INSTANCE_UNAME\" in os.environ and \"SNOW_INSTANCE_PWD\" in os.environ:\n snow_credentials = (\n os.environ[\"SNOW_INSTANCE_UNAME\"],\n os.environ[\"SNOW_INSTANCE_PWD\"],\n )\n else:\n raise ValueError(\n f\"Please provide ServiceNow credentials (you can use the environment variables SNOW_INSTANCE_UNAME and SNOW_INSTANCE_PWD)\"\n )\n\n # remove trailing slashes in the URL, if any\n self.snow_url = snow_url.rstrip(\"/\")\n self.snow_credentials = snow_credentials\n self.check_status()\n\n def check_status(self):\n \"\"\"\n Check the status of the ServiceNow instance. Raises an error if the instance is not ready to be used.\n\n \"\"\"\n self._check_is_reachable()\n self._check_is_hibernating()\n\n def _check_is_hibernating(self):\n \"\"\"\n Test that the ServiceNow instance is not hibernating\n\n \"\"\"\n response = requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n\n # Check if the response contains any indication of the instance being in hibernation\n if \"hibernating\" in response.text.lower():\n raise RuntimeError(\n f\"ServiceNow instance is hibernating. Please navigate to {self.snow_url} wake it up.\"\n )\n\n def _check_is_reachable(self):\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n try:\n requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):\n raise RuntimeError(\n f\"ServiceNow instance at {self.snow_url} is not reachable. Please check the URL.\"\n )\n\n @property\n def release_version(self) -> str:\n \"\"\"\n Get the release of the ServiceNow instance\n\n Returns:\n --------\n dict\n Information about the release of the ServiceNow instance\n\n \"\"\"\n # XXX: Need to include the import here to avoid circular imports\n from .utils import ui_login\n\n keys = [\"build name\", \"build date\", \"build tag\", \"connected to cluster node\"]\n\n # We need to use playwright since the page is loaded dynamically\n # and its source doesn't contain the information we need\n with sync_playwright() as playwright:\n browser = playwright.chromium.launch(headless=True)\n page = browser.new_page()\n ui_login(self, page)\n page.goto(self.snow_url + \"/stats.do\")\n\n # The page contains a big list of information separated by
tags. Extract it.\n release_info = {\n key.strip(): value.strip()\n for x in page.content().lower().split(\"
\")\n if \":\" in x\n for key, value in [x.split(\":\", 1)]\n if key in keys\n }\n browser.close()\n\n return release_info\n\n @property\n def report_filter_config(self) -> dict:\n \"\"\"\n Get the report filter configuration from the ServiceNow instance.\n\n Returns:\n --------\n dict\n The report filter configuration, or an empty dictionary if not found.\n\n \"\"\"\n from .api.system_properties import (\n get_sys_property,\n ) # Import here to avoid circular import issues\n\n try:\n config = get_sys_property(self, REPORT_FILTER_PROPERTY)\n config = json.loads(config)\n return config\n except Exception:\n return None","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.instance.SNowInstance","uri":"program://WorkArena/class/src.browsergym.workarena.instance.SNowInstance#L12-L149","kind":"class","name":"SNowInstance","path":"src/browsergym/workarena/instance.py","language":"python","start_line":12,"end_line":149,"context_start_line":1,"context_end_line":149,"code":"import json\nimport os\nimport requests\nimport re\n\nfrom playwright.sync_api import sync_playwright\nfrom typing import Optional\n\nfrom .config import SNOW_BROWSER_TIMEOUT, REPORT_FILTER_PROPERTY\n\n\nclass SNowInstance:\n \"\"\"\n Utility class to access a ServiceNow instance.\n\n \"\"\"\n\n def __init__(\n self,\n snow_url: Optional[str] = None,\n snow_credentials: Optional[tuple[str, str]] = None,\n ) -> None:\n \"\"\"\n Set up a ServiceNow instance API\n\n Parameters:\n -----------\n snow_url: str\n The URL of a SNow instance. If None, will try to get the value from the environment variable SNOW_INSTANCE_URL.\n snow_credentials: (str, str)\n The username and password used to access the SNow instance. If None, will try to get the values from the\n environment variables SNOW_INSTANCE_UNAME and SNOW_INSTANCE_PWD.\n\n \"\"\"\n # try to get these values from environment variables if not provided\n if snow_url is None:\n if \"SNOW_INSTANCE_URL\" in os.environ:\n snow_url = os.environ[\"SNOW_INSTANCE_URL\"]\n else:\n raise ValueError(\n f\"Please provide a ServiceNow instance URL (you can use the environment variable SNOW_INSTANCE_URL)\"\n )\n\n if snow_credentials is None:\n if \"SNOW_INSTANCE_UNAME\" in os.environ and \"SNOW_INSTANCE_PWD\" in os.environ:\n snow_credentials = (\n os.environ[\"SNOW_INSTANCE_UNAME\"],\n os.environ[\"SNOW_INSTANCE_PWD\"],\n )\n else:\n raise ValueError(\n f\"Please provide ServiceNow credentials (you can use the environment variables SNOW_INSTANCE_UNAME and SNOW_INSTANCE_PWD)\"\n )\n\n # remove trailing slashes in the URL, if any\n self.snow_url = snow_url.rstrip(\"/\")\n self.snow_credentials = snow_credentials\n self.check_status()\n\n def check_status(self):\n \"\"\"\n Check the status of the ServiceNow instance. Raises an error if the instance is not ready to be used.\n\n \"\"\"\n self._check_is_reachable()\n self._check_is_hibernating()\n\n def _check_is_hibernating(self):\n \"\"\"\n Test that the ServiceNow instance is not hibernating\n\n \"\"\"\n response = requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n\n # Check if the response contains any indication of the instance being in hibernation\n if \"hibernating\" in response.text.lower():\n raise RuntimeError(\n f\"ServiceNow instance is hibernating. Please navigate to {self.snow_url} wake it up.\"\n )\n\n def _check_is_reachable(self):\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n try:\n requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):\n raise RuntimeError(\n f\"ServiceNow instance at {self.snow_url} is not reachable. Please check the URL.\"\n )\n\n @property\n def release_version(self) -> str:\n \"\"\"\n Get the release of the ServiceNow instance\n\n Returns:\n --------\n dict\n Information about the release of the ServiceNow instance\n\n \"\"\"\n # XXX: Need to include the import here to avoid circular imports\n from .utils import ui_login\n\n keys = [\"build name\", \"build date\", \"build tag\", \"connected to cluster node\"]\n\n # We need to use playwright since the page is loaded dynamically\n # and its source doesn't contain the information we need\n with sync_playwright() as playwright:\n browser = playwright.chromium.launch(headless=True)\n page = browser.new_page()\n ui_login(self, page)\n page.goto(self.snow_url + \"/stats.do\")\n\n # The page contains a big list of information separated by
tags. Extract it.\n release_info = {\n key.strip(): value.strip()\n for x in page.content().lower().split(\"
\")\n if \":\" in x\n for key, value in [x.split(\":\", 1)]\n if key in keys\n }\n browser.close()\n\n return release_info\n\n @property\n def report_filter_config(self) -> dict:\n \"\"\"\n Get the report filter configuration from the ServiceNow instance.\n\n Returns:\n --------\n dict\n The report filter configuration, or an empty dictionary if not found.\n\n \"\"\"\n from .api.system_properties import (\n get_sys_property,\n ) # Import here to avoid circular import issues\n\n try:\n config = get_sys_property(self, REPORT_FILTER_PROPERTY)\n config = json.loads(config)\n return config\n except Exception:\n return None","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.instance.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.instance.__init__#L18-L58","kind":"function","name":"__init__","path":"src/browsergym/workarena/instance.py","language":"python","start_line":18,"end_line":58,"context_start_line":1,"context_end_line":78,"code":"import json\nimport os\nimport requests\nimport re\n\nfrom playwright.sync_api import sync_playwright\nfrom typing import Optional\n\nfrom .config import SNOW_BROWSER_TIMEOUT, REPORT_FILTER_PROPERTY\n\n\nclass SNowInstance:\n \"\"\"\n Utility class to access a ServiceNow instance.\n\n \"\"\"\n\n def __init__(\n self,\n snow_url: Optional[str] = None,\n snow_credentials: Optional[tuple[str, str]] = None,\n ) -> None:\n \"\"\"\n Set up a ServiceNow instance API\n\n Parameters:\n -----------\n snow_url: str\n The URL of a SNow instance. If None, will try to get the value from the environment variable SNOW_INSTANCE_URL.\n snow_credentials: (str, str)\n The username and password used to access the SNow instance. If None, will try to get the values from the\n environment variables SNOW_INSTANCE_UNAME and SNOW_INSTANCE_PWD.\n\n \"\"\"\n # try to get these values from environment variables if not provided\n if snow_url is None:\n if \"SNOW_INSTANCE_URL\" in os.environ:\n snow_url = os.environ[\"SNOW_INSTANCE_URL\"]\n else:\n raise ValueError(\n f\"Please provide a ServiceNow instance URL (you can use the environment variable SNOW_INSTANCE_URL)\"\n )\n\n if snow_credentials is None:\n if \"SNOW_INSTANCE_UNAME\" in os.environ and \"SNOW_INSTANCE_PWD\" in os.environ:\n snow_credentials = (\n os.environ[\"SNOW_INSTANCE_UNAME\"],\n os.environ[\"SNOW_INSTANCE_PWD\"],\n )\n else:\n raise ValueError(\n f\"Please provide ServiceNow credentials (you can use the environment variables SNOW_INSTANCE_UNAME and SNOW_INSTANCE_PWD)\"\n )\n\n # remove trailing slashes in the URL, if any\n self.snow_url = snow_url.rstrip(\"/\")\n self.snow_credentials = snow_credentials\n self.check_status()\n\n def check_status(self):\n \"\"\"\n Check the status of the ServiceNow instance. Raises an error if the instance is not ready to be used.\n\n \"\"\"\n self._check_is_reachable()\n self._check_is_hibernating()\n\n def _check_is_hibernating(self):\n \"\"\"\n Test that the ServiceNow instance is not hibernating\n\n \"\"\"\n response = requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n\n # Check if the response contains any indication of the instance being in hibernation\n if \"hibernating\" in response.text.lower():\n raise RuntimeError(\n f\"ServiceNow instance is hibernating. Please navigate to {self.snow_url} wake it up.\"","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.instance.check_status","uri":"program://WorkArena/function/src.browsergym.workarena.instance.check_status#L60-L66","kind":"function","name":"check_status","path":"src/browsergym/workarena/instance.py","language":"python","start_line":60,"end_line":66,"context_start_line":40,"context_end_line":86,"code":" raise ValueError(\n f\"Please provide a ServiceNow instance URL (you can use the environment variable SNOW_INSTANCE_URL)\"\n )\n\n if snow_credentials is None:\n if \"SNOW_INSTANCE_UNAME\" in os.environ and \"SNOW_INSTANCE_PWD\" in os.environ:\n snow_credentials = (\n os.environ[\"SNOW_INSTANCE_UNAME\"],\n os.environ[\"SNOW_INSTANCE_PWD\"],\n )\n else:\n raise ValueError(\n f\"Please provide ServiceNow credentials (you can use the environment variables SNOW_INSTANCE_UNAME and SNOW_INSTANCE_PWD)\"\n )\n\n # remove trailing slashes in the URL, if any\n self.snow_url = snow_url.rstrip(\"/\")\n self.snow_credentials = snow_credentials\n self.check_status()\n\n def check_status(self):\n \"\"\"\n Check the status of the ServiceNow instance. Raises an error if the instance is not ready to be used.\n\n \"\"\"\n self._check_is_reachable()\n self._check_is_hibernating()\n\n def _check_is_hibernating(self):\n \"\"\"\n Test that the ServiceNow instance is not hibernating\n\n \"\"\"\n response = requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n\n # Check if the response contains any indication of the instance being in hibernation\n if \"hibernating\" in response.text.lower():\n raise RuntimeError(\n f\"ServiceNow instance is hibernating. Please navigate to {self.snow_url} wake it up.\"\n )\n\n def _check_is_reachable(self):\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n try:","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.instance._check_is_hibernating","uri":"program://WorkArena/function/src.browsergym.workarena.instance._check_is_hibernating#L68-L79","kind":"function","name":"_check_is_hibernating","path":"src/browsergym/workarena/instance.py","language":"python","start_line":68,"end_line":79,"context_start_line":48,"context_end_line":99,"code":" os.environ[\"SNOW_INSTANCE_PWD\"],\n )\n else:\n raise ValueError(\n f\"Please provide ServiceNow credentials (you can use the environment variables SNOW_INSTANCE_UNAME and SNOW_INSTANCE_PWD)\"\n )\n\n # remove trailing slashes in the URL, if any\n self.snow_url = snow_url.rstrip(\"/\")\n self.snow_credentials = snow_credentials\n self.check_status()\n\n def check_status(self):\n \"\"\"\n Check the status of the ServiceNow instance. Raises an error if the instance is not ready to be used.\n\n \"\"\"\n self._check_is_reachable()\n self._check_is_hibernating()\n\n def _check_is_hibernating(self):\n \"\"\"\n Test that the ServiceNow instance is not hibernating\n\n \"\"\"\n response = requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n\n # Check if the response contains any indication of the instance being in hibernation\n if \"hibernating\" in response.text.lower():\n raise RuntimeError(\n f\"ServiceNow instance is hibernating. Please navigate to {self.snow_url} wake it up.\"\n )\n\n def _check_is_reachable(self):\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n try:\n requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):\n raise RuntimeError(\n f\"ServiceNow instance at {self.snow_url} is not reachable. Please check the URL.\"\n )\n\n @property\n def release_version(self) -> str:\n \"\"\"\n Get the release of the ServiceNow instance\n\n Returns:\n --------","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.instance._check_is_reachable","uri":"program://WorkArena/function/src.browsergym.workarena.instance._check_is_reachable#L81-L91","kind":"function","name":"_check_is_reachable","path":"src/browsergym/workarena/instance.py","language":"python","start_line":81,"end_line":91,"context_start_line":61,"context_end_line":111,"code":" \"\"\"\n Check the status of the ServiceNow instance. Raises an error if the instance is not ready to be used.\n\n \"\"\"\n self._check_is_reachable()\n self._check_is_hibernating()\n\n def _check_is_hibernating(self):\n \"\"\"\n Test that the ServiceNow instance is not hibernating\n\n \"\"\"\n response = requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n\n # Check if the response contains any indication of the instance being in hibernation\n if \"hibernating\" in response.text.lower():\n raise RuntimeError(\n f\"ServiceNow instance is hibernating. Please navigate to {self.snow_url} wake it up.\"\n )\n\n def _check_is_reachable(self):\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n try:\n requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):\n raise RuntimeError(\n f\"ServiceNow instance at {self.snow_url} is not reachable. Please check the URL.\"\n )\n\n @property\n def release_version(self) -> str:\n \"\"\"\n Get the release of the ServiceNow instance\n\n Returns:\n --------\n dict\n Information about the release of the ServiceNow instance\n\n \"\"\"\n # XXX: Need to include the import here to avoid circular imports\n from .utils import ui_login\n\n keys = [\"build name\", \"build date\", \"build tag\", \"connected to cluster node\"]\n\n # We need to use playwright since the page is loaded dynamically\n # and its source doesn't contain the information we need\n with sync_playwright() as playwright:","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.instance.release_version","uri":"program://WorkArena/function/src.browsergym.workarena.instance.release_version#L94-L127","kind":"function","name":"release_version","path":"src/browsergym/workarena/instance.py","language":"python","start_line":94,"end_line":127,"context_start_line":74,"context_end_line":147,"code":"\n # Check if the response contains any indication of the instance being in hibernation\n if \"hibernating\" in response.text.lower():\n raise RuntimeError(\n f\"ServiceNow instance is hibernating. Please navigate to {self.snow_url} wake it up.\"\n )\n\n def _check_is_reachable(self):\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"\n try:\n requests.get(self.snow_url, timeout=SNOW_BROWSER_TIMEOUT)\n except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):\n raise RuntimeError(\n f\"ServiceNow instance at {self.snow_url} is not reachable. Please check the URL.\"\n )\n\n @property\n def release_version(self) -> str:\n \"\"\"\n Get the release of the ServiceNow instance\n\n Returns:\n --------\n dict\n Information about the release of the ServiceNow instance\n\n \"\"\"\n # XXX: Need to include the import here to avoid circular imports\n from .utils import ui_login\n\n keys = [\"build name\", \"build date\", \"build tag\", \"connected to cluster node\"]\n\n # We need to use playwright since the page is loaded dynamically\n # and its source doesn't contain the information we need\n with sync_playwright() as playwright:\n browser = playwright.chromium.launch(headless=True)\n page = browser.new_page()\n ui_login(self, page)\n page.goto(self.snow_url + \"/stats.do\")\n\n # The page contains a big list of information separated by
tags. Extract it.\n release_info = {\n key.strip(): value.strip()\n for x in page.content().lower().split(\"
\")\n if \":\" in x\n for key, value in [x.split(\":\", 1)]\n if key in keys\n }\n browser.close()\n\n return release_info\n\n @property\n def report_filter_config(self) -> dict:\n \"\"\"\n Get the report filter configuration from the ServiceNow instance.\n\n Returns:\n --------\n dict\n The report filter configuration, or an empty dictionary if not found.\n\n \"\"\"\n from .api.system_properties import (\n get_sys_property,\n ) # Import here to avoid circular import issues\n\n try:\n config = get_sys_property(self, REPORT_FILTER_PROPERTY)\n config = json.loads(config)\n return config","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.instance.report_filter_config","uri":"program://WorkArena/function/src.browsergym.workarena.instance.report_filter_config#L130-L149","kind":"function","name":"report_filter_config","path":"src/browsergym/workarena/instance.py","language":"python","start_line":130,"end_line":149,"context_start_line":110,"context_end_line":149,"code":" # and its source doesn't contain the information we need\n with sync_playwright() as playwright:\n browser = playwright.chromium.launch(headless=True)\n page = browser.new_page()\n ui_login(self, page)\n page.goto(self.snow_url + \"/stats.do\")\n\n # The page contains a big list of information separated by
tags. Extract it.\n release_info = {\n key.strip(): value.strip()\n for x in page.content().lower().split(\"
\")\n if \":\" in x\n for key, value in [x.split(\":\", 1)]\n if key in keys\n }\n browser.close()\n\n return release_info\n\n @property\n def report_filter_config(self) -> dict:\n \"\"\"\n Get the report filter configuration from the ServiceNow instance.\n\n Returns:\n --------\n dict\n The report filter configuration, or an empty dictionary if not found.\n\n \"\"\"\n from .api.system_properties import (\n get_sys_property,\n ) # Import here to avoid circular import issues\n\n try:\n config = get_sys_property(self, REPORT_FILTER_PROPERTY)\n config = json.loads(config)\n return config\n except Exception:\n return None","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install","uri":"program://WorkArena/module/src.browsergym.workarena.install#L1-L1132","kind":"module","name":"src.browsergym.workarena.install","path":"src/browsergym/workarena/install.py","language":"python","start_line":1,"end_line":1132,"context_start_line":1,"context_end_line":1132,"code":"import html\nimport json\nimport logging\nimport re\nimport tenacity\n\nfrom datetime import datetime\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom requests import HTTPError\nfrom time import sleep\n\nfrom .api.system_properties import get_sys_property, set_sys_property\nfrom .api.ui_themes import get_workarena_theme_variants\nfrom .api.user import create_user\nfrom .api.utils import table_api_call, table_column_info\nfrom .config import (\n # for knowledge base setup\n KB_FILEPATH,\n KB_NAME,\n PROTOCOL_KB_FILEPATH,\n PROTOCOL_KB_NAME,\n # For list setup\n EXPECTED_ASSET_LIST_COLUMNS_PATH,\n EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n EXPECTED_HARDWARE_COLUMNS_PATH,\n EXPECTED_INCIDENT_COLUMNS_PATH,\n EXPECTED_PROBLEM_COLUMNS_PATH,\n EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,\n EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n EXPECTED_USER_COLUMNS_PATH,\n # for form setup\n EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH,\n EXPECTED_HARDWARE_FORM_FIELDS_PATH,\n EXPECTED_INCIDENT_FORM_FIELDS_PATH,\n EXPECTED_PROBLEM_FORM_FIELDS_PATH,\n EXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH,\n EXPECTED_USER_FORM_FIELDS_PATH,\n # Patch flag for reports\n REPORT_PATCH_FLAG,\n REPORT_FILTER_PROPERTY,\n # Supported ServiceNow releases\n SNOW_SUPPORTED_RELEASES,\n # For workflows setup\n WORKFLOWS,\n # For UI themes setup\n UI_THEMES_UPDATE_SET,\n)\nfrom .api.user import set_user_preference\nfrom .instance import SNowInstance\nfrom .utils import url_login\n\n\ndef _is_dev_portal_instance() -> bool:\n \"\"\"\n Check if the instance is a ServiceNow Developer Portal instance.\n\n Returns:\n --------\n bool: True if the instance is a developer portal instance, False otherwise.\n\n \"\"\"\n instance = SNowInstance()\n # Check if the instance url has the for devXXXXXX.service-now.com format (where X is a digit)\n if re.match(r\"^https?://dev\\d{6}\\.service-now\\.com\", instance.snow_url):\n logging.info(\"Detected a developer portal instance...\")\n return True\n logging.info(\"Detected an internal instance...\")\n return False\n\n\ndef _install_update_set(path: str, name: str):\n \"\"\"\n Install a ServiceNow update set\n\n Parameters:\n -----------\n path: str\n The path to the update set file.\n name: str\n The name of the update set as it should appear in the UI.\n\n Notes: requires interacting with the UI, so we use playwright instead of the API\n\n \"\"\"\n with sync_playwright() as playwright:\n instance = SNowInstance()\n browser = playwright.chromium.launch(headless=True, slow_mo=1000)\n page = browser.new_page()\n url_login(instance, page)\n\n # Navigate to the update set upload page and upload all update sets\n logging.info(\"Uploading update set...\")\n page.goto(\n instance.snow_url\n + \"/now/nav/ui/classic/params/target/upload.do%3Fsysparm_referring_url%3Dsys_remote_update_set_list.do%253Fsysparm_fixed_query%253Dsys_class_name%253Dsys_remote_update_set%26sysparm_target%3Dsys_remote_update_set\"\n )\n iframe = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n with page.expect_file_chooser() as fc_info:\n iframe.locator(\"#attachFile\").click()\n file_chooser = fc_info.value\n file_chooser.set_files(path)\n iframe.locator(\"input:text('Upload')\").click()\n sleep(5)\n\n # Apply all update sets\n logging.info(\"Applying update set...\")\n # ... retrieve all update sets that are ready to be applied\n update_set = table_api_call(\n instance=instance,\n table=\"sys_remote_update_set\",\n params={\n \"sysparm_query\": f\"name={name}^state=loaded\",\n },\n )[\"result\"][0]\n # ... apply them\n logging.info(f\"... {update_set['name']}\")\n page.goto(instance.snow_url + \"/sys_remote_update_set.do?sys_id=\" + update_set[\"sys_id\"])\n page.locator(\"button:has-text('Preview Update Set')\").first.click()\n page.wait_for_selector(\"text=Succeeded\")\n # click escape to close popup\n page.keyboard.press(\"Escape\")\n page.locator(\"button:has-text('Commit Update Set')\").first.click()\n page.wait_for_selector(\"text=Succeeded\")\n\n browser.close()\n\n\ndef check_knowledge_base(\n instance: SNowInstance, kb_name: str, kb_data: dict, disable_commenting: bool = True\n):\n \"\"\"\n Verify the integrity of the knowledge base in the instance.\n Args:\n -----\n instance: SNowInstance\n The ServiceNow instance to check the knowledge base in\n kb_name: str\n The name of the knowledge base to check\n kb_data: dict\n The knowledge base data to check\n disable_commenting: bool\n Whether to disable commenting on the knowledge base\n\n \"\"\"\n\n def _extract_text(article):\n article = html.unescape(article) # replace special chars\n article = re.sub(r\"<[^>]+>\", \"\", article) # remove html tags\n article = \"\".join([c for c in article if c.isalnum()]) # extract alphanum only\n return article\n\n # Check that a knowledge base with the correct name exists\n kb = table_api_call(\n instance=instance,\n table=\"kb_knowledge_base\",\n params={\"sysparm_query\": f\"title={kb_name}\"},\n )[\"result\"]\n\n # The KB exists\n if len(kb) == 1:\n requires_install = False\n requires_delete = False\n\n # Check that the KB has the correct settings\n if disable_commenting and (\n kb[0][\"disable_commenting\"] != \"true\"\n or kb[0][\"disable_mark_as_helpful\"] != \"true\"\n or kb[0][\"disable_rating\"] != \"true\"\n or kb[0][\"disable_suggesting\"] != \"true\"\n or kb[0][\"disable_category_editing\"] != \"true\"\n ):\n requires_install = True\n requires_delete = True\n\n # Get all articles in the KB\n articles = table_api_call(\n instance=instance,\n table=\"kb_knowledge\",\n params={\"sysparm_query\": f\"kb_knowledge_base={kb[0]['sys_id']}\"},\n )[\"result\"]\n if len(articles) != len(kb_data):\n requires_install = True\n requires_delete = True\n else:\n for a in articles:\n try:\n # Parse the article title (by convention, articles are named \"Article \" and 1-indexed)\n idx = int(a[\"short_description\"].split(\" \")[1]) - 1\n except:\n # Invalid article title, the KB is corrupt and must be reinstalled\n requires_install = True\n requires_delete = True\n break\n\n # Check that the articles match (preprocess the text because ServiceNow adds some HTML tags)\n if _extract_text(kb_data[idx][\"article\"]) != _extract_text(a[\"text\"]):\n requires_install = True\n requires_delete = True\n break\n\n # There are more than one KB with the expected name (corrupt install)\n elif len(kb) > 1:\n raise Exception(\n \"Multiple knowledge bases with the same name found. The instance is in an unexpected state.\"\n )\n\n # The KB doesn't exist and must be installed\n else:\n requires_install = True\n requires_delete = False\n\n return (\n kb[0][\"sys_id\"] if len(kb) == 1 else None,\n requires_install,\n requires_delete,\n )\n\n\ndef delete_knowledge_base(instance: SNowInstance, kb_id: str, kb_name: str):\n \"\"\"\n Delete a knowledge base from the instance.\n\n Notes: will delete all content, but will only archive the KB since ServiceNow prevents deletion.\n\n \"\"\"\n articles = table_api_call(\n instance=instance,\n table=\"kb_knowledge\",\n params={\"sysparm_query\": f\"kb_knowledge_base={kb_id}\"},\n )[\"result\"]\n\n # Delete the knowledge base\n logging.info(f\"Knowledge base {kb_name}: deleting knowledge base content\")\n for a_ in articles:\n table_api_call(instance=instance, table=f\"kb_knowledge/{a_['sys_id']}\", method=\"DELETE\")\n\n # Rename the KB and set active=False (ServiceNow prevents deletion)\n logging.info(f\"Knowledge base {kb_name}: archiving knowledge base\")\n table_api_call(\n instance=instance,\n table=f\"kb_knowledge_base/{kb_id}\",\n method=\"PATCH\",\n json={\"title\": f\"archived_{kb_id}\", \"active\": \"false\"},\n )\n\n\ndef create_knowledge_base(\n instance: SNowInstance,\n kb_name: str,\n kb_data: dict,\n disable_commenting: bool = True,\n add_article_name: bool = False,\n):\n \"\"\"\n Create knowledge base and upload all articles.\n Params:\n -------\n instance: SNowInstance\n The ServiceNow instance to install the knowledge base in\n kb_name: str\n The name of the knowledge base that will be created\n kb_data: dict\n The knowledge base data to upload\n disable_commenting: bool\n Whether to disable commenting on the knowledge base\n add_article_name: bool\n Whether to add the article name to the article text. If False, the articles will be named \"Article \"\n Otherwise, we will extract the article title from the 'item' field in the JSON file.\n\n \"\"\"\n logging.info(f\"Installing knowledge base {kb_name}...\")\n\n # Create the knowledge base\n logging.info(f\"... creating knowledge base {kb_name}\")\n disable_commenting = \"true\" if disable_commenting else \"false\"\n\n kb = table_api_call(\n instance=instance,\n table=\"kb_knowledge_base\",\n method=\"POST\",\n data=json.dumps(\n {\n \"title\": kb_name,\n \"disable_commenting\": disable_commenting,\n \"disable_mark_as_helpful\": disable_commenting,\n \"disable_rating\": disable_commenting,\n \"disable_suggesting\": disable_commenting,\n \"disable_category_editing\": disable_commenting,\n }\n ),\n )[\"result\"]\n kb_id = kb[\"sys_id\"]\n\n for i, kb_entry in enumerate(kb_data):\n logging.info(f\"... Knowledge Base {kb_name} uploading article {i + 1}/{len(kb_data)}\")\n article = kb_entry[\"article\"]\n if add_article_name:\n short_description = kb_entry[\"item\"]\n else:\n short_description = f\"Article {i + 1}\"\n # Plant a new article in kb_knowledge table\n table_api_call(\n instance,\n table=\"kb_knowledge\",\n method=\"POST\",\n data=json.dumps(\n {\n \"short_description\": short_description,\n \"sys_class_name\": \"kb_knowledge\",\n \"text\": article,\n \"article_type\": \"text\",\n \"kb_knowledge_base\": kb_id,\n }\n ),\n )\n\n\ndef setup_knowledge_bases():\n \"\"\"\n Verify that the knowledge base is installed correctly in the instance.\n If it is not, it will be installed.\n\n \"\"\"\n # Get the ServiceNow instance\n instance = SNowInstance()\n # Mapping between knowledge base name and filepath + whether or not to disable comments + whether or not to add article name\n knowledge_bases = {\n KB_NAME: (KB_FILEPATH, True, False),\n PROTOCOL_KB_NAME: (PROTOCOL_KB_FILEPATH, True, True),\n }\n for kb_name, (kb_filepath, disable_commenting, add_article_name) in knowledge_bases.items():\n # Load the knowledge base\n with open(kb_filepath, \"r\") as f:\n kb_data = json.load(f)\n\n kb_id, requires_install, requires_delete = check_knowledge_base(\n instance=instance,\n kb_name=kb_name,\n kb_data=kb_data,\n disable_commenting=disable_commenting,\n )\n\n # Delete knowledge base if needed\n if requires_delete:\n logging.info(f\"Knowledge base {kb_name} is corrupt. Reinstalling...\")\n delete_knowledge_base(instance=instance, kb_id=kb_id, kb_name=kb_name)\n\n # Install the knowledge base\n if requires_install:\n create_knowledge_base(\n instance=instance,\n kb_name=kb_name,\n kb_data=kb_data,\n disable_commenting=disable_commenting,\n add_article_name=add_article_name,\n )\n\n # Confirm that the knowledge base was installed correctly\n kb_id, requires_install, requires_delete = check_knowledge_base(\n instance=instance, kb_name=kb_name, kb_data=kb_data\n )\n assert (\n not requires_install or requires_delete\n ), f\"Knowledge base {kb_name} installation failed.\"\n logging.info(f\"Knowledge base {kb_name} installation succeeded.\")\n\n if not requires_delete and not requires_install:\n logging.info(f\"Knowledge base {kb_name} is already installed.\")\n\n\ndef setup_workflows():\n \"\"\"\n Verify that workflows are correctly installed.\n If not, install them.\n\n \"\"\"\n if not check_workflows_installed():\n install_workflows()\n assert check_workflows_installed(), \"Workflow installation failed.\"\n logging.info(\"Workflow installation succeeded.\")\n\n\ndef check_workflows_installed():\n \"\"\"\n Check if the workflows are installed in the instance.\n\n Will return False if workflows need to be (re)installed. True if all is good.\n\n \"\"\"\n expected_workflow_names = [x[\"name\"] for x in WORKFLOWS.values()]\n workflows = table_api_call(\n instance=SNowInstance(),\n table=\"wf_workflow\",\n params={\n \"sysparm_query\": \"nameIN\" + \",\".join(expected_workflow_names),\n },\n )[\"result\"]\n\n # Verify that all workflows are installed\n if len(workflows) != len(WORKFLOWS):\n logging.info(\n f\"Missing workflows: {set(expected_workflow_names) - set([w['name'] for w in workflows])}.\"\n )\n return False\n\n logging.info(\"All workflows are installed properly.\")\n return True\n\n\ndef install_workflows():\n \"\"\"\n Install workflows using ServiceNow update sets.\n\n Notes: requires interacting with the UI, so we use playwright instead of the API\n\n \"\"\"\n logging.info(\"Installing workflow update sets...\")\n for wf in WORKFLOWS.values():\n _install_update_set(path=wf[\"update_set\"], name=wf[\"name\"])\n\n\ndef display_all_expected_columns(\n instance: SNowInstance, list_name: str, expected_columns: list[str]\n):\n \"\"\"\n Display all expected columns in a given list view.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to configure.\n list_name: str\n The name of the list to display columns for.\n expected_columns: list[str]\n The list of columns to display.\n\n \"\"\"\n logging.info(f\"... Setting up default view for list {list_name}\")\n\n # Get the default view (for all users)\n logging.info(f\"...... Fetching default view for list {list_name}...\")\n default_view = table_api_call(\n instance=instance,\n table=\"sys_ui_list\",\n params={\n \"sysparm_query\": f\"name={list_name}^view.title=Default View^sys_userISEMPTY^parentISEMPTY\",\n \"sysparm_fields\": \"sys_id,name,view.title,sys_user\",\n },\n )[\"result\"]\n\n # If there is more than one, delete all but the one with the most recently updated\n if len(default_view) > 1:\n logging.info(\n f\"......... Multiple default views found for list {list_name}. Deleting all but the most recent one.\"\n )\n default_view = sorted(default_view, key=lambda x: x[\"sys_updated_on\"], reverse=True)\n # Delete all but the first one\n for view in default_view[1:]:\n logging.info(f\"............ Deleting view {view['sys_id']}\")\n table_api_call(\n instance=instance, table=f\"sys_ui_list/{view['sys_id']}\", method=\"DELETE\"\n )\n default_view = default_view[0]\n\n # Find all columns in the view (get their sysid)\n logging.info(f\"...... Fetching existing columns for default view of list {list_name}...\")\n columns = table_api_call(\n instance=instance,\n table=\"sys_ui_list_element\",\n params={\"sysparm_query\": f\"list_id={default_view['sys_id']}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"]\n\n # Delete all columns in the default view\n logging.info(f\"...... Deleting existing columns for default view of list {list_name}...\")\n for column in columns:\n table_api_call(\n instance=instance, table=f\"sys_ui_list_element/{column['sys_id']}\", method=\"DELETE\"\n )\n\n # Add all expected columns to the default view\n logging.info(f\"...... Adding expected columns to default view of list {list_name}...\")\n for i, column in enumerate(expected_columns):\n logging.info(f\"......... {column}\")\n table_api_call(\n instance=instance,\n table=\"sys_ui_list_element\",\n method=\"POST\",\n data=json.dumps({\"list_id\": default_view[\"sys_id\"], \"element\": column, \"position\": i}),\n )\n logging.info(f\"...... Done.\")\n\n\ndef check_all_columns_displayed(\n instance: SNowInstance, url: str, expected_columns: list[str]\n) -> bool:\n \"\"\"\n Get the visible columns and checks that all expected columns are displayed.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to configure.\n url: str\n The URL of the list view to check.\n expected_columns: list[str]\n The set of columns to check for.\n\n Returns:\n --------\n bool: True if all expected columns are displayed, False otherwise.\n\n \"\"\"\n with sync_playwright() as playwright:\n browser = playwright.chromium.launch(headless=True, slow_mo=1000)\n page = browser.new_page()\n url_login(instance, page)\n page.goto(instance.snow_url + url)\n iframe = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n # Wait for gsft_main.GlideList2 to be available\n page.wait_for_function(\"typeof gsft_main.GlideList2 !== 'undefined'\")\n lst = iframe.locator(\"table.data_list_table\")\n\n # Validate the number of lists on the page\n lst = lst.nth(0)\n js_selector = f\"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')\"\n visible_columns = set(page.evaluate(f\"{js_selector}.fields\").split(\",\"))\n\n # check if expected columns is contained in the visible columns\n if not set(expected_columns).issubset(visible_columns):\n logging.info(\n f\"Error setting up list at {url} \\n Expected {expected_columns} columns, but got {visible_columns}.\"\n )\n return False\n logging.info(f\"All columns properly displayed for {url}.\")\n return True\n\n\ndef setup_list_columns():\n \"\"\"\n Setup the list view to display the expected number of columns.\n\n \"\"\"\n logging.info(\"Setting up visible list columns...\")\n list_mappings = {\n \"alm_asset\": {\n \"url\": \"/now/nav/ui/classic/params/target/alm_asset_list.do\",\n \"expected_columns_path\": EXPECTED_ASSET_LIST_COLUMNS_PATH,\n },\n \"alm_hardware\": {\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n \"expected_columns_path\": EXPECTED_HARDWARE_COLUMNS_PATH,\n },\n \"change_request\": {\n \"url\": \"/now/nav/ui/classic/params/target/change_request_list.do\",\n \"expected_columns_path\": EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n },\n \"incident\": {\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n \"expected_columns_path\": EXPECTED_INCIDENT_COLUMNS_PATH,\n },\n \"problem\": {\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n \"expected_columns_path\": EXPECTED_PROBL\n# ... truncated ...","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install._is_dev_portal_instance","uri":"program://WorkArena/function/src.browsergym.workarena.install._is_dev_portal_instance#L55-L70","kind":"function","name":"_is_dev_portal_instance","path":"src/browsergym/workarena/install.py","language":"python","start_line":55,"end_line":70,"context_start_line":35,"context_end_line":90,"code":" EXPECTED_HARDWARE_FORM_FIELDS_PATH,\n EXPECTED_INCIDENT_FORM_FIELDS_PATH,\n EXPECTED_PROBLEM_FORM_FIELDS_PATH,\n EXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH,\n EXPECTED_USER_FORM_FIELDS_PATH,\n # Patch flag for reports\n REPORT_PATCH_FLAG,\n REPORT_FILTER_PROPERTY,\n # Supported ServiceNow releases\n SNOW_SUPPORTED_RELEASES,\n # For workflows setup\n WORKFLOWS,\n # For UI themes setup\n UI_THEMES_UPDATE_SET,\n)\nfrom .api.user import set_user_preference\nfrom .instance import SNowInstance\nfrom .utils import url_login\n\n\ndef _is_dev_portal_instance() -> bool:\n \"\"\"\n Check if the instance is a ServiceNow Developer Portal instance.\n\n Returns:\n --------\n bool: True if the instance is a developer portal instance, False otherwise.\n\n \"\"\"\n instance = SNowInstance()\n # Check if the instance url has the for devXXXXXX.service-now.com format (where X is a digit)\n if re.match(r\"^https?://dev\\d{6}\\.service-now\\.com\", instance.snow_url):\n logging.info(\"Detected a developer portal instance...\")\n return True\n logging.info(\"Detected an internal instance...\")\n return False\n\n\ndef _install_update_set(path: str, name: str):\n \"\"\"\n Install a ServiceNow update set\n\n Parameters:\n -----------\n path: str\n The path to the update set file.\n name: str\n The name of the update set as it should appear in the UI.\n\n Notes: requires interacting with the UI, so we use playwright instead of the API\n\n \"\"\"\n with sync_playwright() as playwright:\n instance = SNowInstance()\n browser = playwright.chromium.launch(headless=True, slow_mo=1000)\n page = browser.new_page()","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install._install_update_set","uri":"program://WorkArena/function/src.browsergym.workarena.install._install_update_set#L73-L127","kind":"function","name":"_install_update_set","path":"src/browsergym/workarena/install.py","language":"python","start_line":73,"end_line":127,"context_start_line":53,"context_end_line":147,"code":"\n\ndef _is_dev_portal_instance() -> bool:\n \"\"\"\n Check if the instance is a ServiceNow Developer Portal instance.\n\n Returns:\n --------\n bool: True if the instance is a developer portal instance, False otherwise.\n\n \"\"\"\n instance = SNowInstance()\n # Check if the instance url has the for devXXXXXX.service-now.com format (where X is a digit)\n if re.match(r\"^https?://dev\\d{6}\\.service-now\\.com\", instance.snow_url):\n logging.info(\"Detected a developer portal instance...\")\n return True\n logging.info(\"Detected an internal instance...\")\n return False\n\n\ndef _install_update_set(path: str, name: str):\n \"\"\"\n Install a ServiceNow update set\n\n Parameters:\n -----------\n path: str\n The path to the update set file.\n name: str\n The name of the update set as it should appear in the UI.\n\n Notes: requires interacting with the UI, so we use playwright instead of the API\n\n \"\"\"\n with sync_playwright() as playwright:\n instance = SNowInstance()\n browser = playwright.chromium.launch(headless=True, slow_mo=1000)\n page = browser.new_page()\n url_login(instance, page)\n\n # Navigate to the update set upload page and upload all update sets\n logging.info(\"Uploading update set...\")\n page.goto(\n instance.snow_url\n + \"/now/nav/ui/classic/params/target/upload.do%3Fsysparm_referring_url%3Dsys_remote_update_set_list.do%253Fsysparm_fixed_query%253Dsys_class_name%253Dsys_remote_update_set%26sysparm_target%3Dsys_remote_update_set\"\n )\n iframe = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n with page.expect_file_chooser() as fc_info:\n iframe.locator(\"#attachFile\").click()\n file_chooser = fc_info.value\n file_chooser.set_files(path)\n iframe.locator(\"input:text('Upload')\").click()\n sleep(5)\n\n # Apply all update sets\n logging.info(\"Applying update set...\")\n # ... retrieve all update sets that are ready to be applied\n update_set = table_api_call(\n instance=instance,\n table=\"sys_remote_update_set\",\n params={\n \"sysparm_query\": f\"name={name}^state=loaded\",\n },\n )[\"result\"][0]\n # ... apply them\n logging.info(f\"... {update_set['name']}\")\n page.goto(instance.snow_url + \"/sys_remote_update_set.do?sys_id=\" + update_set[\"sys_id\"])\n page.locator(\"button:has-text('Preview Update Set')\").first.click()\n page.wait_for_selector(\"text=Succeeded\")\n # click escape to close popup\n page.keyboard.press(\"Escape\")\n page.locator(\"button:has-text('Commit Update Set')\").first.click()\n page.wait_for_selector(\"text=Succeeded\")\n\n browser.close()\n\n\ndef check_knowledge_base(\n instance: SNowInstance, kb_name: str, kb_data: dict, disable_commenting: bool = True\n):\n \"\"\"\n Verify the integrity of the knowledge base in the instance.\n Args:\n -----\n instance: SNowInstance\n The ServiceNow instance to check the knowledge base in\n kb_name: str\n The name of the knowledge base to check\n kb_data: dict\n The knowledge base data to check\n disable_commenting: bool\n Whether to disable commenting on the knowledge base\n\n \"\"\"\n","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.check_knowledge_base","uri":"program://WorkArena/function/src.browsergym.workarena.install.check_knowledge_base#L130-L218","kind":"function","name":"check_knowledge_base","path":"src/browsergym/workarena/install.py","language":"python","start_line":130,"end_line":218,"context_start_line":110,"context_end_line":238,"code":" update_set = table_api_call(\n instance=instance,\n table=\"sys_remote_update_set\",\n params={\n \"sysparm_query\": f\"name={name}^state=loaded\",\n },\n )[\"result\"][0]\n # ... apply them\n logging.info(f\"... {update_set['name']}\")\n page.goto(instance.snow_url + \"/sys_remote_update_set.do?sys_id=\" + update_set[\"sys_id\"])\n page.locator(\"button:has-text('Preview Update Set')\").first.click()\n page.wait_for_selector(\"text=Succeeded\")\n # click escape to close popup\n page.keyboard.press(\"Escape\")\n page.locator(\"button:has-text('Commit Update Set')\").first.click()\n page.wait_for_selector(\"text=Succeeded\")\n\n browser.close()\n\n\ndef check_knowledge_base(\n instance: SNowInstance, kb_name: str, kb_data: dict, disable_commenting: bool = True\n):\n \"\"\"\n Verify the integrity of the knowledge base in the instance.\n Args:\n -----\n instance: SNowInstance\n The ServiceNow instance to check the knowledge base in\n kb_name: str\n The name of the knowledge base to check\n kb_data: dict\n The knowledge base data to check\n disable_commenting: bool\n Whether to disable commenting on the knowledge base\n\n \"\"\"\n\n def _extract_text(article):\n article = html.unescape(article) # replace special chars\n article = re.sub(r\"<[^>]+>\", \"\", article) # remove html tags\n article = \"\".join([c for c in article if c.isalnum()]) # extract alphanum only\n return article\n\n # Check that a knowledge base with the correct name exists\n kb = table_api_call(\n instance=instance,\n table=\"kb_knowledge_base\",\n params={\"sysparm_query\": f\"title={kb_name}\"},\n )[\"result\"]\n\n # The KB exists\n if len(kb) == 1:\n requires_install = False\n requires_delete = False\n\n # Check that the KB has the correct settings\n if disable_commenting and (\n kb[0][\"disable_commenting\"] != \"true\"\n or kb[0][\"disable_mark_as_helpful\"] != \"true\"\n or kb[0][\"disable_rating\"] != \"true\"\n or kb[0][\"disable_suggesting\"] != \"true\"\n or kb[0][\"disable_category_editing\"] != \"true\"\n ):\n requires_install = True\n requires_delete = True\n\n # Get all articles in the KB\n articles = table_api_call(\n instance=instance,\n table=\"kb_knowledge\",\n params={\"sysparm_query\": f\"kb_knowledge_base={kb[0]['sys_id']}\"},\n )[\"result\"]\n if len(articles) != len(kb_data):\n requires_install = True\n requires_delete = True\n else:\n for a in articles:\n try:\n # Parse the article title (by convention, articles are named \"Article \" and 1-indexed)\n idx = int(a[\"short_description\"].split(\" \")[1]) - 1\n except:\n # Invalid article title, the KB is corrupt and must be reinstalled\n requires_install = True\n requires_delete = True\n break\n\n # Check that the articles match (preprocess the text because ServiceNow adds some HTML tags)\n if _extract_text(kb_data[idx][\"article\"]) != _extract_text(a[\"text\"]):\n requires_install = True\n requires_delete = True\n break\n\n # There are more than one KB with the expected name (corrupt install)\n elif len(kb) > 1:\n raise Exception(\n \"Multiple knowledge bases with the same name found. The instance is in an unexpected state.\"\n )\n\n # The KB doesn't exist and must be installed\n else:\n requires_install = True\n requires_delete = False\n\n return (\n kb[0][\"sys_id\"] if len(kb) == 1 else None,\n requires_install,\n requires_delete,\n )\n\n\ndef delete_knowledge_base(instance: SNowInstance, kb_id: str, kb_name: str):\n \"\"\"\n Delete a knowledge base from the instance.\n\n Notes: will delete all content, but will only archive the KB since ServiceNow prevents deletion.\n\n \"\"\"\n articles = table_api_call(\n instance=instance,\n table=\"kb_knowledge\",\n params={\"sysparm_query\": f\"kb_knowledge_base={kb_id}\"},\n )[\"result\"]\n\n # Delete the knowledge base\n logging.info(f\"Knowledge base {kb_name}: deleting knowledge base content\")\n for a_ in articles:\n table_api_call(instance=instance, table=f\"kb_knowledge/{a_['sys_id']}\", method=\"DELETE\")\n","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.delete_knowledge_base","uri":"program://WorkArena/function/src.browsergym.workarena.install.delete_knowledge_base#L221-L246","kind":"function","name":"delete_knowledge_base","path":"src/browsergym/workarena/install.py","language":"python","start_line":221,"end_line":246,"context_start_line":201,"context_end_line":266,"code":" break\n\n # There are more than one KB with the expected name (corrupt install)\n elif len(kb) > 1:\n raise Exception(\n \"Multiple knowledge bases with the same name found. The instance is in an unexpected state.\"\n )\n\n # The KB doesn't exist and must be installed\n else:\n requires_install = True\n requires_delete = False\n\n return (\n kb[0][\"sys_id\"] if len(kb) == 1 else None,\n requires_install,\n requires_delete,\n )\n\n\ndef delete_knowledge_base(instance: SNowInstance, kb_id: str, kb_name: str):\n \"\"\"\n Delete a knowledge base from the instance.\n\n Notes: will delete all content, but will only archive the KB since ServiceNow prevents deletion.\n\n \"\"\"\n articles = table_api_call(\n instance=instance,\n table=\"kb_knowledge\",\n params={\"sysparm_query\": f\"kb_knowledge_base={kb_id}\"},\n )[\"result\"]\n\n # Delete the knowledge base\n logging.info(f\"Knowledge base {kb_name}: deleting knowledge base content\")\n for a_ in articles:\n table_api_call(instance=instance, table=f\"kb_knowledge/{a_['sys_id']}\", method=\"DELETE\")\n\n # Rename the KB and set active=False (ServiceNow prevents deletion)\n logging.info(f\"Knowledge base {kb_name}: archiving knowledge base\")\n table_api_call(\n instance=instance,\n table=f\"kb_knowledge_base/{kb_id}\",\n method=\"PATCH\",\n json={\"title\": f\"archived_{kb_id}\", \"active\": \"false\"},\n )\n\n\ndef create_knowledge_base(\n instance: SNowInstance,\n kb_name: str,\n kb_data: dict,\n disable_commenting: bool = True,\n add_article_name: bool = False,\n):\n \"\"\"\n Create knowledge base and upload all articles.\n Params:\n -------\n instance: SNowInstance\n The ServiceNow instance to install the knowledge base in\n kb_name: str\n The name of the knowledge base that will be created\n kb_data: dict\n The knowledge base data to upload\n disable_commenting: bool","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.create_knowledge_base","uri":"program://WorkArena/function/src.browsergym.workarena.install.create_knowledge_base#L249-L317","kind":"function","name":"create_knowledge_base","path":"src/browsergym/workarena/install.py","language":"python","start_line":249,"end_line":317,"context_start_line":229,"context_end_line":337,"code":" instance=instance,\n table=\"kb_knowledge\",\n params={\"sysparm_query\": f\"kb_knowledge_base={kb_id}\"},\n )[\"result\"]\n\n # Delete the knowledge base\n logging.info(f\"Knowledge base {kb_name}: deleting knowledge base content\")\n for a_ in articles:\n table_api_call(instance=instance, table=f\"kb_knowledge/{a_['sys_id']}\", method=\"DELETE\")\n\n # Rename the KB and set active=False (ServiceNow prevents deletion)\n logging.info(f\"Knowledge base {kb_name}: archiving knowledge base\")\n table_api_call(\n instance=instance,\n table=f\"kb_knowledge_base/{kb_id}\",\n method=\"PATCH\",\n json={\"title\": f\"archived_{kb_id}\", \"active\": \"false\"},\n )\n\n\ndef create_knowledge_base(\n instance: SNowInstance,\n kb_name: str,\n kb_data: dict,\n disable_commenting: bool = True,\n add_article_name: bool = False,\n):\n \"\"\"\n Create knowledge base and upload all articles.\n Params:\n -------\n instance: SNowInstance\n The ServiceNow instance to install the knowledge base in\n kb_name: str\n The name of the knowledge base that will be created\n kb_data: dict\n The knowledge base data to upload\n disable_commenting: bool\n Whether to disable commenting on the knowledge base\n add_article_name: bool\n Whether to add the article name to the article text. If False, the articles will be named \"Article \"\n Otherwise, we will extract the article title from the 'item' field in the JSON file.\n\n \"\"\"\n logging.info(f\"Installing knowledge base {kb_name}...\")\n\n # Create the knowledge base\n logging.info(f\"... creating knowledge base {kb_name}\")\n disable_commenting = \"true\" if disable_commenting else \"false\"\n\n kb = table_api_call(\n instance=instance,\n table=\"kb_knowledge_base\",\n method=\"POST\",\n data=json.dumps(\n {\n \"title\": kb_name,\n \"disable_commenting\": disable_commenting,\n \"disable_mark_as_helpful\": disable_commenting,\n \"disable_rating\": disable_commenting,\n \"disable_suggesting\": disable_commenting,\n \"disable_category_editing\": disable_commenting,\n }\n ),\n )[\"result\"]\n kb_id = kb[\"sys_id\"]\n\n for i, kb_entry in enumerate(kb_data):\n logging.info(f\"... Knowledge Base {kb_name} uploading article {i + 1}/{len(kb_data)}\")\n article = kb_entry[\"article\"]\n if add_article_name:\n short_description = kb_entry[\"item\"]\n else:\n short_description = f\"Article {i + 1}\"\n # Plant a new article in kb_knowledge table\n table_api_call(\n instance,\n table=\"kb_knowledge\",\n method=\"POST\",\n data=json.dumps(\n {\n \"short_description\": short_description,\n \"sys_class_name\": \"kb_knowledge\",\n \"text\": article,\n \"article_type\": \"text\",\n \"kb_knowledge_base\": kb_id,\n }\n ),\n )\n\n\ndef setup_knowledge_bases():\n \"\"\"\n Verify that the knowledge base is installed correctly in the instance.\n If it is not, it will be installed.\n\n \"\"\"\n # Get the ServiceNow instance\n instance = SNowInstance()\n # Mapping between knowledge base name and filepath + whether or not to disable comments + whether or not to add article name\n knowledge_bases = {\n KB_NAME: (KB_FILEPATH, True, False),\n PROTOCOL_KB_NAME: (PROTOCOL_KB_FILEPATH, True, True),\n }\n for kb_name, (kb_filepath, disable_commenting, add_article_name) in knowledge_bases.items():\n # Load the knowledge base\n with open(kb_filepath, \"r\") as f:\n kb_data = json.load(f)\n","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.setup_knowledge_bases","uri":"program://WorkArena/function/src.browsergym.workarena.install.setup_knowledge_bases#L320-L370","kind":"function","name":"setup_knowledge_bases","path":"src/browsergym/workarena/install.py","language":"python","start_line":320,"end_line":370,"context_start_line":300,"context_end_line":390,"code":" short_description = kb_entry[\"item\"]\n else:\n short_description = f\"Article {i + 1}\"\n # Plant a new article in kb_knowledge table\n table_api_call(\n instance,\n table=\"kb_knowledge\",\n method=\"POST\",\n data=json.dumps(\n {\n \"short_description\": short_description,\n \"sys_class_name\": \"kb_knowledge\",\n \"text\": article,\n \"article_type\": \"text\",\n \"kb_knowledge_base\": kb_id,\n }\n ),\n )\n\n\ndef setup_knowledge_bases():\n \"\"\"\n Verify that the knowledge base is installed correctly in the instance.\n If it is not, it will be installed.\n\n \"\"\"\n # Get the ServiceNow instance\n instance = SNowInstance()\n # Mapping between knowledge base name and filepath + whether or not to disable comments + whether or not to add article name\n knowledge_bases = {\n KB_NAME: (KB_FILEPATH, True, False),\n PROTOCOL_KB_NAME: (PROTOCOL_KB_FILEPATH, True, True),\n }\n for kb_name, (kb_filepath, disable_commenting, add_article_name) in knowledge_bases.items():\n # Load the knowledge base\n with open(kb_filepath, \"r\") as f:\n kb_data = json.load(f)\n\n kb_id, requires_install, requires_delete = check_knowledge_base(\n instance=instance,\n kb_name=kb_name,\n kb_data=kb_data,\n disable_commenting=disable_commenting,\n )\n\n # Delete knowledge base if needed\n if requires_delete:\n logging.info(f\"Knowledge base {kb_name} is corrupt. Reinstalling...\")\n delete_knowledge_base(instance=instance, kb_id=kb_id, kb_name=kb_name)\n\n # Install the knowledge base\n if requires_install:\n create_knowledge_base(\n instance=instance,\n kb_name=kb_name,\n kb_data=kb_data,\n disable_commenting=disable_commenting,\n add_article_name=add_article_name,\n )\n\n # Confirm that the knowledge base was installed correctly\n kb_id, requires_install, requires_delete = check_knowledge_base(\n instance=instance, kb_name=kb_name, kb_data=kb_data\n )\n assert (\n not requires_install or requires_delete\n ), f\"Knowledge base {kb_name} installation failed.\"\n logging.info(f\"Knowledge base {kb_name} installation succeeded.\")\n\n if not requires_delete and not requires_install:\n logging.info(f\"Knowledge base {kb_name} is already installed.\")\n\n\ndef setup_workflows():\n \"\"\"\n Verify that workflows are correctly installed.\n If not, install them.\n\n \"\"\"\n if not check_workflows_installed():\n install_workflows()\n assert check_workflows_installed(), \"Workflow installation failed.\"\n logging.info(\"Workflow installation succeeded.\")\n\n\ndef check_workflows_installed():\n \"\"\"\n Check if the workflows are installed in the instance.\n\n Will return False if workflows need to be (re)installed. True if all is good.\n","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.setup_workflows","uri":"program://WorkArena/function/src.browsergym.workarena.install.setup_workflows#L373-L382","kind":"function","name":"setup_workflows","path":"src/browsergym/workarena/install.py","language":"python","start_line":373,"end_line":382,"context_start_line":353,"context_end_line":402,"code":" instance=instance,\n kb_name=kb_name,\n kb_data=kb_data,\n disable_commenting=disable_commenting,\n add_article_name=add_article_name,\n )\n\n # Confirm that the knowledge base was installed correctly\n kb_id, requires_install, requires_delete = check_knowledge_base(\n instance=instance, kb_name=kb_name, kb_data=kb_data\n )\n assert (\n not requires_install or requires_delete\n ), f\"Knowledge base {kb_name} installation failed.\"\n logging.info(f\"Knowledge base {kb_name} installation succeeded.\")\n\n if not requires_delete and not requires_install:\n logging.info(f\"Knowledge base {kb_name} is already installed.\")\n\n\ndef setup_workflows():\n \"\"\"\n Verify that workflows are correctly installed.\n If not, install them.\n\n \"\"\"\n if not check_workflows_installed():\n install_workflows()\n assert check_workflows_installed(), \"Workflow installation failed.\"\n logging.info(\"Workflow installation succeeded.\")\n\n\ndef check_workflows_installed():\n \"\"\"\n Check if the workflows are installed in the instance.\n\n Will return False if workflows need to be (re)installed. True if all is good.\n\n \"\"\"\n expected_workflow_names = [x[\"name\"] for x in WORKFLOWS.values()]\n workflows = table_api_call(\n instance=SNowInstance(),\n table=\"wf_workflow\",\n params={\n \"sysparm_query\": \"nameIN\" + \",\".join(expected_workflow_names),\n },\n )[\"result\"]\n\n # Verify that all workflows are installed\n if len(workflows) != len(WORKFLOWS):","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.check_workflows_installed","uri":"program://WorkArena/function/src.browsergym.workarena.install.check_workflows_installed#L385-L409","kind":"function","name":"check_workflows_installed","path":"src/browsergym/workarena/install.py","language":"python","start_line":385,"end_line":409,"context_start_line":365,"context_end_line":429,"code":" not requires_install or requires_delete\n ), f\"Knowledge base {kb_name} installation failed.\"\n logging.info(f\"Knowledge base {kb_name} installation succeeded.\")\n\n if not requires_delete and not requires_install:\n logging.info(f\"Knowledge base {kb_name} is already installed.\")\n\n\ndef setup_workflows():\n \"\"\"\n Verify that workflows are correctly installed.\n If not, install them.\n\n \"\"\"\n if not check_workflows_installed():\n install_workflows()\n assert check_workflows_installed(), \"Workflow installation failed.\"\n logging.info(\"Workflow installation succeeded.\")\n\n\ndef check_workflows_installed():\n \"\"\"\n Check if the workflows are installed in the instance.\n\n Will return False if workflows need to be (re)installed. True if all is good.\n\n \"\"\"\n expected_workflow_names = [x[\"name\"] for x in WORKFLOWS.values()]\n workflows = table_api_call(\n instance=SNowInstance(),\n table=\"wf_workflow\",\n params={\n \"sysparm_query\": \"nameIN\" + \",\".join(expected_workflow_names),\n },\n )[\"result\"]\n\n # Verify that all workflows are installed\n if len(workflows) != len(WORKFLOWS):\n logging.info(\n f\"Missing workflows: {set(expected_workflow_names) - set([w['name'] for w in workflows])}.\"\n )\n return False\n\n logging.info(\"All workflows are installed properly.\")\n return True\n\n\ndef install_workflows():\n \"\"\"\n Install workflows using ServiceNow update sets.\n\n Notes: requires interacting with the UI, so we use playwright instead of the API\n\n \"\"\"\n logging.info(\"Installing workflow update sets...\")\n for wf in WORKFLOWS.values():\n _install_update_set(path=wf[\"update_set\"], name=wf[\"name\"])\n\n\ndef display_all_expected_columns(\n instance: SNowInstance, list_name: str, expected_columns: list[str]\n):\n \"\"\"\n Display all expected columns in a given list view.\n","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.install_workflows","uri":"program://WorkArena/function/src.browsergym.workarena.install.install_workflows#L412-L421","kind":"function","name":"install_workflows","path":"src/browsergym/workarena/install.py","language":"python","start_line":412,"end_line":421,"context_start_line":392,"context_end_line":441,"code":" expected_workflow_names = [x[\"name\"] for x in WORKFLOWS.values()]\n workflows = table_api_call(\n instance=SNowInstance(),\n table=\"wf_workflow\",\n params={\n \"sysparm_query\": \"nameIN\" + \",\".join(expected_workflow_names),\n },\n )[\"result\"]\n\n # Verify that all workflows are installed\n if len(workflows) != len(WORKFLOWS):\n logging.info(\n f\"Missing workflows: {set(expected_workflow_names) - set([w['name'] for w in workflows])}.\"\n )\n return False\n\n logging.info(\"All workflows are installed properly.\")\n return True\n\n\ndef install_workflows():\n \"\"\"\n Install workflows using ServiceNow update sets.\n\n Notes: requires interacting with the UI, so we use playwright instead of the API\n\n \"\"\"\n logging.info(\"Installing workflow update sets...\")\n for wf in WORKFLOWS.values():\n _install_update_set(path=wf[\"update_set\"], name=wf[\"name\"])\n\n\ndef display_all_expected_columns(\n instance: SNowInstance, list_name: str, expected_columns: list[str]\n):\n \"\"\"\n Display all expected columns in a given list view.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to configure.\n list_name: str\n The name of the list to display columns for.\n expected_columns: list[str]\n The list of columns to display.\n\n \"\"\"\n logging.info(f\"... Setting up default view for list {list_name}\")\n","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.display_all_expected_columns","uri":"program://WorkArena/function/src.browsergym.workarena.install.display_all_expected_columns#L424-L492","kind":"function","name":"display_all_expected_columns","path":"src/browsergym/workarena/install.py","language":"python","start_line":424,"end_line":492,"context_start_line":404,"context_end_line":512,"code":" f\"Missing workflows: {set(expected_workflow_names) - set([w['name'] for w in workflows])}.\"\n )\n return False\n\n logging.info(\"All workflows are installed properly.\")\n return True\n\n\ndef install_workflows():\n \"\"\"\n Install workflows using ServiceNow update sets.\n\n Notes: requires interacting with the UI, so we use playwright instead of the API\n\n \"\"\"\n logging.info(\"Installing workflow update sets...\")\n for wf in WORKFLOWS.values():\n _install_update_set(path=wf[\"update_set\"], name=wf[\"name\"])\n\n\ndef display_all_expected_columns(\n instance: SNowInstance, list_name: str, expected_columns: list[str]\n):\n \"\"\"\n Display all expected columns in a given list view.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to configure.\n list_name: str\n The name of the list to display columns for.\n expected_columns: list[str]\n The list of columns to display.\n\n \"\"\"\n logging.info(f\"... Setting up default view for list {list_name}\")\n\n # Get the default view (for all users)\n logging.info(f\"...... Fetching default view for list {list_name}...\")\n default_view = table_api_call(\n instance=instance,\n table=\"sys_ui_list\",\n params={\n \"sysparm_query\": f\"name={list_name}^view.title=Default View^sys_userISEMPTY^parentISEMPTY\",\n \"sysparm_fields\": \"sys_id,name,view.title,sys_user\",\n },\n )[\"result\"]\n\n # If there is more than one, delete all but the one with the most recently updated\n if len(default_view) > 1:\n logging.info(\n f\"......... Multiple default views found for list {list_name}. Deleting all but the most recent one.\"\n )\n default_view = sorted(default_view, key=lambda x: x[\"sys_updated_on\"], reverse=True)\n # Delete all but the first one\n for view in default_view[1:]:\n logging.info(f\"............ Deleting view {view['sys_id']}\")\n table_api_call(\n instance=instance, table=f\"sys_ui_list/{view['sys_id']}\", method=\"DELETE\"\n )\n default_view = default_view[0]\n\n # Find all columns in the view (get their sysid)\n logging.info(f\"...... Fetching existing columns for default view of list {list_name}...\")\n columns = table_api_call(\n instance=instance,\n table=\"sys_ui_list_element\",\n params={\"sysparm_query\": f\"list_id={default_view['sys_id']}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"]\n\n # Delete all columns in the default view\n logging.info(f\"...... Deleting existing columns for default view of list {list_name}...\")\n for column in columns:\n table_api_call(\n instance=instance, table=f\"sys_ui_list_element/{column['sys_id']}\", method=\"DELETE\"\n )\n\n # Add all expected columns to the default view\n logging.info(f\"...... Adding expected columns to default view of list {list_name}...\")\n for i, column in enumerate(expected_columns):\n logging.info(f\"......... {column}\")\n table_api_call(\n instance=instance,\n table=\"sys_ui_list_element\",\n method=\"POST\",\n data=json.dumps({\"list_id\": default_view[\"sys_id\"], \"element\": column, \"position\": i}),\n )\n logging.info(f\"...... Done.\")\n\n\ndef check_all_columns_displayed(\n instance: SNowInstance, url: str, expected_columns: list[str]\n) -> bool:\n \"\"\"\n Get the visible columns and checks that all expected columns are displayed.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to configure.\n url: str\n The URL of the list view to check.\n expected_columns: list[str]\n The set of columns to check for.\n\n Returns:\n --------\n bool: True if all expected columns are displayed, False otherwise.","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.check_all_columns_displayed","uri":"program://WorkArena/function/src.browsergym.workarena.install.check_all_columns_displayed#L495-L537","kind":"function","name":"check_all_columns_displayed","path":"src/browsergym/workarena/install.py","language":"python","start_line":495,"end_line":537,"context_start_line":475,"context_end_line":557,"code":" # Delete all columns in the default view\n logging.info(f\"...... Deleting existing columns for default view of list {list_name}...\")\n for column in columns:\n table_api_call(\n instance=instance, table=f\"sys_ui_list_element/{column['sys_id']}\", method=\"DELETE\"\n )\n\n # Add all expected columns to the default view\n logging.info(f\"...... Adding expected columns to default view of list {list_name}...\")\n for i, column in enumerate(expected_columns):\n logging.info(f\"......... {column}\")\n table_api_call(\n instance=instance,\n table=\"sys_ui_list_element\",\n method=\"POST\",\n data=json.dumps({\"list_id\": default_view[\"sys_id\"], \"element\": column, \"position\": i}),\n )\n logging.info(f\"...... Done.\")\n\n\ndef check_all_columns_displayed(\n instance: SNowInstance, url: str, expected_columns: list[str]\n) -> bool:\n \"\"\"\n Get the visible columns and checks that all expected columns are displayed.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to configure.\n url: str\n The URL of the list view to check.\n expected_columns: list[str]\n The set of columns to check for.\n\n Returns:\n --------\n bool: True if all expected columns are displayed, False otherwise.\n\n \"\"\"\n with sync_playwright() as playwright:\n browser = playwright.chromium.launch(headless=True, slow_mo=1000)\n page = browser.new_page()\n url_login(instance, page)\n page.goto(instance.snow_url + url)\n iframe = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n # Wait for gsft_main.GlideList2 to be available\n page.wait_for_function(\"typeof gsft_main.GlideList2 !== 'undefined'\")\n lst = iframe.locator(\"table.data_list_table\")\n\n # Validate the number of lists on the page\n lst = lst.nth(0)\n js_selector = f\"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')\"\n visible_columns = set(page.evaluate(f\"{js_selector}.fields\").split(\",\"))\n\n # check if expected columns is contained in the visible columns\n if not set(expected_columns).issubset(visible_columns):\n logging.info(\n f\"Error setting up list at {url} \\n Expected {expected_columns} columns, but got {visible_columns}.\"\n )\n return False\n logging.info(f\"All columns properly displayed for {url}.\")\n return True\n\n\ndef setup_list_columns():\n \"\"\"\n Setup the list view to display the expected number of columns.\n\n \"\"\"\n logging.info(\"Setting up visible list columns...\")\n list_mappings = {\n \"alm_asset\": {\n \"url\": \"/now/nav/ui/classic/params/target/alm_asset_list.do\",\n \"expected_columns_path\": EXPECTED_ASSET_LIST_COLUMNS_PATH,\n },\n \"alm_hardware\": {\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n \"expected_columns_path\": EXPECTED_HARDWARE_COLUMNS_PATH,\n },\n \"change_request\": {\n \"url\": \"/now/nav/ui/classic/params/target/change_request_list.do\",\n \"expected_columns_path\": EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.setup_list_columns","uri":"program://WorkArena/function/src.browsergym.workarena.install.setup_list_columns#L540-L605","kind":"function","name":"setup_list_columns","path":"src/browsergym/workarena/install.py","language":"python","start_line":540,"end_line":605,"context_start_line":520,"context_end_line":625,"code":" iframe = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n # Wait for gsft_main.GlideList2 to be available\n page.wait_for_function(\"typeof gsft_main.GlideList2 !== 'undefined'\")\n lst = iframe.locator(\"table.data_list_table\")\n\n # Validate the number of lists on the page\n lst = lst.nth(0)\n js_selector = f\"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')\"\n visible_columns = set(page.evaluate(f\"{js_selector}.fields\").split(\",\"))\n\n # check if expected columns is contained in the visible columns\n if not set(expected_columns).issubset(visible_columns):\n logging.info(\n f\"Error setting up list at {url} \\n Expected {expected_columns} columns, but got {visible_columns}.\"\n )\n return False\n logging.info(f\"All columns properly displayed for {url}.\")\n return True\n\n\ndef setup_list_columns():\n \"\"\"\n Setup the list view to display the expected number of columns.\n\n \"\"\"\n logging.info(\"Setting up visible list columns...\")\n list_mappings = {\n \"alm_asset\": {\n \"url\": \"/now/nav/ui/classic/params/target/alm_asset_list.do\",\n \"expected_columns_path\": EXPECTED_ASSET_LIST_COLUMNS_PATH,\n },\n \"alm_hardware\": {\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n \"expected_columns_path\": EXPECTED_HARDWARE_COLUMNS_PATH,\n },\n \"change_request\": {\n \"url\": \"/now/nav/ui/classic/params/target/change_request_list.do\",\n \"expected_columns_path\": EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n },\n \"incident\": {\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n \"expected_columns_path\": EXPECTED_INCIDENT_COLUMNS_PATH,\n },\n \"problem\": {\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n \"expected_columns_path\": EXPECTED_PROBLEM_COLUMNS_PATH,\n },\n \"sys_user\": {\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n \"expected_columns_path\": EXPECTED_USER_COLUMNS_PATH,\n },\n \"sc_req_item\": {\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n \"expected_columns_path\": EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,\n },\n \"fm_expense_line\": {\n \"url\": \"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n \"expected_columns_path\": EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n },\n \"sc_cat_item\": {\n \"url\": \"/now/nav/ui/classic/params/target/sc_cat_item_list.do\",\n \"expected_columns_path\": EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n },\n }\n\n logging.info(\"... Creating a new user account to validate list columns\")\n admin_instance = SNowInstance()\n username, password, usysid = create_user(instance=admin_instance)\n user_instance = SNowInstance(snow_credentials=(username, password))\n\n for task, task_info in list_mappings.items():\n expected_columns_path = task_info[\"expected_columns_path\"]\n with open(expected_columns_path, \"r\") as f:\n expected_columns = list(json.load(f))\n\n # Configuration is done via API (with admin credentials)\n display_all_expected_columns(admin_instance, task, expected_columns=expected_columns)\n\n # Validation is done via UI (with normal user credentials to see if changes have propagated)\n assert check_all_columns_displayed(\n user_instance, task_info[\"url\"], expected_columns=expected_columns\n ), f\"Error setting up list columns at {task_info['url']}\"\n\n # Delete the user account\n logging.info(\"... Deleting the test user account\")\n table_api_call(instance=admin_instance, table=f\"sys_user/{usysid}\", method=\"DELETE\")\n\n\n@retry(\n stop=stop_after_attempt(3),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\ndef process_form_fields(instance: SNowInstance, url: str, expected_fields: list[str], action: str):\n \"\"\"Process form fields based on the given action.\"\"\"\n with sync_playwright() as playwright:\n browser = playwright.chromium.launch(headless=True, slow_mo=1000)\n page = browser.new_page()\n url_login(instance, page)\n page.goto(instance.snow_url + url)\n frame = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n page.wait_for_function(\"typeof gsft_main.GlideList2 !== 'undefined'\")\n # Open form personalization view if not expanded\n form_personalization_expanded = frame.locator(\n 'button:has-text(\"Personalize Form\")'","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.process_form_fields","uri":"program://WorkArena/function/src.browsergym.workarena.install.process_form_fields#L614-L660","kind":"function","name":"process_form_fields","path":"src/browsergym/workarena/install.py","language":"python","start_line":614,"end_line":660,"context_start_line":594,"context_end_line":680,"code":"\n # Configuration is done via API (with admin credentials)\n display_all_expected_columns(admin_instance, task, expected_columns=expected_columns)\n\n # Validation is done via UI (with normal user credentials to see if changes have propagated)\n assert check_all_columns_displayed(\n user_instance, task_info[\"url\"], expected_columns=expected_columns\n ), f\"Error setting up list columns at {task_info['url']}\"\n\n # Delete the user account\n logging.info(\"... Deleting the test user account\")\n table_api_call(instance=admin_instance, table=f\"sys_user/{usysid}\", method=\"DELETE\")\n\n\n@retry(\n stop=stop_after_attempt(3),\n retry=retry_if_exception_type(TimeoutError),\n reraise=True,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n)\ndef process_form_fields(instance: SNowInstance, url: str, expected_fields: list[str], action: str):\n \"\"\"Process form fields based on the given action.\"\"\"\n with sync_playwright() as playwright:\n browser = playwright.chromium.launch(headless=True, slow_mo=1000)\n page = browser.new_page()\n url_login(instance, page)\n page.goto(instance.snow_url + url)\n frame = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n page.wait_for_function(\"typeof gsft_main.GlideList2 !== 'undefined'\")\n # Open form personalization view if not expanded\n form_personalization_expanded = frame.locator(\n 'button:has-text(\"Personalize Form\")'\n ).get_attribute(\"aria-expanded\")\n if form_personalization_expanded == \"false\":\n frame.click('button:has-text(\"Personalize Form\")')\n available_options = (\n frame.get_by_label(\"Personalize Form\").locator('li[role=\"presentation\"] >> input').all()\n )\n\n for option in available_options:\n id = option.get_attribute(\"id\")\n disabled = option.get_attribute(\"disabled\")\n if disabled == \"disabled\":\n continue\n checked = option.get_attribute(\"aria-checked\")\n if action == \"display\":\n if id in expected_fields and checked == \"false\":\n option.evaluate(\"e => e.click()\") # playwright clicking doesn't work\n elif id not in expected_fields and checked == \"true\":\n option.evaluate(\"e => e.click()\") # playwright clicking doesn't work\n elif action == \"check\":\n if id in expected_fields and checked == \"false\":\n logging.info(\n f\"Error setting up form fields at {url} \\n Field {id} was supposed to be checked, but was not.\"\n )\n return False\n elif id not in expected_fields and checked == \"true\":\n logging.info(\n f\"Error setting up form fields at {url} \\n Field {id} was not supposed to be checked, but was.\"\n )\n return False\n if action == \"check\":\n logging.info(f\"All fields properly displayed for {url}.\")\n\n # Close the form personalization view\n frame.click('button:has-text(\"Personalize Form\")')\n return True\n\n\ndef setup_form_fields():\n task_mapping = {\n \"create_change_request\": {\n \"expected_fields_path\": EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/change_request.do\",\n },\n \"create_incident\": {\n \"expected_fields_path\": EXPECTED_INCIDENT_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/incident.do\",\n },\n \"create_hardware\": {\n \"expected_fields_path\": EXPECTED_HARDWARE_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware.do\",\n },\n \"create_problem\": {\n \"expected_fields_path\": EXPECTED_PROBLEM_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/problem.do\",\n },","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.setup_form_fields","uri":"program://WorkArena/function/src.browsergym.workarena.install.setup_form_fields#L663-L742","kind":"function","name":"setup_form_fields","path":"src/browsergym/workarena/install.py","language":"python","start_line":663,"end_line":742,"context_start_line":643,"context_end_line":762,"code":" option.evaluate(\"e => e.click()\") # playwright clicking doesn't work\n elif action == \"check\":\n if id in expected_fields and checked == \"false\":\n logging.info(\n f\"Error setting up form fields at {url} \\n Field {id} was supposed to be checked, but was not.\"\n )\n return False\n elif id not in expected_fields and checked == \"true\":\n logging.info(\n f\"Error setting up form fields at {url} \\n Field {id} was not supposed to be checked, but was.\"\n )\n return False\n if action == \"check\":\n logging.info(f\"All fields properly displayed for {url}.\")\n\n # Close the form personalization view\n frame.click('button:has-text(\"Personalize Form\")')\n return True\n\n\ndef setup_form_fields():\n task_mapping = {\n \"create_change_request\": {\n \"expected_fields_path\": EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/change_request.do\",\n },\n \"create_incident\": {\n \"expected_fields_path\": EXPECTED_INCIDENT_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/incident.do\",\n },\n \"create_hardware\": {\n \"expected_fields_path\": EXPECTED_HARDWARE_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware.do\",\n },\n \"create_problem\": {\n \"expected_fields_path\": EXPECTED_PROBLEM_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/problem.do\",\n },\n \"create_user\": {\n \"expected_fields_path\": EXPECTED_USER_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/sys_user.do\",\n },\n \"create_request_item\": {\n \"expected_fields_path\": EXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH,\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item.do\",\n },\n }\n\n logging.info(\"... Creating a new user account to validate form fields\")\n admin_instance = SNowInstance()\n username, password, usysid = create_user(instance=admin_instance)\n user_instance = SNowInstance(snow_credentials=(username, password))\n\n for task, task_info in task_mapping.items():\n expected_fields_path = task_info[\"expected_fields_path\"]\n with open(expected_fields_path, \"r\") as f:\n expected_fields = json.load(f)\n\n logging.info(f\"Setting up form fields for {task}...\")\n process_form_fields(\n admin_instance, task_info[\"url\"], expected_fields=expected_fields, action=\"display\"\n )\n sleep(5)\n\n # If the view was edited, a new user preference was created for the admin user\n # We want to apply it to all users so we need to edit the record to set sys_user to empty\n # and system to true.\n logging.info(f\"Checking for new user preferences for {task} form fields\")\n user_preferences = table_api_call(\n instance=admin_instance,\n table=\"sys_user_preference\",\n params={\n \"sysparm_query\": f\"name=personalize_{task_info['url'].split('/')[-1].strip().replace('.do', '')}_default\"\n },\n )[\"result\"]\n if len(user_preferences) > 0:\n logging.info(f\"Generalizing new settings to all users for {task} form fields\")\n # Get the most recent user preference\n user_preference = sorted(\n user_preferences, key=lambda x: x[\"sys_updated_on\"], reverse=True\n )[0]\n # Update the user preference\n table_api_call(\n instance=admin_instance,\n table=f\"sys_user_preference/{user_preference['sys_id']}\",\n method=\"PATCH\",\n json={\"user\": \"\", \"system\": \"true\"},\n )\n\n # Validation is done with a new user to make sure the changes have propagated\n logging.info(f\"Validating form fields for {task}...\")\n assert process_form_fields(\n user_instance, task_info[\"url\"], expected_fields=expected_fields, action=\"check\"\n ), f\"Error setting up form fields at {task_info['url']}\"\n\n # Delete the user account\n logging.info(\"... Deleting the test user account\")\n table_api_call(instance=admin_instance, table=f\"sys_user/{usysid}\", method=\"DELETE\")\n\n logging.info(\"All form fields properly displayed.\")\n\n\ndef check_instance_release_support():\n \"\"\"\n Check that the instance is running a compatible version of ServiceNow.\n\n Returns:\n --------\n bool: True if the version is supported, False otherwise.\n\n \"\"\"\n instance = SNowInstance()\n version_info = instance.release_version\n if version_info[\"build name\"] not in SNOW_SUPPORTED_RELEASES:\n logging.error(\n f\"The ServiceNow release version of your instance is not supported. \"\n f\"Supported versions: {SNOW_SUPPORTED_RELEASES}. \"\n f\"You are running {version_info['build name']} {version_info}.\"\n )\n return False","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.check_instance_release_support","uri":"program://WorkArena/function/src.browsergym.workarena.install.check_instance_release_support#L745-L764","kind":"function","name":"check_instance_release_support","path":"src/browsergym/workarena/install.py","language":"python","start_line":745,"end_line":764,"context_start_line":725,"context_end_line":784,"code":" table_api_call(\n instance=admin_instance,\n table=f\"sys_user_preference/{user_preference['sys_id']}\",\n method=\"PATCH\",\n json={\"user\": \"\", \"system\": \"true\"},\n )\n\n # Validation is done with a new user to make sure the changes have propagated\n logging.info(f\"Validating form fields for {task}...\")\n assert process_form_fields(\n user_instance, task_info[\"url\"], expected_fields=expected_fields, action=\"check\"\n ), f\"Error setting up form fields at {task_info['url']}\"\n\n # Delete the user account\n logging.info(\"... Deleting the test user account\")\n table_api_call(instance=admin_instance, table=f\"sys_user/{usysid}\", method=\"DELETE\")\n\n logging.info(\"All form fields properly displayed.\")\n\n\ndef check_instance_release_support():\n \"\"\"\n Check that the instance is running a compatible version of ServiceNow.\n\n Returns:\n --------\n bool: True if the version is supported, False otherwise.\n\n \"\"\"\n instance = SNowInstance()\n version_info = instance.release_version\n if version_info[\"build name\"] not in SNOW_SUPPORTED_RELEASES:\n logging.error(\n f\"The ServiceNow release version of your instance is not supported. \"\n f\"Supported versions: {SNOW_SUPPORTED_RELEASES}. \"\n f\"You are running {version_info['build name']} {version_info}.\"\n )\n return False\n\n return True\n\n\ndef enable_url_login():\n \"\"\"\n Configure the instance to allow login via URL.\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.security.restrict.get.login\", value=\"false\"\n )\n logging.info(\"URL login enabled.\")\n\n\ndef disable_password_policies():\n \"\"\"\n Disable password policies in the instance.\n\n Notes: this is required to allow the creation of users with weak passwords.\n\n \"\"\"","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.enable_url_login","uri":"program://WorkArena/function/src.browsergym.workarena.install.enable_url_login#L767-L775","kind":"function","name":"enable_url_login","path":"src/browsergym/workarena/install.py","language":"python","start_line":767,"end_line":775,"context_start_line":747,"context_end_line":795,"code":" Check that the instance is running a compatible version of ServiceNow.\n\n Returns:\n --------\n bool: True if the version is supported, False otherwise.\n\n \"\"\"\n instance = SNowInstance()\n version_info = instance.release_version\n if version_info[\"build name\"] not in SNOW_SUPPORTED_RELEASES:\n logging.error(\n f\"The ServiceNow release version of your instance is not supported. \"\n f\"Supported versions: {SNOW_SUPPORTED_RELEASES}. \"\n f\"You are running {version_info['build name']} {version_info}.\"\n )\n return False\n\n return True\n\n\ndef enable_url_login():\n \"\"\"\n Configure the instance to allow login via URL.\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.security.restrict.get.login\", value=\"false\"\n )\n logging.info(\"URL login enabled.\")\n\n\ndef disable_password_policies():\n \"\"\"\n Disable password policies in the instance.\n\n Notes: this is required to allow the creation of users with weak passwords.\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"glide.security.password.policy.enabled\",\n value=\"false\",\n )\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.apply.password_policy.on_login\", value=\"false\"\n )\n # Exception handling since this property is sometimes read-only on some instances\n try:\n set_sys_property(","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.disable_password_policies","uri":"program://WorkArena/function/src.browsergym.workarena.install.disable_password_policies#L778-L807","kind":"function","name":"disable_password_policies","path":"src/browsergym/workarena/install.py","language":"python","start_line":778,"end_line":807,"context_start_line":758,"context_end_line":827,"code":" f\"The ServiceNow release version of your instance is not supported. \"\n f\"Supported versions: {SNOW_SUPPORTED_RELEASES}. \"\n f\"You are running {version_info['build name']} {version_info}.\"\n )\n return False\n\n return True\n\n\ndef enable_url_login():\n \"\"\"\n Configure the instance to allow login via URL.\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.security.restrict.get.login\", value=\"false\"\n )\n logging.info(\"URL login enabled.\")\n\n\ndef disable_password_policies():\n \"\"\"\n Disable password policies in the instance.\n\n Notes: this is required to allow the creation of users with weak passwords.\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"glide.security.password.policy.enabled\",\n value=\"false\",\n )\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.apply.password_policy.on_login\", value=\"false\"\n )\n # Exception handling since this property is sometimes read-only on some instances\n try:\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"glide.authenticate.api.user.reset_password.mandatory\",\n value=\"false\",\n )\n except Exception:\n logging.warning(\n \"Warning: Failed to set sys property \"\n \"'glide.authenticate.api.user.reset_password.mandatory'. Continuing.\",\n exc_info=True,\n )\n\n logging.info(\"Password policies disabled.\")\n\n\ndef disable_guided_tours():\n \"\"\"\n Hide guided tour popups\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"com.snc.guided_tours.sp.enable\", value=\"false\"\n )\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"com.snc.guided_tours.standard_ui.enable\",\n value=\"false\",\n )\n logging.info(\"Guided tours disabled.\")\n\n\ndef disable_welcome_help_popup():\n \"\"\"","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.disable_guided_tours","uri":"program://WorkArena/function/src.browsergym.workarena.install.disable_guided_tours#L810-L823","kind":"function","name":"disable_guided_tours","path":"src/browsergym/workarena/install.py","language":"python","start_line":810,"end_line":823,"context_start_line":790,"context_end_line":843,"code":" set_sys_property(\n instance=SNowInstance(), property_name=\"glide.apply.password_policy.on_login\", value=\"false\"\n )\n # Exception handling since this property is sometimes read-only on some instances\n try:\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"glide.authenticate.api.user.reset_password.mandatory\",\n value=\"false\",\n )\n except Exception:\n logging.warning(\n \"Warning: Failed to set sys property \"\n \"'glide.authenticate.api.user.reset_password.mandatory'. Continuing.\",\n exc_info=True,\n )\n\n logging.info(\"Password policies disabled.\")\n\n\ndef disable_guided_tours():\n \"\"\"\n Hide guided tour popups\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"com.snc.guided_tours.sp.enable\", value=\"false\"\n )\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"com.snc.guided_tours.standard_ui.enable\",\n value=\"false\",\n )\n logging.info(\"Guided tours disabled.\")\n\n\ndef disable_welcome_help_popup():\n \"\"\"\n Disable the welcome help popup\n\n \"\"\"\n set_user_preference(instance=SNowInstance(), key=\"overview_help.visited.navui\", value=\"true\")\n logging.info(\"Welcome help popup disabled.\")\n\n\ndef disable_analytics_popups():\n \"\"\"\n Disable analytics popups (needs to be done through UI since Vancouver release)\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.analytics.enabled\", value=\"false\"\n )\n logging.info(\"Analytics popups disabled.\")","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.disable_welcome_help_popup","uri":"program://WorkArena/function/src.browsergym.workarena.install.disable_welcome_help_popup#L826-L832","kind":"function","name":"disable_welcome_help_popup","path":"src/browsergym/workarena/install.py","language":"python","start_line":826,"end_line":832,"context_start_line":806,"context_end_line":852,"code":"\n logging.info(\"Password policies disabled.\")\n\n\ndef disable_guided_tours():\n \"\"\"\n Hide guided tour popups\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"com.snc.guided_tours.sp.enable\", value=\"false\"\n )\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"com.snc.guided_tours.standard_ui.enable\",\n value=\"false\",\n )\n logging.info(\"Guided tours disabled.\")\n\n\ndef disable_welcome_help_popup():\n \"\"\"\n Disable the welcome help popup\n\n \"\"\"\n set_user_preference(instance=SNowInstance(), key=\"overview_help.visited.navui\", value=\"true\")\n logging.info(\"Welcome help popup disabled.\")\n\n\ndef disable_analytics_popups():\n \"\"\"\n Disable analytics popups (needs to be done through UI since Vancouver release)\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.analytics.enabled\", value=\"false\"\n )\n logging.info(\"Analytics popups disabled.\")\n\n\ndef setup_ui_themes():\n \"\"\"\n Install custom UI themes and set it as default\n\n \"\"\"\n logging.info(\"Installing custom UI themes...\")\n _install_update_set(path=UI_THEMES_UPDATE_SET[\"update_set\"], name=UI_THEMES_UPDATE_SET[\"name\"])","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.disable_analytics_popups","uri":"program://WorkArena/function/src.browsergym.workarena.install.disable_analytics_popups#L835-L843","kind":"function","name":"disable_analytics_popups","path":"src/browsergym/workarena/install.py","language":"python","start_line":835,"end_line":843,"context_start_line":815,"context_end_line":863,"code":" set_sys_property(\n instance=SNowInstance(), property_name=\"com.snc.guided_tours.sp.enable\", value=\"false\"\n )\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"com.snc.guided_tours.standard_ui.enable\",\n value=\"false\",\n )\n logging.info(\"Guided tours disabled.\")\n\n\ndef disable_welcome_help_popup():\n \"\"\"\n Disable the welcome help popup\n\n \"\"\"\n set_user_preference(instance=SNowInstance(), key=\"overview_help.visited.navui\", value=\"true\")\n logging.info(\"Welcome help popup disabled.\")\n\n\ndef disable_analytics_popups():\n \"\"\"\n Disable analytics popups (needs to be done through UI since Vancouver release)\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.analytics.enabled\", value=\"false\"\n )\n logging.info(\"Analytics popups disabled.\")\n\n\ndef setup_ui_themes():\n \"\"\"\n Install custom UI themes and set it as default\n\n \"\"\"\n logging.info(\"Installing custom UI themes...\")\n _install_update_set(path=UI_THEMES_UPDATE_SET[\"update_set\"], name=UI_THEMES_UPDATE_SET[\"name\"])\n check_ui_themes_installed()\n\n logging.info(\"Setting default UI theme\")\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"glide.ui.polaris.theme.custom\",\n value=get_workarena_theme_variants(SNowInstance())[0][\"theme.sys_id\"],\n )\n\n # Set admin user's theme variant\n # ... get user's sysid","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.setup_ui_themes","uri":"program://WorkArena/function/src.browsergym.workarena.install.setup_ui_themes#L846-L879","kind":"function","name":"setup_ui_themes","path":"src/browsergym/workarena/install.py","language":"python","start_line":846,"end_line":879,"context_start_line":826,"context_end_line":899,"code":"def disable_welcome_help_popup():\n \"\"\"\n Disable the welcome help popup\n\n \"\"\"\n set_user_preference(instance=SNowInstance(), key=\"overview_help.visited.navui\", value=\"true\")\n logging.info(\"Welcome help popup disabled.\")\n\n\ndef disable_analytics_popups():\n \"\"\"\n Disable analytics popups (needs to be done through UI since Vancouver release)\n\n \"\"\"\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.analytics.enabled\", value=\"false\"\n )\n logging.info(\"Analytics popups disabled.\")\n\n\ndef setup_ui_themes():\n \"\"\"\n Install custom UI themes and set it as default\n\n \"\"\"\n logging.info(\"Installing custom UI themes...\")\n _install_update_set(path=UI_THEMES_UPDATE_SET[\"update_set\"], name=UI_THEMES_UPDATE_SET[\"name\"])\n check_ui_themes_installed()\n\n logging.info(\"Setting default UI theme\")\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"glide.ui.polaris.theme.custom\",\n value=get_workarena_theme_variants(SNowInstance())[0][\"theme.sys_id\"],\n )\n\n # Set admin user's theme variant\n # ... get user's sysid\n admin_user = table_api_call(\n instance=SNowInstance(),\n table=\"sys_user\",\n params={\"sysparm_query\": \"user_name=admin\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0]\n # ... set user preference\n set_user_preference(\n instance=SNowInstance(),\n user=admin_user[\"sys_id\"],\n key=\"glide.ui.polaris.theme.variant\",\n value=[\n x[\"style.sys_id\"]\n for x in get_workarena_theme_variants(SNowInstance())\n if x[\"style.name\"] == \"Workarena\"\n ][0],\n )\n\n\ndef check_ui_themes_installed():\n \"\"\"\n Check if the UI themes are installed in the instance.\n\n \"\"\"\n expected_variants = set([v.lower() for v in UI_THEMES_UPDATE_SET[\"variants\"]])\n installed_themes = get_workarena_theme_variants(SNowInstance())\n installed_themes = set([t[\"style.name\"].lower() for t in installed_themes])\n\n assert (\n installed_themes == expected_variants\n ), f\"\"\"UI theme installation failed.\n Expected: {expected_variants}\n Installed: {installed_themes}\n \"\"\"\n\n\ndef set_home_page():","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.check_ui_themes_installed","uri":"program://WorkArena/function/src.browsergym.workarena.install.check_ui_themes_installed#L882-L896","kind":"function","name":"check_ui_themes_installed","path":"src/browsergym/workarena/install.py","language":"python","start_line":882,"end_line":896,"context_start_line":862,"context_end_line":916,"code":" # Set admin user's theme variant\n # ... get user's sysid\n admin_user = table_api_call(\n instance=SNowInstance(),\n table=\"sys_user\",\n params={\"sysparm_query\": \"user_name=admin\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0]\n # ... set user preference\n set_user_preference(\n instance=SNowInstance(),\n user=admin_user[\"sys_id\"],\n key=\"glide.ui.polaris.theme.variant\",\n value=[\n x[\"style.sys_id\"]\n for x in get_workarena_theme_variants(SNowInstance())\n if x[\"style.name\"] == \"Workarena\"\n ][0],\n )\n\n\ndef check_ui_themes_installed():\n \"\"\"\n Check if the UI themes are installed in the instance.\n\n \"\"\"\n expected_variants = set([v.lower() for v in UI_THEMES_UPDATE_SET[\"variants\"]])\n installed_themes = get_workarena_theme_variants(SNowInstance())\n installed_themes = set([t[\"style.name\"].lower() for t in installed_themes])\n\n assert (\n installed_themes == expected_variants\n ), f\"\"\"UI theme installation failed.\n Expected: {expected_variants}\n Installed: {installed_themes}\n \"\"\"\n\n\ndef set_home_page():\n logging.info(\"Setting default home page\")\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.login.home\", value=\"/now/nav/ui/home\"\n )\n\n\ndef wipe_system_admin_preferences():\n \"\"\"\n Wipe all system admin preferences\n\n \"\"\"\n logging.info(\"Wiping all system admin preferences\")\n sys_admin_prefs = table_api_call(\n instance=SNowInstance(),\n table=\"sys_user_preference\",\n params={\"sysparm_query\": \"user.user_name=admin\", \"sysparm_fields\": \"sys_id,name\"},\n )[\"result\"]","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.set_home_page","uri":"program://WorkArena/function/src.browsergym.workarena.install.set_home_page#L899-L903","kind":"function","name":"set_home_page","path":"src/browsergym/workarena/install.py","language":"python","start_line":899,"end_line":903,"context_start_line":879,"context_end_line":923,"code":" )\n\n\ndef check_ui_themes_installed():\n \"\"\"\n Check if the UI themes are installed in the instance.\n\n \"\"\"\n expected_variants = set([v.lower() for v in UI_THEMES_UPDATE_SET[\"variants\"]])\n installed_themes = get_workarena_theme_variants(SNowInstance())\n installed_themes = set([t[\"style.name\"].lower() for t in installed_themes])\n\n assert (\n installed_themes == expected_variants\n ), f\"\"\"UI theme installation failed.\n Expected: {expected_variants}\n Installed: {installed_themes}\n \"\"\"\n\n\ndef set_home_page():\n logging.info(\"Setting default home page\")\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.login.home\", value=\"/now/nav/ui/home\"\n )\n\n\ndef wipe_system_admin_preferences():\n \"\"\"\n Wipe all system admin preferences\n\n \"\"\"\n logging.info(\"Wiping all system admin preferences\")\n sys_admin_prefs = table_api_call(\n instance=SNowInstance(),\n table=\"sys_user_preference\",\n params={\"sysparm_query\": \"user.user_name=admin\", \"sysparm_fields\": \"sys_id,name\"},\n )[\"result\"]\n\n # Delete all sysadmin preferences\n logging.info(\"... Deleting all preferences\")\n for pref in sys_admin_prefs:\n logging.info(f\"...... deleting {pref['name']}\")\n table_api_call(\n instance=SNowInstance(), table=f\"sys_user_preference/{pref['sys_id']}\", method=\"DELETE\"","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.wipe_system_admin_preferences","uri":"program://WorkArena/function/src.browsergym.workarena.install.wipe_system_admin_preferences#L906-L924","kind":"function","name":"wipe_system_admin_preferences","path":"src/browsergym/workarena/install.py","language":"python","start_line":906,"end_line":924,"context_start_line":886,"context_end_line":944,"code":" \"\"\"\n expected_variants = set([v.lower() for v in UI_THEMES_UPDATE_SET[\"variants\"]])\n installed_themes = get_workarena_theme_variants(SNowInstance())\n installed_themes = set([t[\"style.name\"].lower() for t in installed_themes])\n\n assert (\n installed_themes == expected_variants\n ), f\"\"\"UI theme installation failed.\n Expected: {expected_variants}\n Installed: {installed_themes}\n \"\"\"\n\n\ndef set_home_page():\n logging.info(\"Setting default home page\")\n set_sys_property(\n instance=SNowInstance(), property_name=\"glide.login.home\", value=\"/now/nav/ui/home\"\n )\n\n\ndef wipe_system_admin_preferences():\n \"\"\"\n Wipe all system admin preferences\n\n \"\"\"\n logging.info(\"Wiping all system admin preferences\")\n sys_admin_prefs = table_api_call(\n instance=SNowInstance(),\n table=\"sys_user_preference\",\n params={\"sysparm_query\": \"user.user_name=admin\", \"sysparm_fields\": \"sys_id,name\"},\n )[\"result\"]\n\n # Delete all sysadmin preferences\n logging.info(\"... Deleting all preferences\")\n for pref in sys_admin_prefs:\n logging.info(f\"...... deleting {pref['name']}\")\n table_api_call(\n instance=SNowInstance(), table=f\"sys_user_preference/{pref['sys_id']}\", method=\"DELETE\"\n )\n\n\ndef is_report_filter_using_relative_time(filter):\n \"\"\"\n Heuristic to check if a report is filtering based on relative time\n\n This aims to detect the use of functions like \"gs.endOfToday()\". To avoid hardcoding all of them,\n we simply check for the use of keywords. Our filter is definitely too wide, but that's ok.\n\n \"\"\"\n return \"javascript:gs.\" in filter or \"@ago\" in filter\n\n\ndef patch_report_filters():\n \"\"\"\n Add filters to reports to make sure they stay frozen in time and don't show new data\n as then instance's life cycle progresses.\n\n \"\"\"\n logging.info(\"Patching reports with date filter...\")","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.is_report_filter_using_relative_time","uri":"program://WorkArena/function/src.browsergym.workarena.install.is_report_filter_using_relative_time#L927-L935","kind":"function","name":"is_report_filter_using_relative_time","path":"src/browsergym/workarena/install.py","language":"python","start_line":927,"end_line":935,"context_start_line":907,"context_end_line":955,"code":" \"\"\"\n Wipe all system admin preferences\n\n \"\"\"\n logging.info(\"Wiping all system admin preferences\")\n sys_admin_prefs = table_api_call(\n instance=SNowInstance(),\n table=\"sys_user_preference\",\n params={\"sysparm_query\": \"user.user_name=admin\", \"sysparm_fields\": \"sys_id,name\"},\n )[\"result\"]\n\n # Delete all sysadmin preferences\n logging.info(\"... Deleting all preferences\")\n for pref in sys_admin_prefs:\n logging.info(f\"...... deleting {pref['name']}\")\n table_api_call(\n instance=SNowInstance(), table=f\"sys_user_preference/{pref['sys_id']}\", method=\"DELETE\"\n )\n\n\ndef is_report_filter_using_relative_time(filter):\n \"\"\"\n Heuristic to check if a report is filtering based on relative time\n\n This aims to detect the use of functions like \"gs.endOfToday()\". To avoid hardcoding all of them,\n we simply check for the use of keywords. Our filter is definitely too wide, but that's ok.\n\n \"\"\"\n return \"javascript:gs.\" in filter or \"@ago\" in filter\n\n\ndef patch_report_filters():\n \"\"\"\n Add filters to reports to make sure they stay frozen in time and don't show new data\n as then instance's life cycle progresses.\n\n \"\"\"\n logging.info(\"Patching reports with date filter...\")\n\n instance = SNowInstance()\n filter_config = instance.report_filter_config\n\n # If the report date filter is already set, we use the existing values (would be the case on reinstall)\n if not filter_config:\n # Set the report date filter to current date as YYYY-MM-DD and time filter to current time as HH:MM:SS\n now = datetime.now()\n report_date_filter = now.strftime(\"%Y-%m-%d\")\n report_time_filter = now.strftime(\"%H:%M:%S\")\n # ... save the filter config","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.patch_report_filters","uri":"program://WorkArena/function/src.browsergym.workarena.install.patch_report_filters#L938-L1042","kind":"function","name":"patch_report_filters","path":"src/browsergym/workarena/install.py","language":"python","start_line":938,"end_line":1042,"context_start_line":918,"context_end_line":1062,"code":" # Delete all sysadmin preferences\n logging.info(\"... Deleting all preferences\")\n for pref in sys_admin_prefs:\n logging.info(f\"...... deleting {pref['name']}\")\n table_api_call(\n instance=SNowInstance(), table=f\"sys_user_preference/{pref['sys_id']}\", method=\"DELETE\"\n )\n\n\ndef is_report_filter_using_relative_time(filter):\n \"\"\"\n Heuristic to check if a report is filtering based on relative time\n\n This aims to detect the use of functions like \"gs.endOfToday()\". To avoid hardcoding all of them,\n we simply check for the use of keywords. Our filter is definitely too wide, but that's ok.\n\n \"\"\"\n return \"javascript:gs.\" in filter or \"@ago\" in filter\n\n\ndef patch_report_filters():\n \"\"\"\n Add filters to reports to make sure they stay frozen in time and don't show new data\n as then instance's life cycle progresses.\n\n \"\"\"\n logging.info(\"Patching reports with date filter...\")\n\n instance = SNowInstance()\n filter_config = instance.report_filter_config\n\n # If the report date filter is already set, we use the existing values (would be the case on reinstall)\n if not filter_config:\n # Set the report date filter to current date as YYYY-MM-DD and time filter to current time as HH:MM:SS\n now = datetime.now()\n report_date_filter = now.strftime(\"%Y-%m-%d\")\n report_time_filter = now.strftime(\"%H:%M:%S\")\n # ... save the filter config\n logging.info(\n f\"Setting report date filter to {report_date_filter} and time filter to {report_time_filter} via {REPORT_FILTER_PROPERTY}\"\n )\n set_sys_property(\n instance=instance,\n property_name=REPORT_FILTER_PROPERTY,\n value=json.dumps(\n {\"report_date_filter\": report_date_filter, \"report_time_filter\": report_time_filter}\n ),\n )\n else:\n # Use the existing configuration\n logging.info(\n f\"Using existing report date filter {filter_config['report_date_filter']} and time filter {filter_config['report_time_filter']}\"\n )\n report_date_filter = filter_config[\"report_date_filter\"]\n report_time_filter = filter_config[\"report_time_filter\"]\n\n # Get all reports that are not already patched\n reports = table_api_call(\n instance=instance,\n table=\"sys_report\",\n params={\n \"sysparm_query\": f\"sys_class_name=sys_report^active=true^descriptionNOT LIKE{REPORT_PATCH_FLAG}^ORdescriptionISEMPTY\"\n },\n )[\"result\"]\n\n for report in reports:\n # Find all sys_created_on columns of this record. Some have many.\n sys_created_on_cols = [\n c for c in table_column_info(instance, report[\"table\"]).keys() if \"sys_created_on\" in c\n ]\n try:\n # XXX: We purposely do not support reports with multiple filter conditions for simplicity\n if len(sys_created_on_cols) == 0 or \"^NQ\" in report[\"filter\"]:\n logging.info(f\"Discarding report {report['title']} {report['sys_id']}...\")\n raise NotImplementedError() # Mark for deletion\n\n if not is_report_filter_using_relative_time(report[\"filter\"]):\n # That's a report we want to keep (use date cutoff filter)\n filter_date = report_date_filter\n filter_time = report_time_filter\n logging.info(\n f\"Keeping report {report['title']} {report['sys_id']} (columns: {sys_created_on_cols})...\"\n )\n else:\n # XXX: We do not support reports with filters that rely on relative time (e.g., last 10 days) because\n # there are not stable. In this case, we don't delete them but add a filter to make\n # them empty. They will be shown as \"No data available\".\n logging.info(\n f\"Disabling report {report['title']} {report['sys_id']} because it uses time filters...\"\n )\n filter_date = \"1900-01-01\"\n filter_time = \"00:00:00\"\n\n # Format the filter\n filter = \"\".join(\n [\n f\"^{col} 0 and not report[\"filter\"].startswith(\"^\") else \"\")\n # Patch the report with the new filter\n table_api_call(\n instance=instance,\n table=f\"sys_report/{report['sys_id']}\",\n method=\"PATCH\",\n json={\n \"filter\": filter + report[\"filter\"],\n \"description\": report[\"description\"] + \" \" + REPORT_PATCH_FLAG,\n },\n )\n logging.info(f\"... done\")\n\n except (NotImplementedError, HTTPError):\n # HTTPError occurs when some reports simply cannot be patched because they are critical and protected\n logging.info(f\"...failed to patch report. Attempting delete...\")\n\n # Delete the report if it cannot be patched\n # This might fail sometimes, but it's the best we can do.\n try:\n table_api_call(\n instance=instance, table=f\"sys_report/{report['sys_id']}\", method=\"DELETE\"\n )\n logging.info(f\"...... deleted.\")\n except:\n logging.error(f\"...... could not delete.\")\n\n\n@tenacity.retry(\n stop=tenacity.stop_after_attempt(3),\n reraise=True,\n before_sleep=lambda _: logging.info(\"An error occurred. Retrying...\"),\n)\ndef setup():\n \"\"\"\n Check that WorkArena is installed correctly in the instance.\n\n \"\"\"\n if not check_instance_release_support():\n return # Don't continue if the instance is not supported\n\n # Enable URL login (XXX: Do this first since other functions can use URL login)\n enable_url_login()\n\n # Disable password policies\n disable_password_policies()","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.setup","uri":"program://WorkArena/function/src.browsergym.workarena.install.setup#L1050-L1100","kind":"function","name":"setup","path":"src/browsergym/workarena/install.py","language":"python","start_line":1050,"end_line":1100,"context_start_line":1030,"context_end_line":1120,"code":" except (NotImplementedError, HTTPError):\n # HTTPError occurs when some reports simply cannot be patched because they are critical and protected\n logging.info(f\"...failed to patch report. Attempting delete...\")\n\n # Delete the report if it cannot be patched\n # This might fail sometimes, but it's the best we can do.\n try:\n table_api_call(\n instance=instance, table=f\"sys_report/{report['sys_id']}\", method=\"DELETE\"\n )\n logging.info(f\"...... deleted.\")\n except:\n logging.error(f\"...... could not delete.\")\n\n\n@tenacity.retry(\n stop=tenacity.stop_after_attempt(3),\n reraise=True,\n before_sleep=lambda _: logging.info(\"An error occurred. Retrying...\"),\n)\ndef setup():\n \"\"\"\n Check that WorkArena is installed correctly in the instance.\n\n \"\"\"\n if not check_instance_release_support():\n return # Don't continue if the instance is not supported\n\n # Enable URL login (XXX: Do this first since other functions can use URL login)\n enable_url_login()\n\n # Disable password policies\n disable_password_policies()\n\n # Set default landing page\n set_home_page()\n\n # Disable popups for new users\n # ... guided tours\n disable_guided_tours()\n # ... analytics\n disable_analytics_popups()\n # ... help\n disable_welcome_help_popup()\n\n # Install custom UI themes (needs to be after disabling popups)\n setup_ui_themes()\n\n # Clear all predefined system admin preferences (e.g., default list views, etc.)\n wipe_system_admin_preferences()\n\n # Patch all reports to only show data <= April 1, 2024\n patch_report_filters()\n\n # XXX: Install workflows first because they may automate some downstream installations\n setup_workflows()\n setup_knowledge_bases()\n\n # Setup the user list columns by displaying all columns and checking that the expected number are displayed\n setup_form_fields()\n setup_list_columns()\n\n # Save installation date\n logging.info(\"Saving installation date\")\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"workarena.installation.date\",\n value=datetime.now().isoformat(),\n )\n\n logging.info(\"WorkArena setup complete.\")\n\n\ndef main():\n \"\"\"\n Entrypoint for package CLI installation command\n\n \"\"\"\n logging.basicConfig(level=logging.INFO)\n\n try:\n past_install_date = get_sys_property(\n instance=SNowInstance(), property_name=\"workarena.installation.date\"\n )\n logging.info(f\"Detected previous installation on {past_install_date}. Reinstalling...\")\n except:\n past_install_date = \"never\"\n\n logging.info(\n f\"\"\"\n","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install.main","uri":"program://WorkArena/function/src.browsergym.workarena.install.main#L1103-L1132","kind":"function","name":"main","path":"src/browsergym/workarena/install.py","language":"python","start_line":1103,"end_line":1132,"context_start_line":1083,"context_end_line":1132,"code":"\n # XXX: Install workflows first because they may automate some downstream installations\n setup_workflows()\n setup_knowledge_bases()\n\n # Setup the user list columns by displaying all columns and checking that the expected number are displayed\n setup_form_fields()\n setup_list_columns()\n\n # Save installation date\n logging.info(\"Saving installation date\")\n set_sys_property(\n instance=SNowInstance(),\n property_name=\"workarena.installation.date\",\n value=datetime.now().isoformat(),\n )\n\n logging.info(\"WorkArena setup complete.\")\n\n\ndef main():\n \"\"\"\n Entrypoint for package CLI installation command\n\n \"\"\"\n logging.basicConfig(level=logging.INFO)\n\n try:\n past_install_date = get_sys_property(\n instance=SNowInstance(), property_name=\"workarena.installation.date\"\n )\n logging.info(f\"Detected previous installation on {past_install_date}. Reinstalling...\")\n except:\n past_install_date = \"never\"\n\n logging.info(\n f\"\"\"\n\n██ ██ ██████ ██████ ██ ██ █████ ██████ ███████ ███ ██ █████\n██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██\n██ █ ██ ██ ██ ██████ █████ ███████ ██████ █████ ██ ██ ██ ███████\n██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\n ███ ███ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ██ ████ ██ ██\n\nInstance: {SNowInstance().snow_url}\nPrevious installation: {past_install_date}\n\n\"\"\"\n )\n setup()","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.install._extract_text","uri":"program://WorkArena/function/src.browsergym.workarena.install._extract_text#L148-L152","kind":"function","name":"_extract_text","path":"src/browsergym/workarena/install.py","language":"python","start_line":148,"end_line":152,"context_start_line":128,"context_end_line":172,"code":"\n\ndef check_knowledge_base(\n instance: SNowInstance, kb_name: str, kb_data: dict, disable_commenting: bool = True\n):\n \"\"\"\n Verify the integrity of the knowledge base in the instance.\n Args:\n -----\n instance: SNowInstance\n The ServiceNow instance to check the knowledge base in\n kb_name: str\n The name of the knowledge base to check\n kb_data: dict\n The knowledge base data to check\n disable_commenting: bool\n Whether to disable commenting on the knowledge base\n\n \"\"\"\n\n def _extract_text(article):\n article = html.unescape(article) # replace special chars\n article = re.sub(r\"<[^>]+>\", \"\", article) # remove html tags\n article = \"\".join([c for c in article if c.isalnum()]) # extract alphanum only\n return article\n\n # Check that a knowledge base with the correct name exists\n kb = table_api_call(\n instance=instance,\n table=\"kb_knowledge_base\",\n params={\"sysparm_query\": f\"title={kb_name}\"},\n )[\"result\"]\n\n # The KB exists\n if len(kb) == 1:\n requires_install = False\n requires_delete = False\n\n # Check that the KB has the correct settings\n if disable_commenting and (\n kb[0][\"disable_commenting\"] != \"true\"\n or kb[0][\"disable_mark_as_helpful\"] != \"true\"\n or kb[0][\"disable_rating\"] != \"true\"\n or kb[0][\"disable_suggesting\"] != \"true\"\n or kb[0][\"disable_category_editing\"] != \"true\"","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.utils","uri":"program://WorkArena/module/src.browsergym.workarena.utils#L1-L99","kind":"module","name":"src.browsergym.workarena.utils","path":"src/browsergym/workarena/utils.py","language":"python","start_line":1,"end_line":99,"context_start_line":1,"context_end_line":99,"code":"\"\"\"\nGeneral utiilty functions\n\n\"\"\"\n\nimport playwright.sync_api\n\nfrom browsergym.workarena.instance import SNowInstance\n\nfrom urllib import parse\n\n\ndef impersonate_user(username: str, page: playwright.sync_api.Page):\n \"\"\"\n Impersonate a user in the ServiceNow interface\n\n Parameters:\n -----------\n username: str\n The username of the user to impersonate\n page: playwright.sync_api.Page\n The page instance to use for the impersonation (you must be logged in as admin)\n\n Notes:\n ------\n * If you provide a username that matches to multiple users (e.g., a partial one), the first one will be selected\n\n \"\"\"\n page.locator(\".header-avatar-button\").click()\n page.get_by_role(\"menuitem\", name=\"Impersonate user\").click()\n page.locator(\"input.now-typeahead-native-input\").click()\n page.locator(\"input.now-typeahead-native-input\").fill(username)\n page.locator(\"seismic-hoist\").get_by_role(\"option\", name=username).first.click()\n with page.expect_navigation():\n page.get_by_role(\"button\", name=\"Impersonate user\").click()\n\n # If there is the analytics dialog, close it\n page.wait_for_load_state(\"networkidle\")\n if page.get_by_label(\"Close dialog\").count() > 0:\n page.keyboard.press(\"Escape\")\n\n\ndef ui_login(instance: SNowInstance, page: playwright.sync_api.Page):\n \"\"\"\n Log into the instance via the UI\n\n Parameters:\n -----------\n instance:\n The instance to log into\n page:\n The page instance to use for the UI login\n\n \"\"\"\n (snow_username, snow_password) = instance.snow_credentials\n\n # Navigate to instance\n page.goto(instance.snow_url)\n\n # If login is required, we'll be redirected to the login page\n if \"log in | servicenow\" in page.title().lower():\n page.get_by_label(\"User name\").fill(snow_username)\n page.get_by_label(\"Password\", exact=True).fill(snow_password)\n with page.expect_navigation():\n page.get_by_role(\"button\", name=\"Log in\").click()\n\n # Check if we have been returned to the login page (appends /welcome.do)\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n if current_url.path.endswith(\"/welcome.do\"):\n raise RuntimeError(\"Login failed. Check credentials.\")\n\n\ndef url_login(instance: SNowInstance, page: playwright.sync_api.Page):\n \"\"\"\n Log into the instance via the URL\n\n Parameters:\n -----------\n instance:\n The instance to log into\n page:\n The page instance to use for the URL login\n\n \"\"\"\n (snow_username, snow_password) = instance.snow_credentials\n\n # Encode special characters\n snow_username = parse.quote(snow_username)\n snow_password = parse.quote(snow_password)\n\n # Log in via URL\n page.goto(\n f\"{instance.snow_url}/login.do?user_name={snow_username}&user_password={snow_password}&sys_action=sysverb_login\"\n )\n\n # Check if we have been returned to the login page\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n if \"login.do\" in current_url.path:\n raise RuntimeError(\"Login failed. Check credentials and make sure to have run installer.\")","source_hash":"983e91a95b9afa6d7e98a3354461a5504bb5b3aba7d1923d6b96533cdee0d616","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.utils.impersonate_user","uri":"program://WorkArena/function/src.browsergym.workarena.utils.impersonate_user#L13-L40","kind":"function","name":"impersonate_user","path":"src/browsergym/workarena/utils.py","language":"python","start_line":13,"end_line":40,"context_start_line":1,"context_end_line":60,"code":"\"\"\"\nGeneral utiilty functions\n\n\"\"\"\n\nimport playwright.sync_api\n\nfrom browsergym.workarena.instance import SNowInstance\n\nfrom urllib import parse\n\n\ndef impersonate_user(username: str, page: playwright.sync_api.Page):\n \"\"\"\n Impersonate a user in the ServiceNow interface\n\n Parameters:\n -----------\n username: str\n The username of the user to impersonate\n page: playwright.sync_api.Page\n The page instance to use for the impersonation (you must be logged in as admin)\n\n Notes:\n ------\n * If you provide a username that matches to multiple users (e.g., a partial one), the first one will be selected\n\n \"\"\"\n page.locator(\".header-avatar-button\").click()\n page.get_by_role(\"menuitem\", name=\"Impersonate user\").click()\n page.locator(\"input.now-typeahead-native-input\").click()\n page.locator(\"input.now-typeahead-native-input\").fill(username)\n page.locator(\"seismic-hoist\").get_by_role(\"option\", name=username).first.click()\n with page.expect_navigation():\n page.get_by_role(\"button\", name=\"Impersonate user\").click()\n\n # If there is the analytics dialog, close it\n page.wait_for_load_state(\"networkidle\")\n if page.get_by_label(\"Close dialog\").count() > 0:\n page.keyboard.press(\"Escape\")\n\n\ndef ui_login(instance: SNowInstance, page: playwright.sync_api.Page):\n \"\"\"\n Log into the instance via the UI\n\n Parameters:\n -----------\n instance:\n The instance to log into\n page:\n The page instance to use for the UI login\n\n \"\"\"\n (snow_username, snow_password) = instance.snow_credentials\n\n # Navigate to instance\n page.goto(instance.snow_url)\n\n # If login is required, we'll be redirected to the login page","source_hash":"983e91a95b9afa6d7e98a3354461a5504bb5b3aba7d1923d6b96533cdee0d616","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.utils.ui_login","uri":"program://WorkArena/function/src.browsergym.workarena.utils.ui_login#L43-L70","kind":"function","name":"ui_login","path":"src/browsergym/workarena/utils.py","language":"python","start_line":43,"end_line":70,"context_start_line":23,"context_end_line":90,"code":"\n Notes:\n ------\n * If you provide a username that matches to multiple users (e.g., a partial one), the first one will be selected\n\n \"\"\"\n page.locator(\".header-avatar-button\").click()\n page.get_by_role(\"menuitem\", name=\"Impersonate user\").click()\n page.locator(\"input.now-typeahead-native-input\").click()\n page.locator(\"input.now-typeahead-native-input\").fill(username)\n page.locator(\"seismic-hoist\").get_by_role(\"option\", name=username).first.click()\n with page.expect_navigation():\n page.get_by_role(\"button\", name=\"Impersonate user\").click()\n\n # If there is the analytics dialog, close it\n page.wait_for_load_state(\"networkidle\")\n if page.get_by_label(\"Close dialog\").count() > 0:\n page.keyboard.press(\"Escape\")\n\n\ndef ui_login(instance: SNowInstance, page: playwright.sync_api.Page):\n \"\"\"\n Log into the instance via the UI\n\n Parameters:\n -----------\n instance:\n The instance to log into\n page:\n The page instance to use for the UI login\n\n \"\"\"\n (snow_username, snow_password) = instance.snow_credentials\n\n # Navigate to instance\n page.goto(instance.snow_url)\n\n # If login is required, we'll be redirected to the login page\n if \"log in | servicenow\" in page.title().lower():\n page.get_by_label(\"User name\").fill(snow_username)\n page.get_by_label(\"Password\", exact=True).fill(snow_password)\n with page.expect_navigation():\n page.get_by_role(\"button\", name=\"Log in\").click()\n\n # Check if we have been returned to the login page (appends /welcome.do)\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n if current_url.path.endswith(\"/welcome.do\"):\n raise RuntimeError(\"Login failed. Check credentials.\")\n\n\ndef url_login(instance: SNowInstance, page: playwright.sync_api.Page):\n \"\"\"\n Log into the instance via the URL\n\n Parameters:\n -----------\n instance:\n The instance to log into\n page:\n The page instance to use for the URL login\n\n \"\"\"\n (snow_username, snow_password) = instance.snow_credentials\n\n # Encode special characters\n snow_username = parse.quote(snow_username)\n snow_password = parse.quote(snow_password)\n","source_hash":"983e91a95b9afa6d7e98a3354461a5504bb5b3aba7d1923d6b96533cdee0d616","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.utils.url_login","uri":"program://WorkArena/function/src.browsergym.workarena.utils.url_login#L73-L99","kind":"function","name":"url_login","path":"src/browsergym/workarena/utils.py","language":"python","start_line":73,"end_line":99,"context_start_line":53,"context_end_line":99,"code":"\n \"\"\"\n (snow_username, snow_password) = instance.snow_credentials\n\n # Navigate to instance\n page.goto(instance.snow_url)\n\n # If login is required, we'll be redirected to the login page\n if \"log in | servicenow\" in page.title().lower():\n page.get_by_label(\"User name\").fill(snow_username)\n page.get_by_label(\"Password\", exact=True).fill(snow_password)\n with page.expect_navigation():\n page.get_by_role(\"button\", name=\"Log in\").click()\n\n # Check if we have been returned to the login page (appends /welcome.do)\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n if current_url.path.endswith(\"/welcome.do\"):\n raise RuntimeError(\"Login failed. Check credentials.\")\n\n\ndef url_login(instance: SNowInstance, page: playwright.sync_api.Page):\n \"\"\"\n Log into the instance via the URL\n\n Parameters:\n -----------\n instance:\n The instance to log into\n page:\n The page instance to use for the URL login\n\n \"\"\"\n (snow_username, snow_password) = instance.snow_credentials\n\n # Encode special characters\n snow_username = parse.quote(snow_username)\n snow_password = parse.quote(snow_password)\n\n # Log in via URL\n page.goto(\n f\"{instance.snow_url}/login.do?user_name={snow_username}&user_password={snow_password}&sys_action=sysverb_login\"\n )\n\n # Check if we have been returned to the login page\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n if \"login.do\" in current_url.path:\n raise RuntimeError(\"Login failed. Check credentials and make sure to have run installer.\")","source_hash":"983e91a95b9afa6d7e98a3354461a5504bb5b3aba7d1923d6b96533cdee0d616","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool","uri":"program://WorkArena/module/src.browsergym.workarena.human_eval.tool#L1-L366","kind":"module","name":"src.browsergym.workarena.human_eval.tool","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":1,"end_line":366,"context_start_line":1,"context_end_line":366,"code":"\"\"\"\nWorkArena Human Evaluation Tool\n\nKnown issues:\n * Blocking page interaction: We can't block loading until validation is done because some validation\n functions require the page to be loaded. This means the user might act\n while validation is ongoing. However, they would need to be very quick to\n cause issues.\n\n\"\"\"\n\nimport argparse\nimport json\nimport logging\nimport os\nimport random\nimport tenacity\n\nfrom time import sleep, time\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS, get_all_tasks_humans\nfrom browsergym.workarena.tasks.compositional.base import CompositionalTask\n\n\nlogging.basicConfig(level=logging.INFO)\n\n\n# All available task classes by name\nTASKS = {task.__name__: task for task in ALL_WORKARENA_TASKS}\n\n\ndef get_servicenow_pages(context):\n return [p for p in context.pages if \"service-now\" in p.url]\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validation_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.NEED_VALIDATION !== 'undefined' && window.NEED_VALIDATION\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef reset_validation_flag(context):\n try:\n for page in get_servicenow_pages(context):\n for f in page.frames:\n f.evaluate(\"window.NEED_VALIDATION = 0;\")\n except Exception as e:\n print(e, \"Failed to reset validation flag\") # Worst case we'll just keep validating\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef abandon_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.HUMAN_ABANDON !== 'undefined' && window.HUMAN_ABANDON\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef infeasible_flag_activated(context):\n infeasible = any(\n f.evaluate(\"typeof window.HUMAN_INFEASIBLE !== 'undefined'\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n reason = None\n if infeasible:\n for p in get_servicenow_pages(context):\n try:\n reason = p.evaluate(\"document.getElementById('reasonTextBox').value\")\n break\n except:\n pass\n\n return infeasible, reason\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('taskStatusDiv').innerText = '{msg}'\")\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_progress_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('progressDiv').innerText = '{msg}'\")\n\n\ndef log_result(annotator_info: dict, task_info: dict, metrics: dict, path: str):\n # Read existing log\n if os.path.exists(path):\n log = json.load(open(path, \"r\"))\n else:\n log = []\n\n # Append log\n log.append({\"annotator_info\": annotator_info, \"task_info\": task_info, \"metrics\": metrics})\n json.dump(log, open(path, \"w\"))\n\n logging.info(f\"Logged result: {task_info} -- {metrics}\")\n\n\ndef task_already_evaluated(path: str, annotator_info: dict, task_info: dict):\n if not os.path.exists(path):\n return False\n\n log = json.load(open(path, \"r\"))\n for entry in log:\n if entry[\"annotator_info\"] == annotator_info and entry[\"task_info\"] == task_info:\n return True\n\n return False\n\n\ndef setup_environment(task_info: dict):\n task_cls = TASKS[task_info[\"task_name\"]]\n env = BrowserEnv(\n task_entrypoint=task_cls,\n headless=False,\n )\n info, _ = env.reset(seed=task_info[\"task_seed\"])\n\n # Inject human-eval helper scripts (reload to apply)\n env.task.page.context.add_init_script(\"window.NEED_VALIDATION = 1;\")\n env.task.page.context.add_init_script(\n path=os.path.join(os.path.dirname(__file__), \"console.js\")\n )\n env.task.page.reload()\n\n # Patch the chat messages so that the human posts as the bot\n env.chat.page.evaluate(\n \"\"\"\n (function() {\n let old;\n\n // Function to wait for addChatMessage to be defined\n function waitForAddChatMessage() {\n if (typeof addChatMessage !== 'undefined') {\n // Save the original 'addChatMessage' function to 'old'\n if (typeof old === 'undefined') {\n old = new Function('return ' + addChatMessage.toString())();\n }\n\n // Redefine 'addChatMessage' to wrap the original function\n addChatMessage = function(role, timeString, msg) {\n if (role === 'user') {\n role = 'assistant'; // Swap role from 'user' to 'assistant'\n }\n else if (role === 'assistant') {\n role = 'user'; // Swap role from 'assistant' to 'user'\n }\n old(role, timeString, msg); // Call the original function\n };\n } else {\n // Retry after a short delay\n setTimeout(waitForAddChatMessage, 100);\n }\n }\n\n // Start waiting for addChatMessage to be defined\n waitForAddChatMessage();\n })();\n \"\"\"\n )\n\n # Mark all chat messages as patched so that we don't patch them again\n for m in env.chat.messages:\n m[\"patched\"] = True\n\n return env\n\n\ndef load_curriculum(path):\n \"\"\"\n Load curriculum from a file or generate a random one.\n\n Parameters:\n -----------\n path: str\n Path to the curriculum file. If set to \"random\", a random curriculum will be generated.\n\n Returns:\n --------\n curriculum: list\n\n \"\"\"\n if path == \"random\":\n logging.info(\"Generating random curriculum\")\n all_tasks = get_all_tasks_humans(filter=\"l2\") + get_all_tasks_humans(filter=\"l3\")\n random.shuffle(all_tasks)\n curriculum = [{\"task_name\": x[0].__name__, \"task_seed\": x[1]} for x in all_tasks]\n else:\n logging.info(f\"Loading curriculum from {path}\")\n with open(path, \"r\") as f:\n curriculum = [\n {\"task_name\": l.split(\",\")[0].strip(), \"task_seed\": int(l.split(\",\")[1].strip())}\n for l in f.readlines()\n if len(l.strip()) > 0\n ]\n\n return curriculum\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validate_solution(env):\n infos = []\n messages = []\n for p in env.context.pages:\n reward, stop, message, info = env.task.validate(p, env.chat.messages)\n\n # If a terminal condition is encountered, return it.\n if reward == 1 or (reward == 0 and stop):\n return reward, stop, message, info\n\n infos.append(info)\n messages.append(message)\n\n return reward, stop, \", \".join(messages), {\"message\": \", \".join([i[\"message\"] for i in infos])}\n\n\ndef main():\n\n # Initialize the argument parser\n parser = argparse.ArgumentParser(\n description=\"Get annotator info and log path from command line arguments.\"\n )\n\n # Define the command line arguments\n parser.add_argument(\"--email\", type=str, required=True, help=\"Email of the annotator\")\n parser.add_argument(\n \"--curriculum\",\n type=str,\n required=True,\n help='Path to the curriculum file (optional: use \"random\" for a random one)',\n )\n parser.add_argument(\n \"--log\",\n type=str,\n required=False,\n default=\"human_eval_log.json\",\n help=\"Path to the log file\",\n )\n parser.add_argument(\"--reset-log\", action=\"store_true\", help=\"Reset the log file\")\n\n # Parse the arguments\n args = parser.parse_args()\n\n annotator_info = {\"email\": args.email}\n logging.info(f\"Annotator info: {annotator_info}\")\n\n # Reset the log file if requested\n logging.info(f\"Log file: {args.log}\")\n if args.reset_log:\n logging.info(\"Resetting log file\")\n json.dump([], open(args.log, \"w\"))\n\n # Loop over the curriculum\n curriculum = load_curriculum(args.curriculum)\n logging.info(f\"Starting evaluation for {len(curriculum)} tasks\")\n for i, task_info in enumerate(curriculum):\n\n if task_already_evaluated(args.log, annotator_info, task_info):\n logging.info(f\"Task {task_info} already evaluated. Skipping.\")\n continue\n\n # Setup the environment\n logging.info(f\"Setting up environment for task {task_info}\")\n env = setup_environment(task_info)\n\n # Game loop\n logging.info(f\"Starting evaluation for task {task_info}\")\n start_time = time()\n end = False\n success = False\n prev_chat_len = len(env.chat.messages)\n while True:\n human_console_set_progress_status(\n f\"Task {i + 1} / {len(curriculum)} --- Elapsed: {round(time() - start_time, 2)} sec.\",\n env.context,\n )\n\n # Event: Human marked task as infeasible\n infeasible, infeasible_reason = infeasible_flag_activated(env.context)\n if infeasible and not any([m[\"role\"] == \"infeasible\" for m in env.chat.messages]):\n logging.info(f\"Human marked task as infeasible. Reason: {infeasible_reason}\")\n human_console_set_status(\"Task marked as infeasible.\", env.context)\n env.chat.messages.append({\"role\": \"infeasible\", \"message\": infeasible_reason})\n # TODO: There is a small glitch where if the user changes their message after,\n # the new infeasible message will be saved instead of the initial one that\n # was added to the chat messages. We can't stop after infeasible has been\n # declared.\n\n # Event: Validation is required\n if validation_flag_activated(env.context) or len(env.chat.messages) != prev_chat_len:\n human_console_set_status(\"Validation in progress...\", env.context)\n\n # Patch all chat messages\n for m in env.chat.messages:\n if not m.get(\"patched\", False):\n if m[\"role\"] == \"user\":\n m[\"role\"] = \"assistant\"\n elif m[\"role\"] == \"assistant\":\n m[\"role\"] = \"user\"\n m[\"patched\"] = True\n\n reward, stop, message, info = validate_solution(env)\n logging.info(f\"Validation: {info} -- reward: {reward} -- stop: {stop}\")\n\n if reward == 1:\n human_console_set_status(\"Success!\", env.context)\n end = True\n success = True\n else:\n if not end: # If we're not already stopping for another reason\n if stop:\n human_console_set_status(\n \"Task not completed. Stop required.\", env.context\n )\n end = True\n success = False\n else:\n human_console_set_status(\"Task not completed. Keep going.\", env.context)\n\n prev_chat_len = len(env.chat.messages)\n reset_validation_flag(env.context)\n\n # Event: Human abandoned task\n if abandon_flag_activated(env.context):\n end = True\n success = False\n human_console_set_status(\"Task abandoned by human.\", env.context)\n\n # Event: Task is finished\n if end:\n log_result(\n path=args.log,\n annotator_info=annotator_info,\n task_info=task_info,\n metrics={\n \"duration\": time() - start_time,\n \"success\": success,\n \"infeasible\": infeasible_reason if infeasible else None,\n \"abandoned\": abandon_flag_activated(env.context),\n \"chat_messages\": env.chat.messages,\n },\n )\n sleep(3) # Sleep so human has time to read status before it closes\n break\n\n sleep(0.1)\n\n human_console_set_status(\"Cleaning environment. This may take a while...\", env.context)\n env.close()\n logging.info(f\"Finished evaluation for task {task_info}\")\n\n\nif __name__ == \"__main__\":\n main()","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.get_servicenow_pages","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.get_servicenow_pages#L33-L34","kind":"function","name":"get_servicenow_pages","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":33,"end_line":34,"context_start_line":13,"context_end_line":54,"code":"import json\nimport logging\nimport os\nimport random\nimport tenacity\n\nfrom time import sleep, time\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS, get_all_tasks_humans\nfrom browsergym.workarena.tasks.compositional.base import CompositionalTask\n\n\nlogging.basicConfig(level=logging.INFO)\n\n\n# All available task classes by name\nTASKS = {task.__name__: task for task in ALL_WORKARENA_TASKS}\n\n\ndef get_servicenow_pages(context):\n return [p for p in context.pages if \"service-now\" in p.url]\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validation_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.NEED_VALIDATION !== 'undefined' && window.NEED_VALIDATION\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef reset_validation_flag(context):\n try:\n for page in get_servicenow_pages(context):\n for f in page.frames:\n f.evaluate(\"window.NEED_VALIDATION = 0;\")\n except Exception as e:\n print(e, \"Failed to reset validation flag\") # Worst case we'll just keep validating\n","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.validation_flag_activated","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.validation_flag_activated#L38-L43","kind":"function","name":"validation_flag_activated","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":38,"end_line":43,"context_start_line":18,"context_end_line":63,"code":"\nfrom time import sleep, time\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS, get_all_tasks_humans\nfrom browsergym.workarena.tasks.compositional.base import CompositionalTask\n\n\nlogging.basicConfig(level=logging.INFO)\n\n\n# All available task classes by name\nTASKS = {task.__name__: task for task in ALL_WORKARENA_TASKS}\n\n\ndef get_servicenow_pages(context):\n return [p for p in context.pages if \"service-now\" in p.url]\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validation_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.NEED_VALIDATION !== 'undefined' && window.NEED_VALIDATION\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef reset_validation_flag(context):\n try:\n for page in get_servicenow_pages(context):\n for f in page.frames:\n f.evaluate(\"window.NEED_VALIDATION = 0;\")\n except Exception as e:\n print(e, \"Failed to reset validation flag\") # Worst case we'll just keep validating\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef abandon_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.HUMAN_ABANDON !== 'undefined' && window.HUMAN_ABANDON\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.reset_validation_flag","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.reset_validation_flag#L47-L53","kind":"function","name":"reset_validation_flag","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":47,"end_line":53,"context_start_line":27,"context_end_line":73,"code":"\n\n# All available task classes by name\nTASKS = {task.__name__: task for task in ALL_WORKARENA_TASKS}\n\n\ndef get_servicenow_pages(context):\n return [p for p in context.pages if \"service-now\" in p.url]\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validation_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.NEED_VALIDATION !== 'undefined' && window.NEED_VALIDATION\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef reset_validation_flag(context):\n try:\n for page in get_servicenow_pages(context):\n for f in page.frames:\n f.evaluate(\"window.NEED_VALIDATION = 0;\")\n except Exception as e:\n print(e, \"Failed to reset validation flag\") # Worst case we'll just keep validating\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef abandon_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.HUMAN_ABANDON !== 'undefined' && window.HUMAN_ABANDON\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef infeasible_flag_activated(context):\n infeasible = any(\n f.evaluate(\"typeof window.HUMAN_INFEASIBLE !== 'undefined'\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n reason = None","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.abandon_flag_activated","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.abandon_flag_activated#L57-L62","kind":"function","name":"abandon_flag_activated","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":57,"end_line":62,"context_start_line":37,"context_end_line":82,"code":"@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validation_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.NEED_VALIDATION !== 'undefined' && window.NEED_VALIDATION\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef reset_validation_flag(context):\n try:\n for page in get_servicenow_pages(context):\n for f in page.frames:\n f.evaluate(\"window.NEED_VALIDATION = 0;\")\n except Exception as e:\n print(e, \"Failed to reset validation flag\") # Worst case we'll just keep validating\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef abandon_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.HUMAN_ABANDON !== 'undefined' && window.HUMAN_ABANDON\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef infeasible_flag_activated(context):\n infeasible = any(\n f.evaluate(\"typeof window.HUMAN_INFEASIBLE !== 'undefined'\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n reason = None\n if infeasible:\n for p in get_servicenow_pages(context):\n try:\n reason = p.evaluate(\"document.getElementById('reasonTextBox').value\")\n break\n except:\n pass\n\n return infeasible, reason","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.infeasible_flag_activated","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.infeasible_flag_activated#L66-L82","kind":"function","name":"infeasible_flag_activated","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":66,"end_line":82,"context_start_line":46,"context_end_line":102,"code":"@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef reset_validation_flag(context):\n try:\n for page in get_servicenow_pages(context):\n for f in page.frames:\n f.evaluate(\"window.NEED_VALIDATION = 0;\")\n except Exception as e:\n print(e, \"Failed to reset validation flag\") # Worst case we'll just keep validating\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef abandon_flag_activated(context):\n return any(\n f.evaluate(\"typeof window.HUMAN_ABANDON !== 'undefined' && window.HUMAN_ABANDON\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef infeasible_flag_activated(context):\n infeasible = any(\n f.evaluate(\"typeof window.HUMAN_INFEASIBLE !== 'undefined'\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n reason = None\n if infeasible:\n for p in get_servicenow_pages(context):\n try:\n reason = p.evaluate(\"document.getElementById('reasonTextBox').value\")\n break\n except:\n pass\n\n return infeasible, reason\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('taskStatusDiv').innerText = '{msg}'\")\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_progress_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('progressDiv').innerText = '{msg}'\")\n\n\ndef log_result(annotator_info: dict, task_info: dict, metrics: dict, path: str):\n # Read existing log\n if os.path.exists(path):\n log = json.load(open(path, \"r\"))\n else:\n log = []","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.human_console_set_status","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.human_console_set_status#L86-L88","kind":"function","name":"human_console_set_status","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":86,"end_line":88,"context_start_line":66,"context_end_line":108,"code":"def infeasible_flag_activated(context):\n infeasible = any(\n f.evaluate(\"typeof window.HUMAN_INFEASIBLE !== 'undefined'\")\n for p in get_servicenow_pages(context)\n for f in p.frames\n )\n\n reason = None\n if infeasible:\n for p in get_servicenow_pages(context):\n try:\n reason = p.evaluate(\"document.getElementById('reasonTextBox').value\")\n break\n except:\n pass\n\n return infeasible, reason\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('taskStatusDiv').innerText = '{msg}'\")\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_progress_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('progressDiv').innerText = '{msg}'\")\n\n\ndef log_result(annotator_info: dict, task_info: dict, metrics: dict, path: str):\n # Read existing log\n if os.path.exists(path):\n log = json.load(open(path, \"r\"))\n else:\n log = []\n\n # Append log\n log.append({\"annotator_info\": annotator_info, \"task_info\": task_info, \"metrics\": metrics})\n json.dump(log, open(path, \"w\"))\n\n logging.info(f\"Logged result: {task_info} -- {metrics}\")","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.human_console_set_progress_status","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.human_console_set_progress_status#L92-L94","kind":"function","name":"human_console_set_progress_status","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":92,"end_line":94,"context_start_line":72,"context_end_line":114,"code":"\n reason = None\n if infeasible:\n for p in get_servicenow_pages(context):\n try:\n reason = p.evaluate(\"document.getElementById('reasonTextBox').value\")\n break\n except:\n pass\n\n return infeasible, reason\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('taskStatusDiv').innerText = '{msg}'\")\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_progress_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('progressDiv').innerText = '{msg}'\")\n\n\ndef log_result(annotator_info: dict, task_info: dict, metrics: dict, path: str):\n # Read existing log\n if os.path.exists(path):\n log = json.load(open(path, \"r\"))\n else:\n log = []\n\n # Append log\n log.append({\"annotator_info\": annotator_info, \"task_info\": task_info, \"metrics\": metrics})\n json.dump(log, open(path, \"w\"))\n\n logging.info(f\"Logged result: {task_info} -- {metrics}\")\n\n\ndef task_already_evaluated(path: str, annotator_info: dict, task_info: dict):\n if not os.path.exists(path):\n return False\n","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.log_result","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.log_result#L97-L108","kind":"function","name":"log_result","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":97,"end_line":108,"context_start_line":77,"context_end_line":128,"code":" reason = p.evaluate(\"document.getElementById('reasonTextBox').value\")\n break\n except:\n pass\n\n return infeasible, reason\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('taskStatusDiv').innerText = '{msg}'\")\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_progress_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('progressDiv').innerText = '{msg}'\")\n\n\ndef log_result(annotator_info: dict, task_info: dict, metrics: dict, path: str):\n # Read existing log\n if os.path.exists(path):\n log = json.load(open(path, \"r\"))\n else:\n log = []\n\n # Append log\n log.append({\"annotator_info\": annotator_info, \"task_info\": task_info, \"metrics\": metrics})\n json.dump(log, open(path, \"w\"))\n\n logging.info(f\"Logged result: {task_info} -- {metrics}\")\n\n\ndef task_already_evaluated(path: str, annotator_info: dict, task_info: dict):\n if not os.path.exists(path):\n return False\n\n log = json.load(open(path, \"r\"))\n for entry in log:\n if entry[\"annotator_info\"] == annotator_info and entry[\"task_info\"] == task_info:\n return True\n\n return False\n\n\ndef setup_environment(task_info: dict):\n task_cls = TASKS[task_info[\"task_name\"]]\n env = BrowserEnv(\n task_entrypoint=task_cls,\n headless=False,\n )","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.task_already_evaluated","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.task_already_evaluated#L111-L120","kind":"function","name":"task_already_evaluated","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":111,"end_line":120,"context_start_line":91,"context_end_line":140,"code":"@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef human_console_set_progress_status(msg, context):\n for p in get_servicenow_pages(context):\n p.evaluate(f\"document.getElementById('progressDiv').innerText = '{msg}'\")\n\n\ndef log_result(annotator_info: dict, task_info: dict, metrics: dict, path: str):\n # Read existing log\n if os.path.exists(path):\n log = json.load(open(path, \"r\"))\n else:\n log = []\n\n # Append log\n log.append({\"annotator_info\": annotator_info, \"task_info\": task_info, \"metrics\": metrics})\n json.dump(log, open(path, \"w\"))\n\n logging.info(f\"Logged result: {task_info} -- {metrics}\")\n\n\ndef task_already_evaluated(path: str, annotator_info: dict, task_info: dict):\n if not os.path.exists(path):\n return False\n\n log = json.load(open(path, \"r\"))\n for entry in log:\n if entry[\"annotator_info\"] == annotator_info and entry[\"task_info\"] == task_info:\n return True\n\n return False\n\n\ndef setup_environment(task_info: dict):\n task_cls = TASKS[task_info[\"task_name\"]]\n env = BrowserEnv(\n task_entrypoint=task_cls,\n headless=False,\n )\n info, _ = env.reset(seed=task_info[\"task_seed\"])\n\n # Inject human-eval helper scripts (reload to apply)\n env.task.page.context.add_init_script(\"window.NEED_VALIDATION = 1;\")\n env.task.page.context.add_init_script(\n path=os.path.join(os.path.dirname(__file__), \"console.js\")\n )\n env.task.page.reload()\n\n # Patch the chat messages so that the human posts as the bot\n env.chat.page.evaluate(\n \"\"\"","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.setup_environment","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.setup_environment#L123-L178","kind":"function","name":"setup_environment","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":123,"end_line":178,"context_start_line":103,"context_end_line":198,"code":"\n # Append log\n log.append({\"annotator_info\": annotator_info, \"task_info\": task_info, \"metrics\": metrics})\n json.dump(log, open(path, \"w\"))\n\n logging.info(f\"Logged result: {task_info} -- {metrics}\")\n\n\ndef task_already_evaluated(path: str, annotator_info: dict, task_info: dict):\n if not os.path.exists(path):\n return False\n\n log = json.load(open(path, \"r\"))\n for entry in log:\n if entry[\"annotator_info\"] == annotator_info and entry[\"task_info\"] == task_info:\n return True\n\n return False\n\n\ndef setup_environment(task_info: dict):\n task_cls = TASKS[task_info[\"task_name\"]]\n env = BrowserEnv(\n task_entrypoint=task_cls,\n headless=False,\n )\n info, _ = env.reset(seed=task_info[\"task_seed\"])\n\n # Inject human-eval helper scripts (reload to apply)\n env.task.page.context.add_init_script(\"window.NEED_VALIDATION = 1;\")\n env.task.page.context.add_init_script(\n path=os.path.join(os.path.dirname(__file__), \"console.js\")\n )\n env.task.page.reload()\n\n # Patch the chat messages so that the human posts as the bot\n env.chat.page.evaluate(\n \"\"\"\n (function() {\n let old;\n\n // Function to wait for addChatMessage to be defined\n function waitForAddChatMessage() {\n if (typeof addChatMessage !== 'undefined') {\n // Save the original 'addChatMessage' function to 'old'\n if (typeof old === 'undefined') {\n old = new Function('return ' + addChatMessage.toString())();\n }\n\n // Redefine 'addChatMessage' to wrap the original function\n addChatMessage = function(role, timeString, msg) {\n if (role === 'user') {\n role = 'assistant'; // Swap role from 'user' to 'assistant'\n }\n else if (role === 'assistant') {\n role = 'user'; // Swap role from 'assistant' to 'user'\n }\n old(role, timeString, msg); // Call the original function\n };\n } else {\n // Retry after a short delay\n setTimeout(waitForAddChatMessage, 100);\n }\n }\n\n // Start waiting for addChatMessage to be defined\n waitForAddChatMessage();\n })();\n \"\"\"\n )\n\n # Mark all chat messages as patched so that we don't patch them again\n for m in env.chat.messages:\n m[\"patched\"] = True\n\n return env\n\n\ndef load_curriculum(path):\n \"\"\"\n Load curriculum from a file or generate a random one.\n\n Parameters:\n -----------\n path: str\n Path to the curriculum file. If set to \"random\", a random curriculum will be generated.\n\n Returns:\n --------\n curriculum: list\n\n \"\"\"\n if path == \"random\":\n logging.info(\"Generating random curriculum\")\n all_tasks = get_all_tasks_humans(filter=\"l2\") + get_all_tasks_humans(filter=\"l3\")\n random.shuffle(all_tasks)","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.load_curriculum","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.load_curriculum#L181-L209","kind":"function","name":"load_curriculum","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":181,"end_line":209,"context_start_line":161,"context_end_line":229,"code":" };\n } else {\n // Retry after a short delay\n setTimeout(waitForAddChatMessage, 100);\n }\n }\n\n // Start waiting for addChatMessage to be defined\n waitForAddChatMessage();\n })();\n \"\"\"\n )\n\n # Mark all chat messages as patched so that we don't patch them again\n for m in env.chat.messages:\n m[\"patched\"] = True\n\n return env\n\n\ndef load_curriculum(path):\n \"\"\"\n Load curriculum from a file or generate a random one.\n\n Parameters:\n -----------\n path: str\n Path to the curriculum file. If set to \"random\", a random curriculum will be generated.\n\n Returns:\n --------\n curriculum: list\n\n \"\"\"\n if path == \"random\":\n logging.info(\"Generating random curriculum\")\n all_tasks = get_all_tasks_humans(filter=\"l2\") + get_all_tasks_humans(filter=\"l3\")\n random.shuffle(all_tasks)\n curriculum = [{\"task_name\": x[0].__name__, \"task_seed\": x[1]} for x in all_tasks]\n else:\n logging.info(f\"Loading curriculum from {path}\")\n with open(path, \"r\") as f:\n curriculum = [\n {\"task_name\": l.split(\",\")[0].strip(), \"task_seed\": int(l.split(\",\")[1].strip())}\n for l in f.readlines()\n if len(l.strip()) > 0\n ]\n\n return curriculum\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validate_solution(env):\n infos = []\n messages = []\n for p in env.context.pages:\n reward, stop, message, info = env.task.validate(p, env.chat.messages)\n\n # If a terminal condition is encountered, return it.\n if reward == 1 or (reward == 0 and stop):\n return reward, stop, message, info\n\n infos.append(info)\n messages.append(message)\n\n return reward, stop, \", \".join(messages), {\"message\": \", \".join([i[\"message\"] for i in infos])}\n\n\ndef main():","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.validate_solution","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.validate_solution#L213-L226","kind":"function","name":"validate_solution","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":213,"end_line":226,"context_start_line":193,"context_end_line":246,"code":"\n \"\"\"\n if path == \"random\":\n logging.info(\"Generating random curriculum\")\n all_tasks = get_all_tasks_humans(filter=\"l2\") + get_all_tasks_humans(filter=\"l3\")\n random.shuffle(all_tasks)\n curriculum = [{\"task_name\": x[0].__name__, \"task_seed\": x[1]} for x in all_tasks]\n else:\n logging.info(f\"Loading curriculum from {path}\")\n with open(path, \"r\") as f:\n curriculum = [\n {\"task_name\": l.split(\",\")[0].strip(), \"task_seed\": int(l.split(\",\")[1].strip())}\n for l in f.readlines()\n if len(l.strip()) > 0\n ]\n\n return curriculum\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validate_solution(env):\n infos = []\n messages = []\n for p in env.context.pages:\n reward, stop, message, info = env.task.validate(p, env.chat.messages)\n\n # If a terminal condition is encountered, return it.\n if reward == 1 or (reward == 0 and stop):\n return reward, stop, message, info\n\n infos.append(info)\n messages.append(message)\n\n return reward, stop, \", \".join(messages), {\"message\": \", \".join([i[\"message\"] for i in infos])}\n\n\ndef main():\n\n # Initialize the argument parser\n parser = argparse.ArgumentParser(\n description=\"Get annotator info and log path from command line arguments.\"\n )\n\n # Define the command line arguments\n parser.add_argument(\"--email\", type=str, required=True, help=\"Email of the annotator\")\n parser.add_argument(\n \"--curriculum\",\n type=str,\n required=True,\n help='Path to the curriculum file (optional: use \"random\" for a random one)',\n )\n parser.add_argument(\n \"--log\",\n type=str,","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.human_eval.tool.main","uri":"program://WorkArena/function/src.browsergym.workarena.human_eval.tool.main#L229-L362","kind":"function","name":"main","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":229,"end_line":362,"context_start_line":209,"context_end_line":366,"code":" return curriculum\n\n\n@tenacity.retry(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_attempt(5), reraise=True)\ndef validate_solution(env):\n infos = []\n messages = []\n for p in env.context.pages:\n reward, stop, message, info = env.task.validate(p, env.chat.messages)\n\n # If a terminal condition is encountered, return it.\n if reward == 1 or (reward == 0 and stop):\n return reward, stop, message, info\n\n infos.append(info)\n messages.append(message)\n\n return reward, stop, \", \".join(messages), {\"message\": \", \".join([i[\"message\"] for i in infos])}\n\n\ndef main():\n\n # Initialize the argument parser\n parser = argparse.ArgumentParser(\n description=\"Get annotator info and log path from command line arguments.\"\n )\n\n # Define the command line arguments\n parser.add_argument(\"--email\", type=str, required=True, help=\"Email of the annotator\")\n parser.add_argument(\n \"--curriculum\",\n type=str,\n required=True,\n help='Path to the curriculum file (optional: use \"random\" for a random one)',\n )\n parser.add_argument(\n \"--log\",\n type=str,\n required=False,\n default=\"human_eval_log.json\",\n help=\"Path to the log file\",\n )\n parser.add_argument(\"--reset-log\", action=\"store_true\", help=\"Reset the log file\")\n\n # Parse the arguments\n args = parser.parse_args()\n\n annotator_info = {\"email\": args.email}\n logging.info(f\"Annotator info: {annotator_info}\")\n\n # Reset the log file if requested\n logging.info(f\"Log file: {args.log}\")\n if args.reset_log:\n logging.info(\"Resetting log file\")\n json.dump([], open(args.log, \"w\"))\n\n # Loop over the curriculum\n curriculum = load_curriculum(args.curriculum)\n logging.info(f\"Starting evaluation for {len(curriculum)} tasks\")\n for i, task_info in enumerate(curriculum):\n\n if task_already_evaluated(args.log, annotator_info, task_info):\n logging.info(f\"Task {task_info} already evaluated. Skipping.\")\n continue\n\n # Setup the environment\n logging.info(f\"Setting up environment for task {task_info}\")\n env = setup_environment(task_info)\n\n # Game loop\n logging.info(f\"Starting evaluation for task {task_info}\")\n start_time = time()\n end = False\n success = False\n prev_chat_len = len(env.chat.messages)\n while True:\n human_console_set_progress_status(\n f\"Task {i + 1} / {len(curriculum)} --- Elapsed: {round(time() - start_time, 2)} sec.\",\n env.context,\n )\n\n # Event: Human marked task as infeasible\n infeasible, infeasible_reason = infeasible_flag_activated(env.context)\n if infeasible and not any([m[\"role\"] == \"infeasible\" for m in env.chat.messages]):\n logging.info(f\"Human marked task as infeasible. Reason: {infeasible_reason}\")\n human_console_set_status(\"Task marked as infeasible.\", env.context)\n env.chat.messages.append({\"role\": \"infeasible\", \"message\": infeasible_reason})\n # TODO: There is a small glitch where if the user changes their message after,\n # the new infeasible message will be saved instead of the initial one that\n # was added to the chat messages. We can't stop after infeasible has been\n # declared.\n\n # Event: Validation is required\n if validation_flag_activated(env.context) or len(env.chat.messages) != prev_chat_len:\n human_console_set_status(\"Validation in progress...\", env.context)\n\n # Patch all chat messages\n for m in env.chat.messages:\n if not m.get(\"patched\", False):\n if m[\"role\"] == \"user\":\n m[\"role\"] = \"assistant\"\n elif m[\"role\"] == \"assistant\":\n m[\"role\"] = \"user\"\n m[\"patched\"] = True\n\n reward, stop, message, info = validate_solution(env)\n logging.info(f\"Validation: {info} -- reward: {reward} -- stop: {stop}\")\n\n if reward == 1:\n human_console_set_status(\"Success!\", env.context)\n end = True\n success = True\n else:\n if not end: # If we're not already stopping for another reason\n if stop:\n human_console_set_status(\n \"Task not completed. Stop required.\", env.context\n )\n end = True\n success = False\n else:\n human_console_set_status(\"Task not completed. Keep going.\", env.context)\n\n prev_chat_len = len(env.chat.messages)\n reset_validation_flag(env.context)\n\n # Event: Human abandoned task\n if abandon_flag_activated(env.context):\n end = True\n success = False\n human_console_set_status(\"Task abandoned by human.\", env.context)\n\n # Event: Task is finished\n if end:\n log_result(\n path=args.log,\n annotator_info=annotator_info,\n task_info=task_info,\n metrics={\n \"duration\": time() - start_time,\n \"success\": success,\n \"infeasible\": infeasible_reason if infeasible else None,\n \"abandoned\": abandon_flag_activated(env.context),\n \"chat_messages\": env.chat.messages,\n },\n )\n sleep(3) # Sleep so human has time to read status before it closes\n break\n\n sleep(0.1)\n\n human_console_set_status(\"Cleaning environment. This may take a while...\", env.context)\n env.close()\n logging.info(f\"Finished evaluation for task {task_info}\")\n\n\nif __name__ == \"__main__\":\n main()","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.base#L1-L202","kind":"module","name":"src.browsergym.workarena.tasks.base","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":1,"end_line":202,"context_start_line":1,"context_end_line":202,"code":"\"\"\"\nA bunch of base classes\n\n\"\"\"\n\nimport logging\n\nimport numpy as np\nimport playwright.sync_api\n\nfrom abc import ABC, abstractmethod\nfrom copy import deepcopy\nfrom typing import List, Optional, Tuple\nfrom uuid import uuid4\nfrom urllib import parse\n\nfrom browsergym.core.task import AbstractBrowserTask\nfrom ..api.user import create_user\nfrom ..api.utils import table_api_call\nfrom ..config import SNOW_BROWSER_TIMEOUT, SNOW_JS_UTILS_FILEPATH\nfrom ..utils import url_login\nfrom ..instance import SNowInstance\n\n\nclass AbstractServiceNowTask(AbstractBrowserTask, ABC):\n \"\"\"\n A base class for tasks that interacts with the ServiceNow instance\n\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n start_rel_url: str,\n instance: SNowInstance = None,\n final_rel_url: Optional[str] = None,\n user_roles: List[str] = [\"admin\"],\n has_description: bool = False,\n ) -> None:\n \"\"\"\n Initialize the task\n\n Parameters:\n -----------\n seed: int\n Random seed\n instance: SNowInstance\n The ServiceNow instance in which the task will be performed\n start_rel_url: str\n The URL for the starting page of the task\n final_rel_url: str (optional)\n The URL for the final page of the task (default: uses the value of base_url)\n user_roles: list[str]\n The roles to assign to the user (default: [\"admin\"])\n has_description: bool\n Whether the task has a description in L3 compositional tasks\n\n \"\"\"\n super().__init__(seed)\n\n # task properties, will be used to set up the browsergym environment\n self.viewport = {\"width\": 1280, \"height\": 720}\n self.slow_mo = 1000 # ms\n self.timeout = 10000 # ms\n\n self.instance = instance if instance is not None else SNowInstance()\n self.start_url = self.instance.snow_url + start_rel_url\n\n if final_rel_url is not None:\n self.final_url = self.instance.snow_url + final_rel_url\n else:\n self.final_url = self.start_url\n self.final_url_ = parse.urlparse(self.final_url)\n\n # Set the task's unique ID\n self.unique_id = str(uuid4())\n # Flag to ensure the task is setup only once\n self.task_is_setup = False\n self.delete_user_on_teardown = False\n self.user_roles = user_roles\n self.has_description = (\n has_description # Whether the task has a description in L3 compositional tasks\n )\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n # Don't call super cheat function because it's not implemented at the base level\n logging.debug(\"Cheat is solving the task\")\n\n def get_init_scripts(self) -> List[str]:\n \"\"\"\n Get the initialization scripts for the task. These are javascript scripts that will be run\n on any page and iframe that is loaded during the task.\n\n \"\"\"\n return []\n\n @classmethod\n def get_task_id(cls):\n # Get the class name and remove the word 'Task' from the end if it exists\n class_name = cls.__name__.replace(\"Task\", \"\")\n # Convert CamelCase to hyphen-separated format\n formatted_name = \"\".join(\n [\"-\" + i.lower() if i.isupper() else i for i in class_name]\n ).lstrip(\"-\")\n return f\"workarena.servicenow.{formatted_name}\"\n\n def setup(self, page: playwright.sync_api.Page, do_start=True) -> tuple[str, dict]:\n \"\"\"\n Set up the task\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The Playwright page object\n do_start: bool\n Whether to start the task or not (including navigating to start page) (default: True)\n\n \"\"\"\n logging.debug(\"Setting up the base task\")\n if self.task_is_setup:\n raise ValueError(\"The task is already setup\")\n\n # Keep the page for client-side validation\n self.page = page\n\n # Set the page timeout\n page.set_default_timeout(SNOW_BROWSER_TIMEOUT)\n\n # Create a new user to run the task if this is the starting task\n if do_start:\n self._base_initial_instance = self.instance\n self._base_user_name, self._base_user_password, self._base_user_sysid = create_user(\n instance=self.instance, user_roles=self.user_roles, random=self.random\n )\n self.instance = deepcopy(self.instance)\n self.instance.snow_credentials = (self._base_user_name, self._base_user_password)\n self.delete_user_on_teardown = True\n # Set the task's unique ID\n self.unique_id = str(uuid4())\n\n # Configure the task\n goal, info = self.setup_goal(page=page)\n\n # Load a few utility functions for init scripts\n page.context.add_init_script(path=SNOW_JS_UTILS_FILEPATH)\n\n # Add the initialization scripts to the page context\n for script in self.get_init_scripts():\n page.context.add_init_script(script)\n\n # Start the task if requested\n if do_start:\n self.start(page)\n\n self.task_is_setup = True\n\n return goal, info\n\n def create_user(self, first_name: str = None, last_name: str = None):\n \"\"\"\n Create a user in the ServiceNow instance\n\n \"\"\"\n\n @abstractmethod\n def setup_goal(self, page: playwright.sync_api.Page) -> tuple[str, dict]:\n \"\"\"\n Setup the task configuration and produce the goal\n\n \"\"\"\n pass\n\n def start(self, page: playwright.sync_api.Page) -> None:\n logging.debug(\"Navigating to task start page\")\n\n # Authenticate\n url_login(\n instance=self.instance,\n page=page,\n )\n\n # Navigate to the task's url\n page.goto(self.start_url)\n\n def teardown(self) -> None:\n \"\"\"\n Clean up after the task\n\n Notes:\n ------\n This method should not make assumptions on the state of the page (e.g., a specific URL).\n\n \"\"\"\n logging.debug(\"Tearing down the task\")\n\n if self.delete_user_on_teardown:\n # Delete the user\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"sys_user/{self._base_user_sysid}\",\n method=\"DELETE\",\n )","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.AbstractServiceNowTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.base.AbstractServiceNowTask#L25-L202","kind":"class","name":"AbstractServiceNowTask","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":25,"end_line":202,"context_start_line":5,"context_end_line":202,"code":"\nimport logging\n\nimport numpy as np\nimport playwright.sync_api\n\nfrom abc import ABC, abstractmethod\nfrom copy import deepcopy\nfrom typing import List, Optional, Tuple\nfrom uuid import uuid4\nfrom urllib import parse\n\nfrom browsergym.core.task import AbstractBrowserTask\nfrom ..api.user import create_user\nfrom ..api.utils import table_api_call\nfrom ..config import SNOW_BROWSER_TIMEOUT, SNOW_JS_UTILS_FILEPATH\nfrom ..utils import url_login\nfrom ..instance import SNowInstance\n\n\nclass AbstractServiceNowTask(AbstractBrowserTask, ABC):\n \"\"\"\n A base class for tasks that interacts with the ServiceNow instance\n\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n start_rel_url: str,\n instance: SNowInstance = None,\n final_rel_url: Optional[str] = None,\n user_roles: List[str] = [\"admin\"],\n has_description: bool = False,\n ) -> None:\n \"\"\"\n Initialize the task\n\n Parameters:\n -----------\n seed: int\n Random seed\n instance: SNowInstance\n The ServiceNow instance in which the task will be performed\n start_rel_url: str\n The URL for the starting page of the task\n final_rel_url: str (optional)\n The URL for the final page of the task (default: uses the value of base_url)\n user_roles: list[str]\n The roles to assign to the user (default: [\"admin\"])\n has_description: bool\n Whether the task has a description in L3 compositional tasks\n\n \"\"\"\n super().__init__(seed)\n\n # task properties, will be used to set up the browsergym environment\n self.viewport = {\"width\": 1280, \"height\": 720}\n self.slow_mo = 1000 # ms\n self.timeout = 10000 # ms\n\n self.instance = instance if instance is not None else SNowInstance()\n self.start_url = self.instance.snow_url + start_rel_url\n\n if final_rel_url is not None:\n self.final_url = self.instance.snow_url + final_rel_url\n else:\n self.final_url = self.start_url\n self.final_url_ = parse.urlparse(self.final_url)\n\n # Set the task's unique ID\n self.unique_id = str(uuid4())\n # Flag to ensure the task is setup only once\n self.task_is_setup = False\n self.delete_user_on_teardown = False\n self.user_roles = user_roles\n self.has_description = (\n has_description # Whether the task has a description in L3 compositional tasks\n )\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n # Don't call super cheat function because it's not implemented at the base level\n logging.debug(\"Cheat is solving the task\")\n\n def get_init_scripts(self) -> List[str]:\n \"\"\"\n Get the initialization scripts for the task. These are javascript scripts that will be run\n on any page and iframe that is loaded during the task.\n\n \"\"\"\n return []\n\n @classmethod\n def get_task_id(cls):\n # Get the class name and remove the word 'Task' from the end if it exists\n class_name = cls.__name__.replace(\"Task\", \"\")\n # Convert CamelCase to hyphen-separated format\n formatted_name = \"\".join(\n [\"-\" + i.lower() if i.isupper() else i for i in class_name]\n ).lstrip(\"-\")\n return f\"workarena.servicenow.{formatted_name}\"\n\n def setup(self, page: playwright.sync_api.Page, do_start=True) -> tuple[str, dict]:\n \"\"\"\n Set up the task\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The Playwright page object\n do_start: bool\n Whether to start the task or not (including navigating to start page) (default: True)\n\n \"\"\"\n logging.debug(\"Setting up the base task\")\n if self.task_is_setup:\n raise ValueError(\"The task is already setup\")\n\n # Keep the page for client-side validation\n self.page = page\n\n # Set the page timeout\n page.set_default_timeout(SNOW_BROWSER_TIMEOUT)\n\n # Create a new user to run the task if this is the starting task\n if do_start:\n self._base_initial_instance = self.instance\n self._base_user_name, self._base_user_password, self._base_user_sysid = create_user(\n instance=self.instance, user_roles=self.user_roles, random=self.random\n )\n self.instance = deepcopy(self.instance)\n self.instance.snow_credentials = (self._base_user_name, self._base_user_password)\n self.delete_user_on_teardown = True\n # Set the task's unique ID\n self.unique_id = str(uuid4())\n\n # Configure the task\n goal, info = self.setup_goal(page=page)\n\n # Load a few utility functions for init scripts\n page.context.add_init_script(path=SNOW_JS_UTILS_FILEPATH)\n\n # Add the initialization scripts to the page context\n for script in self.get_init_scripts():\n page.context.add_init_script(script)\n\n # Start the task if requested\n if do_start:\n self.start(page)\n\n self.task_is_setup = True\n\n return goal, info\n\n def create_user(self, first_name: str = None, last_name: str = None):\n \"\"\"\n Create a user in the ServiceNow instance\n\n \"\"\"\n\n @abstractmethod\n def setup_goal(self, page: playwright.sync_api.Page) -> tuple[str, dict]:\n \"\"\"\n Setup the task configuration and produce the goal\n\n \"\"\"\n pass\n\n def start(self, page: playwright.sync_api.Page) -> None:\n logging.debug(\"Navigating to task start page\")\n\n # Authenticate\n url_login(\n instance=self.instance,\n page=page,\n )\n\n # Navigate to the task's url\n page.goto(self.start_url)\n\n def teardown(self) -> None:\n \"\"\"\n Clean up after the task\n\n Notes:\n ------\n This method should not make assumptions on the state of the page (e.g., a specific URL).\n\n \"\"\"\n logging.debug(\"Tearing down the task\")\n\n if self.delete_user_on_teardown:\n # Delete the user\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"sys_user/{self._base_user_sysid}\",\n method=\"DELETE\",\n )","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.__init__#L31-L83","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":31,"end_line":83,"context_start_line":11,"context_end_line":103,"code":"from abc import ABC, abstractmethod\nfrom copy import deepcopy\nfrom typing import List, Optional, Tuple\nfrom uuid import uuid4\nfrom urllib import parse\n\nfrom browsergym.core.task import AbstractBrowserTask\nfrom ..api.user import create_user\nfrom ..api.utils import table_api_call\nfrom ..config import SNOW_BROWSER_TIMEOUT, SNOW_JS_UTILS_FILEPATH\nfrom ..utils import url_login\nfrom ..instance import SNowInstance\n\n\nclass AbstractServiceNowTask(AbstractBrowserTask, ABC):\n \"\"\"\n A base class for tasks that interacts with the ServiceNow instance\n\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n start_rel_url: str,\n instance: SNowInstance = None,\n final_rel_url: Optional[str] = None,\n user_roles: List[str] = [\"admin\"],\n has_description: bool = False,\n ) -> None:\n \"\"\"\n Initialize the task\n\n Parameters:\n -----------\n seed: int\n Random seed\n instance: SNowInstance\n The ServiceNow instance in which the task will be performed\n start_rel_url: str\n The URL for the starting page of the task\n final_rel_url: str (optional)\n The URL for the final page of the task (default: uses the value of base_url)\n user_roles: list[str]\n The roles to assign to the user (default: [\"admin\"])\n has_description: bool\n Whether the task has a description in L3 compositional tasks\n\n \"\"\"\n super().__init__(seed)\n\n # task properties, will be used to set up the browsergym environment\n self.viewport = {\"width\": 1280, \"height\": 720}\n self.slow_mo = 1000 # ms\n self.timeout = 10000 # ms\n\n self.instance = instance if instance is not None else SNowInstance()\n self.start_url = self.instance.snow_url + start_rel_url\n\n if final_rel_url is not None:\n self.final_url = self.instance.snow_url + final_rel_url\n else:\n self.final_url = self.start_url\n self.final_url_ = parse.urlparse(self.final_url)\n\n # Set the task's unique ID\n self.unique_id = str(uuid4())\n # Flag to ensure the task is setup only once\n self.task_is_setup = False\n self.delete_user_on_teardown = False\n self.user_roles = user_roles\n self.has_description = (\n has_description # Whether the task has a description in L3 compositional tasks\n )\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n # Don't call super cheat function because it's not implemented at the base level\n logging.debug(\"Cheat is solving the task\")\n\n def get_init_scripts(self) -> List[str]:\n \"\"\"\n Get the initialization scripts for the task. These are javascript scripts that will be run\n on any page and iframe that is loaded during the task.\n\n \"\"\"\n return []\n\n @classmethod\n def get_task_id(cls):\n # Get the class name and remove the word 'Task' from the end if it exists\n class_name = cls.__name__.replace(\"Task\", \"\")\n # Convert CamelCase to hyphen-separated format\n formatted_name = \"\".join(\n [\"-\" + i.lower() if i.isupper() else i for i in class_name]","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.cheat#L85-L87","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":85,"end_line":87,"context_start_line":65,"context_end_line":107,"code":"\n self.instance = instance if instance is not None else SNowInstance()\n self.start_url = self.instance.snow_url + start_rel_url\n\n if final_rel_url is not None:\n self.final_url = self.instance.snow_url + final_rel_url\n else:\n self.final_url = self.start_url\n self.final_url_ = parse.urlparse(self.final_url)\n\n # Set the task's unique ID\n self.unique_id = str(uuid4())\n # Flag to ensure the task is setup only once\n self.task_is_setup = False\n self.delete_user_on_teardown = False\n self.user_roles = user_roles\n self.has_description = (\n has_description # Whether the task has a description in L3 compositional tasks\n )\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n # Don't call super cheat function because it's not implemented at the base level\n logging.debug(\"Cheat is solving the task\")\n\n def get_init_scripts(self) -> List[str]:\n \"\"\"\n Get the initialization scripts for the task. These are javascript scripts that will be run\n on any page and iframe that is loaded during the task.\n\n \"\"\"\n return []\n\n @classmethod\n def get_task_id(cls):\n # Get the class name and remove the word 'Task' from the end if it exists\n class_name = cls.__name__.replace(\"Task\", \"\")\n # Convert CamelCase to hyphen-separated format\n formatted_name = \"\".join(\n [\"-\" + i.lower() if i.isupper() else i for i in class_name]\n ).lstrip(\"-\")\n return f\"workarena.servicenow.{formatted_name}\"\n\n def setup(self, page: playwright.sync_api.Page, do_start=True) -> tuple[str, dict]:","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.get_init_scripts","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.get_init_scripts#L89-L95","kind":"function","name":"get_init_scripts","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":89,"end_line":95,"context_start_line":69,"context_end_line":115,"code":" if final_rel_url is not None:\n self.final_url = self.instance.snow_url + final_rel_url\n else:\n self.final_url = self.start_url\n self.final_url_ = parse.urlparse(self.final_url)\n\n # Set the task's unique ID\n self.unique_id = str(uuid4())\n # Flag to ensure the task is setup only once\n self.task_is_setup = False\n self.delete_user_on_teardown = False\n self.user_roles = user_roles\n self.has_description = (\n has_description # Whether the task has a description in L3 compositional tasks\n )\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n # Don't call super cheat function because it's not implemented at the base level\n logging.debug(\"Cheat is solving the task\")\n\n def get_init_scripts(self) -> List[str]:\n \"\"\"\n Get the initialization scripts for the task. These are javascript scripts that will be run\n on any page and iframe that is loaded during the task.\n\n \"\"\"\n return []\n\n @classmethod\n def get_task_id(cls):\n # Get the class name and remove the word 'Task' from the end if it exists\n class_name = cls.__name__.replace(\"Task\", \"\")\n # Convert CamelCase to hyphen-separated format\n formatted_name = \"\".join(\n [\"-\" + i.lower() if i.isupper() else i for i in class_name]\n ).lstrip(\"-\")\n return f\"workarena.servicenow.{formatted_name}\"\n\n def setup(self, page: playwright.sync_api.Page, do_start=True) -> tuple[str, dict]:\n \"\"\"\n Set up the task\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The Playwright page object\n do_start: bool","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.get_task_id","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.get_task_id#L98-L105","kind":"function","name":"get_task_id","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":98,"end_line":105,"context_start_line":78,"context_end_line":125,"code":" self.task_is_setup = False\n self.delete_user_on_teardown = False\n self.user_roles = user_roles\n self.has_description = (\n has_description # Whether the task has a description in L3 compositional tasks\n )\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n # Don't call super cheat function because it's not implemented at the base level\n logging.debug(\"Cheat is solving the task\")\n\n def get_init_scripts(self) -> List[str]:\n \"\"\"\n Get the initialization scripts for the task. These are javascript scripts that will be run\n on any page and iframe that is loaded during the task.\n\n \"\"\"\n return []\n\n @classmethod\n def get_task_id(cls):\n # Get the class name and remove the word 'Task' from the end if it exists\n class_name = cls.__name__.replace(\"Task\", \"\")\n # Convert CamelCase to hyphen-separated format\n formatted_name = \"\".join(\n [\"-\" + i.lower() if i.isupper() else i for i in class_name]\n ).lstrip(\"-\")\n return f\"workarena.servicenow.{formatted_name}\"\n\n def setup(self, page: playwright.sync_api.Page, do_start=True) -> tuple[str, dict]:\n \"\"\"\n Set up the task\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The Playwright page object\n do_start: bool\n Whether to start the task or not (including navigating to start page) (default: True)\n\n \"\"\"\n logging.debug(\"Setting up the base task\")\n if self.task_is_setup:\n raise ValueError(\"The task is already setup\")\n\n # Keep the page for client-side validation\n self.page = page\n","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.setup","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.setup#L107-L157","kind":"function","name":"setup","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":107,"end_line":157,"context_start_line":87,"context_end_line":177,"code":" logging.debug(\"Cheat is solving the task\")\n\n def get_init_scripts(self) -> List[str]:\n \"\"\"\n Get the initialization scripts for the task. These are javascript scripts that will be run\n on any page and iframe that is loaded during the task.\n\n \"\"\"\n return []\n\n @classmethod\n def get_task_id(cls):\n # Get the class name and remove the word 'Task' from the end if it exists\n class_name = cls.__name__.replace(\"Task\", \"\")\n # Convert CamelCase to hyphen-separated format\n formatted_name = \"\".join(\n [\"-\" + i.lower() if i.isupper() else i for i in class_name]\n ).lstrip(\"-\")\n return f\"workarena.servicenow.{formatted_name}\"\n\n def setup(self, page: playwright.sync_api.Page, do_start=True) -> tuple[str, dict]:\n \"\"\"\n Set up the task\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The Playwright page object\n do_start: bool\n Whether to start the task or not (including navigating to start page) (default: True)\n\n \"\"\"\n logging.debug(\"Setting up the base task\")\n if self.task_is_setup:\n raise ValueError(\"The task is already setup\")\n\n # Keep the page for client-side validation\n self.page = page\n\n # Set the page timeout\n page.set_default_timeout(SNOW_BROWSER_TIMEOUT)\n\n # Create a new user to run the task if this is the starting task\n if do_start:\n self._base_initial_instance = self.instance\n self._base_user_name, self._base_user_password, self._base_user_sysid = create_user(\n instance=self.instance, user_roles=self.user_roles, random=self.random\n )\n self.instance = deepcopy(self.instance)\n self.instance.snow_credentials = (self._base_user_name, self._base_user_password)\n self.delete_user_on_teardown = True\n # Set the task's unique ID\n self.unique_id = str(uuid4())\n\n # Configure the task\n goal, info = self.setup_goal(page=page)\n\n # Load a few utility functions for init scripts\n page.context.add_init_script(path=SNOW_JS_UTILS_FILEPATH)\n\n # Add the initialization scripts to the page context\n for script in self.get_init_scripts():\n page.context.add_init_script(script)\n\n # Start the task if requested\n if do_start:\n self.start(page)\n\n self.task_is_setup = True\n\n return goal, info\n\n def create_user(self, first_name: str = None, last_name: str = None):\n \"\"\"\n Create a user in the ServiceNow instance\n\n \"\"\"\n\n @abstractmethod\n def setup_goal(self, page: playwright.sync_api.Page) -> tuple[str, dict]:\n \"\"\"\n Setup the task configuration and produce the goal\n\n \"\"\"\n pass\n\n def start(self, page: playwright.sync_api.Page) -> None:\n logging.debug(\"Navigating to task start page\")\n\n # Authenticate\n url_login(","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.create_user","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.create_user#L159-L163","kind":"function","name":"create_user","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":159,"end_line":163,"context_start_line":139,"context_end_line":183,"code":" self.unique_id = str(uuid4())\n\n # Configure the task\n goal, info = self.setup_goal(page=page)\n\n # Load a few utility functions for init scripts\n page.context.add_init_script(path=SNOW_JS_UTILS_FILEPATH)\n\n # Add the initialization scripts to the page context\n for script in self.get_init_scripts():\n page.context.add_init_script(script)\n\n # Start the task if requested\n if do_start:\n self.start(page)\n\n self.task_is_setup = True\n\n return goal, info\n\n def create_user(self, first_name: str = None, last_name: str = None):\n \"\"\"\n Create a user in the ServiceNow instance\n\n \"\"\"\n\n @abstractmethod\n def setup_goal(self, page: playwright.sync_api.Page) -> tuple[str, dict]:\n \"\"\"\n Setup the task configuration and produce the goal\n\n \"\"\"\n pass\n\n def start(self, page: playwright.sync_api.Page) -> None:\n logging.debug(\"Navigating to task start page\")\n\n # Authenticate\n url_login(\n instance=self.instance,\n page=page,\n )\n\n # Navigate to the task's url\n page.goto(self.start_url)","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.setup_goal#L166-L171","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":166,"end_line":171,"context_start_line":146,"context_end_line":191,"code":"\n # Add the initialization scripts to the page context\n for script in self.get_init_scripts():\n page.context.add_init_script(script)\n\n # Start the task if requested\n if do_start:\n self.start(page)\n\n self.task_is_setup = True\n\n return goal, info\n\n def create_user(self, first_name: str = None, last_name: str = None):\n \"\"\"\n Create a user in the ServiceNow instance\n\n \"\"\"\n\n @abstractmethod\n def setup_goal(self, page: playwright.sync_api.Page) -> tuple[str, dict]:\n \"\"\"\n Setup the task configuration and produce the goal\n\n \"\"\"\n pass\n\n def start(self, page: playwright.sync_api.Page) -> None:\n logging.debug(\"Navigating to task start page\")\n\n # Authenticate\n url_login(\n instance=self.instance,\n page=page,\n )\n\n # Navigate to the task's url\n page.goto(self.start_url)\n\n def teardown(self) -> None:\n \"\"\"\n Clean up after the task\n\n Notes:\n ------\n This method should not make assumptions on the state of the page (e.g., a specific URL).","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.start","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.start#L173-L183","kind":"function","name":"start","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":173,"end_line":183,"context_start_line":153,"context_end_line":202,"code":" self.start(page)\n\n self.task_is_setup = True\n\n return goal, info\n\n def create_user(self, first_name: str = None, last_name: str = None):\n \"\"\"\n Create a user in the ServiceNow instance\n\n \"\"\"\n\n @abstractmethod\n def setup_goal(self, page: playwright.sync_api.Page) -> tuple[str, dict]:\n \"\"\"\n Setup the task configuration and produce the goal\n\n \"\"\"\n pass\n\n def start(self, page: playwright.sync_api.Page) -> None:\n logging.debug(\"Navigating to task start page\")\n\n # Authenticate\n url_login(\n instance=self.instance,\n page=page,\n )\n\n # Navigate to the task's url\n page.goto(self.start_url)\n\n def teardown(self) -> None:\n \"\"\"\n Clean up after the task\n\n Notes:\n ------\n This method should not make assumptions on the state of the page (e.g., a specific URL).\n\n \"\"\"\n logging.debug(\"Tearing down the task\")\n\n if self.delete_user_on_teardown:\n # Delete the user\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"sys_user/{self._base_user_sysid}\",\n method=\"DELETE\",\n )","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.base.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.base.teardown#L185-L202","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":185,"end_line":202,"context_start_line":165,"context_end_line":202,"code":" @abstractmethod\n def setup_goal(self, page: playwright.sync_api.Page) -> tuple[str, dict]:\n \"\"\"\n Setup the task configuration and produce the goal\n\n \"\"\"\n pass\n\n def start(self, page: playwright.sync_api.Page) -> None:\n logging.debug(\"Navigating to task start page\")\n\n # Authenticate\n url_login(\n instance=self.instance,\n page=page,\n )\n\n # Navigate to the task's url\n page.goto(self.start_url)\n\n def teardown(self) -> None:\n \"\"\"\n Clean up after the task\n\n Notes:\n ------\n This method should not make assumptions on the state of the page (e.g., a specific URL).\n\n \"\"\"\n logging.debug(\"Tearing down the task\")\n\n if self.delete_user_on_teardown:\n # Delete the user\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"sys_user/{self._base_user_sysid}\",\n method=\"DELETE\",\n )","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.send_chat_message#L1-L90","kind":"module","name":"src.browsergym.workarena.tasks.send_chat_message","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":1,"end_line":90,"context_start_line":1,"context_end_line":90,"code":"from typing import Tuple\nfrom playwright.sync_api import Page\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..instance import SNowInstance\n\n\nclass SendChatMessageTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"Task to send a chat message in the chat. Only used as a compositional building block for the cheat function.\n Args:\n --------\n message (str):\n The message to send in the chat\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n \"\"\"\n\n def __init__(\n self,\n instance: SNowInstance,\n message: str,\n answer_format: str,\n use_description_in_l3: bool = False,\n **kwargs,\n ):\n super().__init__(seed=0, instance=instance, start_rel_url=\"\")\n self.message = message\n self.answer_format = answer_format\n self.use_description_in_l3 = use_description_in_l3\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page):\n return self.get_pretty_printed_description(), {}\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float | bool | str | dict]:\n return super().validate(page, chat_messages)\n\n def cheat(self, page: Page, chat_messages: list[str]):\n super().cheat(page=page, chat_messages=chat_messages)\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.message)})\n\n def teardown(self) -> None:\n pass\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n raise NotImplementedError\n\n\nclass SendChatMessageForBudgetAllocationTask(SendChatMessageTask):\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget} $. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the value of their 'Number' field in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the value of the 'Number' field of the selected investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain as well as returning their total value in the chat.\"\n\n return task_info\n\n\nclass SendChatMessageGenericTask(SendChatMessageTask):\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.use_description_in_l3:\n task_info = self.description\n elif self.level == 3:\n task_info = \"\"\n elif self.level == 2:\n task_info = self.description\n\n return task_info","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.SendChatMessageTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.send_chat_message.SendChatMessageTask#L10-L51","kind":"class","name":"SendChatMessageTask","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":10,"end_line":51,"context_start_line":1,"context_end_line":71,"code":"from typing import Tuple\nfrom playwright.sync_api import Page\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..instance import SNowInstance\n\n\nclass SendChatMessageTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"Task to send a chat message in the chat. Only used as a compositional building block for the cheat function.\n Args:\n --------\n message (str):\n The message to send in the chat\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n \"\"\"\n\n def __init__(\n self,\n instance: SNowInstance,\n message: str,\n answer_format: str,\n use_description_in_l3: bool = False,\n **kwargs,\n ):\n super().__init__(seed=0, instance=instance, start_rel_url=\"\")\n self.message = message\n self.answer_format = answer_format\n self.use_description_in_l3 = use_description_in_l3\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page):\n return self.get_pretty_printed_description(), {}\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float | bool | str | dict]:\n return super().validate(page, chat_messages)\n\n def cheat(self, page: Page, chat_messages: list[str]):\n super().cheat(page=page, chat_messages=chat_messages)\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.message)})\n\n def teardown(self) -> None:\n pass\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n raise NotImplementedError\n\n\nclass SendChatMessageForBudgetAllocationTask(SendChatMessageTask):\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget} $. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the value of their 'Number' field in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the value of the 'Number' field of the selected investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.SendChatMessageForBudgetAllocationTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.send_chat_message.SendChatMessageForBudgetAllocationTask#L54-L74","kind":"class","name":"SendChatMessageForBudgetAllocationTask","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":54,"end_line":74,"context_start_line":34,"context_end_line":90,"code":" def setup_goal(self, page: Page):\n return self.get_pretty_printed_description(), {}\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float | bool | str | dict]:\n return super().validate(page, chat_messages)\n\n def cheat(self, page: Page, chat_messages: list[str]):\n super().cheat(page=page, chat_messages=chat_messages)\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.message)})\n\n def teardown(self) -> None:\n pass\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n raise NotImplementedError\n\n\nclass SendChatMessageForBudgetAllocationTask(SendChatMessageTask):\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget} $. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the value of their 'Number' field in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the value of the 'Number' field of the selected investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain as well as returning their total value in the chat.\"\n\n return task_info\n\n\nclass SendChatMessageGenericTask(SendChatMessageTask):\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.use_description_in_l3:\n task_info = self.description\n elif self.level == 3:\n task_info = \"\"\n elif self.level == 2:\n task_info = self.description\n\n return task_info","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.SendChatMessageGenericTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.send_chat_message.SendChatMessageGenericTask#L77-L90","kind":"class","name":"SendChatMessageGenericTask","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":77,"end_line":90,"context_start_line":57,"context_end_line":90,"code":" Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget} $. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the value of their 'Number' field in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the value of the 'Number' field of the selected investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain as well as returning their total value in the chat.\"\n\n return task_info\n\n\nclass SendChatMessageGenericTask(SendChatMessageTask):\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.use_description_in_l3:\n task_info = self.description\n elif self.level == 3:\n task_info = \"\"\n elif self.level == 2:\n task_info = self.description\n\n return task_info","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.send_chat_message.__init__#L20-L32","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":20,"end_line":32,"context_start_line":1,"context_end_line":52,"code":"from typing import Tuple\nfrom playwright.sync_api import Page\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..instance import SNowInstance\n\n\nclass SendChatMessageTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"Task to send a chat message in the chat. Only used as a compositional building block for the cheat function.\n Args:\n --------\n message (str):\n The message to send in the chat\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n \"\"\"\n\n def __init__(\n self,\n instance: SNowInstance,\n message: str,\n answer_format: str,\n use_description_in_l3: bool = False,\n **kwargs,\n ):\n super().__init__(seed=0, instance=instance, start_rel_url=\"\")\n self.message = message\n self.answer_format = answer_format\n self.use_description_in_l3 = use_description_in_l3\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page):\n return self.get_pretty_printed_description(), {}\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float | bool | str | dict]:\n return super().validate(page, chat_messages)\n\n def cheat(self, page: Page, chat_messages: list[str]):\n super().cheat(page=page, chat_messages=chat_messages)\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.message)})\n\n def teardown(self) -> None:\n pass\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n raise NotImplementedError\n","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.send_chat_message.setup_goal#L34-L35","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":34,"end_line":35,"context_start_line":14,"context_end_line":55,"code":" message (str):\n The message to send in the chat\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n \"\"\"\n\n def __init__(\n self,\n instance: SNowInstance,\n message: str,\n answer_format: str,\n use_description_in_l3: bool = False,\n **kwargs,\n ):\n super().__init__(seed=0, instance=instance, start_rel_url=\"\")\n self.message = message\n self.answer_format = answer_format\n self.use_description_in_l3 = use_description_in_l3\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page):\n return self.get_pretty_printed_description(), {}\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float | bool | str | dict]:\n return super().validate(page, chat_messages)\n\n def cheat(self, page: Page, chat_messages: list[str]):\n super().cheat(page=page, chat_messages=chat_messages)\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.message)})\n\n def teardown(self) -> None:\n pass\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n raise NotImplementedError\n\n\nclass SendChatMessageForBudgetAllocationTask(SendChatMessageTask):\n def get_pretty_printed_description(self) -> str:","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.send_chat_message.validate#L37-L38","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":37,"end_line":38,"context_start_line":17,"context_end_line":58,"code":" The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n \"\"\"\n\n def __init__(\n self,\n instance: SNowInstance,\n message: str,\n answer_format: str,\n use_description_in_l3: bool = False,\n **kwargs,\n ):\n super().__init__(seed=0, instance=instance, start_rel_url=\"\")\n self.message = message\n self.answer_format = answer_format\n self.use_description_in_l3 = use_description_in_l3\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page):\n return self.get_pretty_printed_description(), {}\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float | bool | str | dict]:\n return super().validate(page, chat_messages)\n\n def cheat(self, page: Page, chat_messages: list[str]):\n super().cheat(page=page, chat_messages=chat_messages)\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.message)})\n\n def teardown(self) -> None:\n pass\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n raise NotImplementedError\n\n\nclass SendChatMessageForBudgetAllocationTask(SendChatMessageTask):\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.send_chat_message.cheat#L40-L42","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":40,"end_line":42,"context_start_line":20,"context_end_line":62,"code":" def __init__(\n self,\n instance: SNowInstance,\n message: str,\n answer_format: str,\n use_description_in_l3: bool = False,\n **kwargs,\n ):\n super().__init__(seed=0, instance=instance, start_rel_url=\"\")\n self.message = message\n self.answer_format = answer_format\n self.use_description_in_l3 = use_description_in_l3\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page):\n return self.get_pretty_printed_description(), {}\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float | bool | str | dict]:\n return super().validate(page, chat_messages)\n\n def cheat(self, page: Page, chat_messages: list[str]):\n super().cheat(page=page, chat_messages=chat_messages)\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.message)})\n\n def teardown(self) -> None:\n pass\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n raise NotImplementedError\n\n\nclass SendChatMessageForBudgetAllocationTask(SendChatMessageTask):\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget} $. The returns are written in their short description.\"","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.send_chat_message.teardown#L44-L45","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":44,"end_line":45,"context_start_line":24,"context_end_line":65,"code":" answer_format: str,\n use_description_in_l3: bool = False,\n **kwargs,\n ):\n super().__init__(seed=0, instance=instance, start_rel_url=\"\")\n self.message = message\n self.answer_format = answer_format\n self.use_description_in_l3 = use_description_in_l3\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page):\n return self.get_pretty_printed_description(), {}\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float | bool | str | dict]:\n return super().validate(page, chat_messages)\n\n def cheat(self, page: Page, chat_messages: list[str]):\n super().cheat(page=page, chat_messages=chat_messages)\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.message)})\n\n def teardown(self) -> None:\n pass\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n raise NotImplementedError\n\n\nclass SendChatMessageForBudgetAllocationTask(SendChatMessageTask):\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget} $. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.send_chat_message.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.send_chat_message.get_pretty_printed_description#L79-L90","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":79,"end_line":90,"context_start_line":59,"context_end_line":90,"code":" if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget} $. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the value of their 'Number' field in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the value of the 'Number' field of the selected investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain as well as returning their total value in the chat.\"\n\n return task_info\n\n\nclass SendChatMessageGenericTask(SendChatMessageTask):\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.use_description_in_l3:\n task_info = self.description\n elif self.level == 3:\n task_info = \"\"\n elif self.level == 2:\n task_info = self.description\n\n return task_info","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.service_catalog#L1-L664","kind":"module","name":"src.browsergym.workarena.tasks.service_catalog","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":1,"end_line":664,"context_start_line":1,"context_end_line":664,"code":"\"\"\"\nTasks that require interacting with the service catalog\n\n\"\"\"\n\nimport json\nimport logging\nfrom typing import List\nimport numpy as np\nimport playwright.sync_api\n\nfrom playwright.sync_api import Page\nimport re\nfrom time import sleep\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .utils.form import fill_text\n\nfrom ..api.requests import (\n get_request_by_id,\n db_delete_from_table,\n)\nfrom ..config import (\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n)\nfrom ..instance import SNowInstance\nfrom .utils.utils import check_url_suffix_match\n\nADDITIONAL_SOFTWARE = [\n \"Slack\",\n \"Trello\",\n \"Salesforce\",\n \"QuickBooks\",\n \"Zoom\",\n \"Microsoft Office 365\",\n \"Google Workspace\",\n \"Asana\",\n \"HubSpot\",\n \"Adobe Creative Cloud\",\n]\n\nMETA_CONFIGS = {\n \"Developer Laptop (Mac)\": {\n \"desc\": \"Macbook Pro\",\n \"options\": {\n \"Adobe Acrobat\": (\"checkbox\", [True, False]),\n \"Eclipse IDE\": (\"checkbox\", [True, False]),\n \"Adobe Photoshop\": (\"checkbox\", [True, False]),\n \"Additional software requirements\": (\"textarea\", ADDITIONAL_SOFTWARE),\n },\n },\n \"iPad mini\": {\n \"desc\": \"Request for iPad mini\",\n \"options\": {\n \"Choose the colour\": (\n \"radio\",\n [\"Space Grey\", \"Pink\", \"Purple\", \"Starlight\"],\n ),\n \"Choose the storage\": (\"radio\", [\"64\", \"256\"]),\n },\n },\n \"iPad pro\": {\n \"desc\": \"Request for iPad pro\",\n \"options\": {\n \"Choose the colour\": (\"radio\", [\"Space Grey\", \"Silver\"]),\n \"Choose the storage\": (\"radio\", [\"128\", \"256\", \"512\"]),\n },\n },\n \"Sales Laptop\": {\n \"desc\": \"Acer Aspire NX\",\n \"options\": {\n \"Microsoft Powerpoint\": (\"checkbox\", [True, False]),\n \"Adobe Acrobat\": (\"checkbox\", [True, False]),\n \"Adobe Photoshop\": (\"checkbox\", [True, False]),\n \"Siebel Client\": (\"checkbox\", [True, False]),\n \"Additional software requirements\": (\"textarea\", ADDITIONAL_SOFTWARE),\n },\n },\n \"Standard Laptop\": {\n \"desc\": \"Lenovo - Carbon x1\",\n \"options\": {\n \"Adobe Acrobat\": (\"checkbox\", [True, False]),\n \"Adobe Photoshop\": (\"checkbox\", [True, False]),\n \"Additional software requirements\": (\"textarea\", ADDITIONAL_SOFTWARE),\n },\n },\n \"Apple Watch\": {\n \"desc\": \"Apple Watch - Their most personal device ever\",\n \"options\": {},\n },\n \"Apple MacBook Pro 15\": {\n \"desc\": \"Apple MacBook Pro\",\n \"options\": {},\n },\n \"Development Laptop (PC)\": {\n \"desc\": \"Dell XPS 13\",\n \"options\": {\n \"What size solid state drive do you want?\": (\n \"radio\",\n [\n \"250\", # This needs to match both the radio option (250 GB [subtract 300$]) and db request (250)\n \"500\", # Similar as above\n ],\n ),\n \"Please specify an operating system\": (\"radio\", [\"Windows 8\", \"Ubuntu\"]),\n },\n },\n \"Loaner Laptop\": {\n \"desc\": \"Short term, while computer is repaired/imaged. Waiting for computer order, special projects, etc. Training, special events, check-in process\",\n \"options\": {\n \"When do you need it ?\": (\n \"textarea\",\n [\n \"ASAP\",\n \"In 2 weeks\",\n \"By the end of the month\",\n \"On time for the next meeting\",\n \"I needed it yesterday but since you are asking I guess I can wait a bit more\",\n \"Do your best, I know you are busy\",\n \"I don't need it anymore, I just wanted to see what would happen if I clicked on this button\",\n ],\n ),\n \"How long do you need it for ?\": (\n \"radio\",\n [\n \"1 day\",\n \"1 month\",\n \"1 week\",\n \"2 weeks\",\n \"3 days\",\n ],\n ),\n },\n },\n}\n\n\nclass OrderHardwareTask(AbstractServiceNowTask):\n \"\"\"\n Order an item from the service catalog.\n\n Parameters:\n -----------\n seed: int\n Random seed\n instance: SNowInstance\n The instance to use.\n fixed_request_item: str\n The item to order. If provided, the task will always order this item.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/order_ipda_pro_task.json\n for an example of a configuration file.\n config_only_in_desc: bool\n If True, the model to order will be omitted from the task description in comp tasks.\n\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_request_item: str = None,\n fixed_config: dict = None,\n config_only_in_desc: bool = False,\n **kwargs,\n ):\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/catalog_home.do%3Fsysparm_view%3Dcatalog_default\",\n final_rel_url=\"/now/nav/ui/classic/params/target/com.glideapp.servicecatalog_checkout_view_v2.do\",\n )\n\n if fixed_request_item is not None and fixed_config is not None:\n if fixed_request_item != fixed_config[\"item\"]:\n raise ValueError(f\"'fixed_request_item' and 'fixed_config[\\\"item\\\"]' do not match\")\n\n self.fixed_config = fixed_config\n self.config = None\n self.fixed_request_item = fixed_request_item\n self.config_only_in_desc = config_only_in_desc\n\n self.js_prefix = \"gsft_main\"\n self.js_api_forms = \"g_form\"\n self.all_configs = self.all_configs()\n self.__dict__.update(kwargs)\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _wait_for_ready(self, page: Page, wait_for_form_api: bool = False) -> None:\n \"\"\"\n Waits for the the main iframe to be loaded\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if wait_for_form_api:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n @property\n def form_js_selector(self):\n return self.js_prefix + \".\" + self.js_api_forms\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded()\",\n self._get_disable_add_to_cart_script(),\n self._get_remove_top_items_panel_script(),\n ]\n\n def _get_disable_add_to_cart_script(self):\n \"\"\"\n Disables the 'Add to Cart' button on the service catalog page\n This is necessary so that agents running in parallel do not interfere with each other (cart is shared between sessions)\n\n \"\"\"\n script = \"\"\"\n function disableAddToCartButton() {\n waLog('Searching for top items panel...', 'disableAddToCartButton');\n let button = document.querySelector('button[aria-label=\"Add to Cart\"]');\n if (button) {\n button.disabled = true;\n waLog('WorkArena: Disabled the \"Add to Cart\" button', 'disableAddToCartButton');\n } else {\n waLog('WorkArena: Could not find the \"Add to Cart\" button', 'disableAddToCartButton');\n }\n }\n\n runInGsftMainOnlyAndProtectByURL(disableAddToCartButton, 'glideapp.servicecatalog_cat_item_view.do');\n \"\"\"\n return script\n\n def _get_remove_top_items_panel_script(self):\n \"\"\"Get script that removes the 'top items' panel that sometimes on the landing page of service catalog\n Disables the 'Top Requests' panel that sometimes appears on the landing page of the service catalog\n Runs in a loop to keep checking for the host element and shadow root\n URL is secured by running only on the catalog_home page; this is a heuristic to avoid running on other pages\n and does not check that the URL is an exact match, as moving back and forth between pages can cause the URL\n to change, but catalog_home will always be present.\n \"\"\"\n script = \"\"\"\n function removeTopItemsPanel() {\n waLog('Searching for top items panel...', 'removeTopItemsPanel');\n let headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n headings.forEach((heading) => {\n if (heading.textContent.includes(\"Top Requests\")) {\n let parentDiv = heading.closest('div.drag_section');\n if (parentDiv) {\n parentDiv.remove();\n waLog('Removed parent div for heading: ' + heading.textContent, 'removeTopItemsPanel');\n }\n }\n });\n }\n\n runInGsftMainOnlyAndProtectByURL(removeTopItemsPanel, `catalog_home`);\n \"\"\"\n return script\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n assert self.all_configs is not None, \"No configuration available for the task.\"\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.requested_item = self.config[\"item\"]\n self.short_description = self.config[\"description\"]\n self.quantity = self.config[\"quantity\"]\n self.requested_configuration = self.config[\"configuration\"]\n\n # Generate goal\n if self.config_only_in_desc:\n goal = self.get_pretty_printed_description()\n else:\n goal = f'Go to the hardware store and order {self.quantity} \"{self.requested_item}\"'\n if len(self.requested_configuration) > 0:\n goal += f\" with configuration {dict((k, v[1]) for k, v in self.requested_configuration.items())}\"\n info = {}\n\n # Used to keep track of the sysid of the request for validation\n self.request_sysid = None\n\n return goal, info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page=page)\n\n iframe = page.frame(self.js_prefix)\n\n # Find hardware buttons\n element = iframe.wait_for_selector(\"a:text('Hardware')\", strict=True)\n element.click()\n self._wait_for_ready(page=page)\n\n element = iframe.wait_for_selector(f\"h2:has-text('{self.requested_item}')\", strict=True)\n element.click()\n self._wait_for_ready(page=page, wait_for_form_api=True)\n\n quantity_input = iframe.wait_for_selector(\"#quantity\", strict=True)\n quantity_input.select_option(str(self.quantity))\n\n editable_fields = page.evaluate(f\"{self.form_js_selector}.getEditableFields()\")\n\n lookup_map = {}\n for idx, field in enumerate(editable_fields):\n control_text = self._get_control_description(page, field)\n lookup_map[control_text] = field\n\n for field_label, (element, value) in self.requested_configuration.items():\n element_id = lookup_map[field_label]\n control_type = page.evaluate(f\"{self.form_js_selector}.getControl('{element_id}').type\")\n\n if control_type in (\"radio\",):\n num_options = page.evaluate(\n f\"{self.form_js_selector}.getControls('{element_id}').length\"\n )\n for i in range(num_options):\n control_handle = page.evaluate_handle(\n f\"{self.form_js_selector}.getControls('{element_id}')[{i}]\"\n )\n control_text = control_handle.evaluate(\"e => e.parentElement.innerText\")\n if control_text.startswith(\n value\n ): # the page changes the text dynamically adding subtract/add to the text\n control_id = control_handle.get_attribute(\"id\")\n iframe.wait_for_selector(f'label[for=\"{control_id}\"]', strict=True).click()\n break\n elif control_type == \"hidden\":\n element_control = page.evaluate_handle(\n f\"{self.form_js_selector}.getControl('{element_id}')\"\n )\n element_value = element_control.evaluate(\"e => e.value\")\n if element_value != str(value).lower():\n label_id = f\"ni.{element_id}_label\"\n element_label = iframe.wait_for_selector(\n f'label[id=\"{label_id}\"]', strict=True, timeout=1_000\n )\n element_label.click()\n elif control_type in (\"textarea\", \"text\"):\n element_control = page.evaluate_handle(\n f\"{self.form_js_selector}.getControl('{element_id}')\"\n ).as_element() # this look superfluous\n element_id = element_control.get_attribute(\"id\") # this look superfluous\n text_element = iframe.query_selector(f'[id=\"{element_id}\"]')\n text_element.click()\n fill_text(page=page, input_field=text_element, value=value, iframe=iframe)\n\n elif control_type == \"select-one\":\n iframe.locator(f\"id={element_id}\").select_option(value)\n else:\n raise ValueError(f\"Unknown control type {control_type}\")\n\n order_now_button = iframe.wait_for_selector(\"#oi_order_now_button\", strict=True)\n\n with page.expect_navigation():\n order_now_button.click()\n\n def _generate_random_config(self, page: Page):\n \"\"\"Generate a random configuration for the task\"\"\"\n self.task_is_setup = (\n False # This is a hack to avoid raising an exception in the setup method\n )\n self.setup(page=page, do_start=False)\n if self.fixed_request_item:\n self.requested_item = self.fixed_request_item\n else:\n # ... choose a random item to order\n self.requested_item = self.random.choice(list(META_CONFIGS.keys()))\n\n meta_config = META_CONFIGS[self.requested_item]\n self.fixed_config = {\n \"item\": self.requested_item,\n \"description\": meta_config[\"desc\"],\n \"quantity\": self.random.randint(1, 11),\n \"configuration\": {\n ctrl_name: (ctrl_type, self.random.choice(values))\n for ctrl_name, (ctrl_type, values) in meta_config[\"options\"].items()\n },\n }\n self.setup(page=page, do_start=True)\n\n def _get_control_description(self, page, field):\n \"\"\"\n Get the description of a control (e.g., the text of a radio button)\n \"\"\"\n # Wait for everything to be ready\n self._wait_for_ready(page, wait_for_form_api=True)\n\n control_type = page.evaluate(f\"{self.form_js_selector}.getControl('{field}').type\")\n if control_type in (\"radio\", \"select-one\"):\n return page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\")\n elif control_type in (\"textarea\", \"hidden\", \"text\"):\n control_handle = page.evaluate_handle(f\"{self.form_js_selector}.getControl('{field}')\")\n # The control text is not always in the control itself, but in a parent element.\n # Being a heuristic, we try to find it by going up the DOM tree.\n # This is up to the page implementation, 5 is an arbitrary number.\n for depth in range(5):\n control_text = control_handle.evaluate(\"e => e.innerText\")\n if control_text != \"\":\n break\n control_handle = control_handle.evaluate_handle(\"e => e.parentElement\")\n else:\n raise ValueError(f\"Could not find control text for {field}\")\n else:\n raise ValueError(f\"Unknown control type {control_type}\")\n return control_text\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n task_specs = {\n \"Quantity\": self.config[\"quantity\"],\n \"Configuration\": self.config[\"configuration\"],\n }\n if self.config_only_in_desc:\n task_info = f\"- Order the item in the following quantities and with the following configuration:\\n\"\n else:\n task_specs[\"Description\"] = self.config[\"description\"]\n task_info = f\"- {class_name_formatted} with the following specifications:\\n\"\n for k, v in task_specs.items():\n # Some values might be empty - like the configuration of the apple watch. It is more natural to exclude them\n if not v:\n continue\n # If the value is a dictionary, print it in a nested way\n if isinstance(v, dict):\n task_info += f\" - {k}:\\n\"\n for k2, v2 in v.items():\n task_info += f\" - {k2}: {v2[1]}\\n\"\n else:\n task_info += f\" - {k}: {v}\\n\"\n\n return task_info\n\n def teardown(self) -> None:\n \"\"\"\n Deletes the request (and automatically all its items)\n \"\"\"\n self._wait_for_ready(self.page)\n\n if hasattr(self, \"request_sysid\") and self.request_sysid is not None:\n db_delete_from_table(\n instance=self.instance, sys_id=self.request_sysid, table=\"sc_request\"\n )\n\n def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str, dict]:\n\n # Retrieve the request sysid from the URL\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n (self.request_sysid,) = parse.parse_qs(current_url.query).get(\"sysparm_sys_id\", [None])\n if self.request_sysid is None:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The request was not created, the sysid is not in the URL.\"},\n )\n\n # Short sleep to make sure the data is saved in the DB\n # TODO: improve this (noted in issue 291)\n sleep(3)\n r = get_request_by_id(instance=self.instance, sysid=self.request_sysid)\n if r is None:\n return 0, False, \"\", {\"message\": \"The request is not in the database.\"}\n\n if len(r[\"items\"]) == 0:\n return 0, False, \"\", {\"message\": \"No items were requested.\"}\n\n if len(r[\"items\"]) > 1:\n error_msg = (\n \"M\n# ... truncated ...","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderHardwareTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderHardwareTask#L147-L548","kind":"class","name":"OrderHardwareTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":147,"end_line":548,"context_start_line":127,"context_end_line":568,"code":" \"I needed it yesterday but since you are asking I guess I can wait a bit more\",\n \"Do your best, I know you are busy\",\n \"I don't need it anymore, I just wanted to see what would happen if I clicked on this button\",\n ],\n ),\n \"How long do you need it for ?\": (\n \"radio\",\n [\n \"1 day\",\n \"1 month\",\n \"1 week\",\n \"2 weeks\",\n \"3 days\",\n ],\n ),\n },\n },\n}\n\n\nclass OrderHardwareTask(AbstractServiceNowTask):\n \"\"\"\n Order an item from the service catalog.\n\n Parameters:\n -----------\n seed: int\n Random seed\n instance: SNowInstance\n The instance to use.\n fixed_request_item: str\n The item to order. If provided, the task will always order this item.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/order_ipda_pro_task.json\n for an example of a configuration file.\n config_only_in_desc: bool\n If True, the model to order will be omitted from the task description in comp tasks.\n\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_request_item: str = None,\n fixed_config: dict = None,\n config_only_in_desc: bool = False,\n **kwargs,\n ):\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/catalog_home.do%3Fsysparm_view%3Dcatalog_default\",\n final_rel_url=\"/now/nav/ui/classic/params/target/com.glideapp.servicecatalog_checkout_view_v2.do\",\n )\n\n if fixed_request_item is not None and fixed_config is not None:\n if fixed_request_item != fixed_config[\"item\"]:\n raise ValueError(f\"'fixed_request_item' and 'fixed_config[\\\"item\\\"]' do not match\")\n\n self.fixed_config = fixed_config\n self.config = None\n self.fixed_request_item = fixed_request_item\n self.config_only_in_desc = config_only_in_desc\n\n self.js_prefix = \"gsft_main\"\n self.js_api_forms = \"g_form\"\n self.all_configs = self.all_configs()\n self.__dict__.update(kwargs)\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _wait_for_ready(self, page: Page, wait_for_form_api: bool = False) -> None:\n \"\"\"\n Waits for the the main iframe to be loaded\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if wait_for_form_api:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n @property\n def form_js_selector(self):\n return self.js_prefix + \".\" + self.js_api_forms\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded()\",\n self._get_disable_add_to_cart_script(),\n self._get_remove_top_items_panel_script(),\n ]\n\n def _get_disable_add_to_cart_script(self):\n \"\"\"\n Disables the 'Add to Cart' button on the service catalog page\n This is necessary so that agents running in parallel do not interfere with each other (cart is shared between sessions)\n\n \"\"\"\n script = \"\"\"\n function disableAddToCartButton() {\n waLog('Searching for top items panel...', 'disableAddToCartButton');\n let button = document.querySelector('button[aria-label=\"Add to Cart\"]');\n if (button) {\n button.disabled = true;\n waLog('WorkArena: Disabled the \"Add to Cart\" button', 'disableAddToCartButton');\n } else {\n waLog('WorkArena: Could not find the \"Add to Cart\" button', 'disableAddToCartButton');\n }\n }\n\n runInGsftMainOnlyAndProtectByURL(disableAddToCartButton, 'glideapp.servicecatalog_cat_item_view.do');\n \"\"\"\n return script\n\n def _get_remove_top_items_panel_script(self):\n \"\"\"Get script that removes the 'top items' panel that sometimes on the landing page of service catalog\n Disables the 'Top Requests' panel that sometimes appears on the landing page of the service catalog\n Runs in a loop to keep checking for the host element and shadow root\n URL is secured by running only on the catalog_home page; this is a heuristic to avoid running on other pages\n and does not check that the URL is an exact match, as moving back and forth between pages can cause the URL\n to change, but catalog_home will always be present.\n \"\"\"\n script = \"\"\"\n function removeTopItemsPanel() {\n waLog('Searching for top items panel...', 'removeTopItemsPanel');\n let headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n headings.forEach((heading) => {\n if (heading.textContent.includes(\"Top Requests\")) {\n let parentDiv = heading.closest('div.drag_section');\n if (parentDiv) {\n parentDiv.remove();\n waLog('Removed parent div for heading: ' + heading.textContent, 'removeTopItemsPanel');\n }\n }\n });\n }\n\n runInGsftMainOnlyAndProtectByURL(removeTopItemsPanel, `catalog_home`);\n \"\"\"\n return script\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n assert self.all_configs is not None, \"No configuration available for the task.\"\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.requested_item = self.config[\"item\"]\n self.short_description = self.config[\"description\"]\n self.quantity = self.config[\"quantity\"]\n self.requested_configuration = self.config[\"configuration\"]\n\n # Generate goal\n if self.config_only_in_desc:\n goal = self.get_pretty_printed_description()\n else:\n goal = f'Go to the hardware store and order {self.quantity} \"{self.requested_item}\"'\n if len(self.requested_configuration) > 0:\n goal += f\" with configuration {dict((k, v[1]) for k, v in self.requested_configuration.items())}\"\n info = {}\n\n # Used to keep track of the sysid of the request for validation\n self.request_sysid = None\n\n return goal, info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page=page)\n\n iframe = page.frame(self.js_prefix)\n\n # Find hardware buttons\n element = iframe.wait_for_selector(\"a:text('Hardware')\", strict=True)\n element.click()\n self._wait_for_ready(page=page)\n\n element = iframe.wait_for_selector(f\"h2:has-text('{self.requested_item}')\", strict=True)\n element.click()\n self._wait_for_ready(page=page, wait_for_form_api=True)\n\n quantity_input = iframe.wait_for_selector(\"#quantity\", strict=True)\n quantity_input.select_option(str(self.quantity))\n\n editable_fields = page.evaluate(f\"{self.form_js_selector}.getEditableFields()\")\n\n lookup_map = {}\n for idx, field in enumerate(editable_fields):\n control_text = self._get_control_description(page, field)\n lookup_map[control_text] = field\n\n for field_label, (element, value) in self.requested_configuration.items():\n element_id = lookup_map[field_label]\n control_type = page.evaluate(f\"{self.form_js_selector}.getControl('{element_id}').type\")\n\n if control_type in (\"radio\",):\n num_options = page.evaluate(\n f\"{self.form_js_selector}.getControls('{element_id}').length\"\n )\n for i in range(num_options):\n control_handle = page.evaluate_handle(\n f\"{self.form_js_selector}.getControls('{element_id}')[{i}]\"\n )\n control_text = control_handle.evaluate(\"e => e.parentElement.innerText\")\n if control_text.startswith(\n value\n ): # the page changes the text dynamically adding subtract/add to the text\n control_id = control_handle.get_attribute(\"id\")\n iframe.wait_for_selector(f'label[for=\"{control_id}\"]', strict=True).click()\n break\n elif control_type == \"hidden\":\n element_control = page.evaluate_handle(\n f\"{self.form_js_selector}.getControl('{element_id}')\"\n )\n element_value = element_control.evaluate(\"e => e.value\")\n if element_value != str(value).lower():\n label_id = f\"ni.{element_id}_label\"\n element_label = iframe.wait_for_selector(\n f'label[id=\"{label_id}\"]', strict=True, timeout=1_000\n )\n element_label.click()\n elif control_type in (\"textarea\", \"text\"):\n element_control = page.evaluate_handle(\n f\"{self.form_js_selector}.getControl('{element_id}')\"\n ).as_element() # this look superfluous\n element_id = element_control.get_attribute(\"id\") # this look superfluous\n text_element = iframe.query_selector(f'[id=\"{element_id}\"]')\n text_element.click()\n fill_text(page=page, input_field=text_element, value=value, iframe=iframe)\n\n elif control_type == \"select-one\":\n iframe.locator(f\"id={element_id}\").select_option(value)\n else:\n raise ValueError(f\"Unknown control type {control_type}\")\n\n order_now_button = iframe.wait_for_selector(\"#oi_order_now_button\", strict=True)\n\n with page.expect_navigation():\n order_now_button.click()\n\n def _generate_random_config(self, page: Page):\n \"\"\"Generate a random configuration for the task\"\"\"\n self.task_is_setup = (\n False # This is a hack to avoid raising an exception in the setup method\n )\n self.setup(page=page, do_start=False)\n if self.fixed_request_item:\n self.requested_item = self.fixed_request_item\n else:\n # ... choose a random item to order\n self.requested_item = self.random.choice(list(META_CONFIGS.keys()))\n\n meta_config = META_CONFIGS[self.requested_item]\n self.fixed_config = {\n \"item\": self.requested_item,\n \"description\": meta_config[\"desc\"],\n \"quantity\": self.random.randint(1, 11),\n \"configuration\": {\n ctrl_name: (ctrl_type, self.random.choice(values))\n for ctrl_name, (ctrl_type, values) in meta_config[\"options\"].items()\n },\n }\n self.setup(page=page, do_start=True)\n\n def _get_control_description(self, page, field):\n \"\"\"\n Get the description of a control (e.g., the text of a radio button)\n \"\"\"\n # Wait for everything to be ready\n self._wait_for_ready(page, wait_for_form_api=True)\n\n control_type = page.evaluate(f\"{self.form_js_selector}.getControl('{field}').type\")\n if control_type in (\"radio\", \"select-one\"):\n return page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\")\n elif control_type in (\"textarea\", \"hidden\", \"text\"):\n control_handle = page.evaluate_handle(f\"{self.form_js_selector}.getControl('{field}')\")\n # The control text is not always in the control itself, but in a parent element.\n # Being a heuristic, we try to find it by going up the DOM tree.\n # This is up to the page implementation, 5 is an arbitrary number.\n for depth in range(5):\n control_text = control_handle.evaluate(\"e => e.innerText\")\n if control_text != \"\":\n break\n control_handle = control_handle.evaluate_handle(\"e => e.parentElement\")\n else:\n raise ValueError(f\"Could not find control text for {field}\")\n else:\n raise ValueError(f\"Unknown control type {control_type}\")\n return control_text\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n task_specs = {\n \"Quantity\": self.config[\"quantity\"],\n \"Configuration\": self.config[\"configuration\"],\n }\n if self.config_only_in_desc:\n task_info = f\"- Order the item in the following quantities and with the following configuration:\\n\"\n else:\n task_specs[\"Description\"] = self.config[\"description\"]\n task_info = f\"- {class_name_formatted} with the following specifications:\\n\"\n for k, v in task_specs.items():\n # Some values might be empty - like the configuration of the apple watch. It is more natural to exclude them\n if not v:\n continue\n # If the value is a dictionary, print it in a nested way\n if isinstance(v, dict):\n task_info += f\" - {k}:\\n\"\n for k2, v2 in v.items():\n task_info += f\" - {k2}: {v2[1]}\\n\"\n else:\n task_info += f\" - {k}: {v}\\n\"\n\n return task_info\n\n def teardown(self) -> None:\n \"\"\"\n Deletes the request (and automatically all its items)\n \"\"\"\n self._wait_for_ready(self.page)\n\n if hasattr(self, \"request_sysid\") and self.request_sysid is not None:\n db_delete_from_table(\n instance=self.instance, sys_id=self.request_sysid, table=\"sc_request\"\n )\n\n def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str, dict]:\n\n # Retrieve the request sysid from the URL\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n (self.request_sysid,) = parse.parse_qs(current_url.query).get(\"sysparm_sys_id\", [None])\n if self.request_sysid is None:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The request was not created, the sysid is not in the URL.\"},\n )\n\n # Short sleep to make sure the data is saved in the DB\n # TODO: improve this (noted in issue 291)\n sleep(3)\n r = get_request_by_id(instance=self.instance, sysid=self.request_sysid)\n if r is None:\n return 0, False, \"\", {\"message\": \"The request is not in the database.\"}\n\n if len(r[\"items\"]) == 0:\n return 0, False, \"\", {\"message\": \"No items were requested.\"}\n\n if len(r[\"items\"]) > 1:\n error_msg = (\n \"Multiple kinds of items were requested, but only a single one was expected.\"\n )\n return (\n 0,\n True,\n error_msg,\n {\"message\": error_msg},\n )\n else:\n (first_item,) = r[\"items\"]\n\n if first_item[\"short_description\"].lower() != self.short_description.lower():\n error_msg = \"The requested item is incorrect.\"\n return 0, True, error_msg, {\"message\": error_msg}\n\n if first_item[\"quantity\"] != str(self.quantity):\n error_msg = \"The requested quantity is incorrect.\"\n return 0, True, error_msg, {\"message\": error_msg}\n\n options = first_item[\"options\"]\n for k, (element_type, value) in self.requested_configuration.items():\n if element_type == \"checkbox\" or element_type == \"radio\":\n if not option_match_heuristic(value, options[k]):\n error_msg = (\n f\"The requested {k} is incorrect, expected {value} but got {options[k]}.\"\n )\n return (\n 0,\n True,\n error_msg,\n {\"message\": error_msg},\n )\n elif element_type == \"textarea\":\n if value.lower() not in options[k].lower():\n error_msg = (\n f\"The requested {k} is incorrect, expected {value} but got {options[k]}.\"\n )\n return (\n 0,\n True,\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n\ndef option_match_heuristic(value, option):\n def _process(x):\n x = str(x).lower()\n x = x.replace(\"_\", \"\")\n x = x.replace(\" \", \"\")\n return x\n\n return _process(value) == _process(option)\n\n\nclass OrderDeveloperLaptopTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Developer Laptop (Mac)\",\n **kwargs,","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.option_match_heuristic","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.option_match_heuristic#L551-L558","kind":"function","name":"option_match_heuristic","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":551,"end_line":558,"context_start_line":531,"context_end_line":578,"code":" elif element_type == \"textarea\":\n if value.lower() not in options[k].lower():\n error_msg = (\n f\"The requested {k} is incorrect, expected {value} but got {options[k]}.\"\n )\n return (\n 0,\n True,\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n\ndef option_match_heuristic(value, option):\n def _process(x):\n x = str(x).lower()\n x = x.replace(\"_\", \"\")\n x = x.replace(\" \", \"\")\n return x\n\n return _process(value) == _process(option)\n\n\nclass OrderDeveloperLaptopTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Developer Laptop (Mac)\",\n **kwargs,\n )\n\n\nclass OrderIpadMiniTask(OrderHardwareTask):\n config_path = ORDER_IPAD_MINI_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad mini\",","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderDeveloperLaptopTask#L561-L569","kind":"class","name":"OrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":561,"end_line":569,"context_start_line":541,"context_end_line":589,"code":" )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n\ndef option_match_heuristic(value, option):\n def _process(x):\n x = str(x).lower()\n x = x.replace(\"_\", \"\")\n x = x.replace(\" \", \"\")\n return x\n\n return _process(value) == _process(option)\n\n\nclass OrderDeveloperLaptopTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Developer Laptop (Mac)\",\n **kwargs,\n )\n\n\nclass OrderIpadMiniTask(OrderHardwareTask):\n config_path = ORDER_IPAD_MINI_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad mini\",\n **kwargs,\n )\n\n\nclass OrderIpadProTask(OrderHardwareTask):\n config_path = ORDER_IPAD_PRO_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad pro\",","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderIpadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderIpadMiniTask#L572-L580","kind":"class","name":"OrderIpadMiniTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":572,"end_line":580,"context_start_line":552,"context_end_line":600,"code":" def _process(x):\n x = str(x).lower()\n x = x.replace(\"_\", \"\")\n x = x.replace(\" \", \"\")\n return x\n\n return _process(value) == _process(option)\n\n\nclass OrderDeveloperLaptopTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Developer Laptop (Mac)\",\n **kwargs,\n )\n\n\nclass OrderIpadMiniTask(OrderHardwareTask):\n config_path = ORDER_IPAD_MINI_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad mini\",\n **kwargs,\n )\n\n\nclass OrderIpadProTask(OrderHardwareTask):\n config_path = ORDER_IPAD_PRO_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad pro\",\n **kwargs,\n )\n\n\nclass OrderSalesLaptopTask(OrderHardwareTask):\n config_path = ORDER_SALES_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Sales Laptop\",","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderIpadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderIpadProTask#L583-L591","kind":"class","name":"OrderIpadProTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":583,"end_line":591,"context_start_line":563,"context_end_line":611,"code":"\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Developer Laptop (Mac)\",\n **kwargs,\n )\n\n\nclass OrderIpadMiniTask(OrderHardwareTask):\n config_path = ORDER_IPAD_MINI_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad mini\",\n **kwargs,\n )\n\n\nclass OrderIpadProTask(OrderHardwareTask):\n config_path = ORDER_IPAD_PRO_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad pro\",\n **kwargs,\n )\n\n\nclass OrderSalesLaptopTask(OrderHardwareTask):\n config_path = ORDER_SALES_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Sales Laptop\",\n **kwargs,\n )\n\n\nclass OrderStandardLaptopTask(OrderHardwareTask):\n config_path = ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Standard Laptop\",","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderSalesLaptopTask#L594-L602","kind":"class","name":"OrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":594,"end_line":602,"context_start_line":574,"context_end_line":622,"code":"\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad mini\",\n **kwargs,\n )\n\n\nclass OrderIpadProTask(OrderHardwareTask):\n config_path = ORDER_IPAD_PRO_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad pro\",\n **kwargs,\n )\n\n\nclass OrderSalesLaptopTask(OrderHardwareTask):\n config_path = ORDER_SALES_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Sales Laptop\",\n **kwargs,\n )\n\n\nclass OrderStandardLaptopTask(OrderHardwareTask):\n config_path = ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Standard Laptop\",\n **kwargs,\n )\n\n\nclass OrderAppleWatchTask(OrderHardwareTask):\n config_path = ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple Watch\",","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderStandardLaptopTask#L605-L613","kind":"class","name":"OrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":605,"end_line":613,"context_start_line":585,"context_end_line":633,"code":"\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"iPad pro\",\n **kwargs,\n )\n\n\nclass OrderSalesLaptopTask(OrderHardwareTask):\n config_path = ORDER_SALES_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Sales Laptop\",\n **kwargs,\n )\n\n\nclass OrderStandardLaptopTask(OrderHardwareTask):\n config_path = ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Standard Laptop\",\n **kwargs,\n )\n\n\nclass OrderAppleWatchTask(OrderHardwareTask):\n config_path = ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple Watch\",\n **kwargs,\n )\n\n\nclass OrderAppleMacBookPro15Task(OrderHardwareTask):\n config_path = ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple MacBook Pro 15\",","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderAppleWatchTask#L616-L624","kind":"class","name":"OrderAppleWatchTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":616,"end_line":624,"context_start_line":596,"context_end_line":644,"code":"\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Sales Laptop\",\n **kwargs,\n )\n\n\nclass OrderStandardLaptopTask(OrderHardwareTask):\n config_path = ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Standard Laptop\",\n **kwargs,\n )\n\n\nclass OrderAppleWatchTask(OrderHardwareTask):\n config_path = ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple Watch\",\n **kwargs,\n )\n\n\nclass OrderAppleMacBookPro15Task(OrderHardwareTask):\n config_path = ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple MacBook Pro 15\",\n **kwargs,\n )\n\n\nclass OrderDevelopmentLaptopPCTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Development Laptop (PC)\",","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderAppleMacBookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderAppleMacBookPro15Task#L627-L635","kind":"class","name":"OrderAppleMacBookPro15Task","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":627,"end_line":635,"context_start_line":607,"context_end_line":655,"code":"\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Standard Laptop\",\n **kwargs,\n )\n\n\nclass OrderAppleWatchTask(OrderHardwareTask):\n config_path = ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple Watch\",\n **kwargs,\n )\n\n\nclass OrderAppleMacBookPro15Task(OrderHardwareTask):\n config_path = ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple MacBook Pro 15\",\n **kwargs,\n )\n\n\nclass OrderDevelopmentLaptopPCTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Development Laptop (PC)\",\n **kwargs,\n )\n\n\nclass OrderLoanerLaptopTask(OrderHardwareTask):\n config_path = ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Loaner Laptop\",","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderDevelopmentLaptopPCTask#L638-L646","kind":"class","name":"OrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":638,"end_line":646,"context_start_line":618,"context_end_line":664,"code":"\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple Watch\",\n **kwargs,\n )\n\n\nclass OrderAppleMacBookPro15Task(OrderHardwareTask):\n config_path = ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple MacBook Pro 15\",\n **kwargs,\n )\n\n\nclass OrderDevelopmentLaptopPCTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Development Laptop (PC)\",\n **kwargs,\n )\n\n\nclass OrderLoanerLaptopTask(OrderHardwareTask):\n config_path = ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Loaner Laptop\",\n **kwargs,\n )\n\n\n__TASKS__ = [\n var\n for var in locals().values()\n if isinstance(var, type) and issubclass(var, OrderHardwareTask) and var is not OrderHardwareTask\n]","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.OrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.service_catalog.OrderLoanerLaptopTask#L649-L657","kind":"class","name":"OrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":649,"end_line":657,"context_start_line":629,"context_end_line":664,"code":"\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Apple MacBook Pro 15\",\n **kwargs,\n )\n\n\nclass OrderDevelopmentLaptopPCTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Development Laptop (PC)\",\n **kwargs,\n )\n\n\nclass OrderLoanerLaptopTask(OrderHardwareTask):\n config_path = ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Loaner Laptop\",\n **kwargs,\n )\n\n\n__TASKS__ = [\n var\n for var in locals().values()\n if isinstance(var, type) and issubclass(var, OrderHardwareTask) and var is not OrderHardwareTask\n]","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.__init__#L652-L657","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":652,"end_line":657,"context_start_line":632,"context_end_line":664,"code":" *args,\n fixed_request_item=\"Apple MacBook Pro 15\",\n **kwargs,\n )\n\n\nclass OrderDevelopmentLaptopPCTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Development Laptop (PC)\",\n **kwargs,\n )\n\n\nclass OrderLoanerLaptopTask(OrderHardwareTask):\n config_path = ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Loaner Laptop\",\n **kwargs,\n )\n\n\n__TASKS__ = [\n var\n for var in locals().values()\n if isinstance(var, type) and issubclass(var, OrderHardwareTask) and var is not OrderHardwareTask\n]","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.all_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.all_configs#L199-L201","kind":"function","name":"all_configs","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":199,"end_line":201,"context_start_line":179,"context_end_line":221,"code":" instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/catalog_home.do%3Fsysparm_view%3Dcatalog_default\",\n final_rel_url=\"/now/nav/ui/classic/params/target/com.glideapp.servicecatalog_checkout_view_v2.do\",\n )\n\n if fixed_request_item is not None and fixed_config is not None:\n if fixed_request_item != fixed_config[\"item\"]:\n raise ValueError(f\"'fixed_request_item' and 'fixed_config[\\\"item\\\"]' do not match\")\n\n self.fixed_config = fixed_config\n self.config = None\n self.fixed_request_item = fixed_request_item\n self.config_only_in_desc = config_only_in_desc\n\n self.js_prefix = \"gsft_main\"\n self.js_api_forms = \"g_form\"\n self.all_configs = self.all_configs()\n self.__dict__.update(kwargs)\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _wait_for_ready(self, page: Page, wait_for_form_api: bool = False) -> None:\n \"\"\"\n Waits for the the main iframe to be loaded\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if wait_for_form_api:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n @property\n def form_js_selector(self):\n return self.js_prefix + \".\" + self.js_api_forms","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog._wait_for_ready","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog._wait_for_ready#L203-L217","kind":"function","name":"_wait_for_ready","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":203,"end_line":217,"context_start_line":183,"context_end_line":237,"code":"\n if fixed_request_item is not None and fixed_config is not None:\n if fixed_request_item != fixed_config[\"item\"]:\n raise ValueError(f\"'fixed_request_item' and 'fixed_config[\\\"item\\\"]' do not match\")\n\n self.fixed_config = fixed_config\n self.config = None\n self.fixed_request_item = fixed_request_item\n self.config_only_in_desc = config_only_in_desc\n\n self.js_prefix = \"gsft_main\"\n self.js_api_forms = \"g_form\"\n self.all_configs = self.all_configs()\n self.__dict__.update(kwargs)\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _wait_for_ready(self, page: Page, wait_for_form_api: bool = False) -> None:\n \"\"\"\n Waits for the the main iframe to be loaded\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if wait_for_form_api:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n @property\n def form_js_selector(self):\n return self.js_prefix + \".\" + self.js_api_forms\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded()\",\n self._get_disable_add_to_cart_script(),\n self._get_remove_top_items_panel_script(),\n ]\n\n def _get_disable_add_to_cart_script(self):\n \"\"\"\n Disables the 'Add to Cart' button on the service catalog page\n This is necessary so that agents running in parallel do not interfere with each other (cart is shared between sessions)\n\n \"\"\"\n script = \"\"\"\n function disableAddToCartButton() {","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.form_js_selector","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.form_js_selector#L220-L221","kind":"function","name":"form_js_selector","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":220,"end_line":221,"context_start_line":200,"context_end_line":241,"code":" with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _wait_for_ready(self, page: Page, wait_for_form_api: bool = False) -> None:\n \"\"\"\n Waits for the the main iframe to be loaded\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if wait_for_form_api:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n @property\n def form_js_selector(self):\n return self.js_prefix + \".\" + self.js_api_forms\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded()\",\n self._get_disable_add_to_cart_script(),\n self._get_remove_top_items_panel_script(),\n ]\n\n def _get_disable_add_to_cart_script(self):\n \"\"\"\n Disables the 'Add to Cart' button on the service catalog page\n This is necessary so that agents running in parallel do not interfere with each other (cart is shared between sessions)\n\n \"\"\"\n script = \"\"\"\n function disableAddToCartButton() {\n waLog('Searching for top items panel...', 'disableAddToCartButton');\n let button = document.querySelector('button[aria-label=\"Add to Cart\"]');\n if (button) {\n button.disabled = true;","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.get_init_scripts","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.get_init_scripts#L223-L228","kind":"function","name":"get_init_scripts","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":223,"end_line":228,"context_start_line":203,"context_end_line":248,"code":" def _wait_for_ready(self, page: Page, wait_for_form_api: bool = False) -> None:\n \"\"\"\n Waits for the the main iframe to be loaded\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if wait_for_form_api:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n @property\n def form_js_selector(self):\n return self.js_prefix + \".\" + self.js_api_forms\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded()\",\n self._get_disable_add_to_cart_script(),\n self._get_remove_top_items_panel_script(),\n ]\n\n def _get_disable_add_to_cart_script(self):\n \"\"\"\n Disables the 'Add to Cart' button on the service catalog page\n This is necessary so that agents running in parallel do not interfere with each other (cart is shared between sessions)\n\n \"\"\"\n script = \"\"\"\n function disableAddToCartButton() {\n waLog('Searching for top items panel...', 'disableAddToCartButton');\n let button = document.querySelector('button[aria-label=\"Add to Cart\"]');\n if (button) {\n button.disabled = true;\n waLog('WorkArena: Disabled the \"Add to Cart\" button', 'disableAddToCartButton');\n } else {\n waLog('WorkArena: Could not find the \"Add to Cart\" button', 'disableAddToCartButton');\n }\n }\n\n runInGsftMainOnlyAndProtectByURL(disableAddToCartButton, 'glideapp.servicecatalog_cat_item_view.do');","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog._get_disable_add_to_cart_script","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog._get_disable_add_to_cart_script#L230-L250","kind":"function","name":"_get_disable_add_to_cart_script","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":230,"end_line":250,"context_start_line":210,"context_end_line":270,"code":" f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if wait_for_form_api:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n @property\n def form_js_selector(self):\n return self.js_prefix + \".\" + self.js_api_forms\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded()\",\n self._get_disable_add_to_cart_script(),\n self._get_remove_top_items_panel_script(),\n ]\n\n def _get_disable_add_to_cart_script(self):\n \"\"\"\n Disables the 'Add to Cart' button on the service catalog page\n This is necessary so that agents running in parallel do not interfere with each other (cart is shared between sessions)\n\n \"\"\"\n script = \"\"\"\n function disableAddToCartButton() {\n waLog('Searching for top items panel...', 'disableAddToCartButton');\n let button = document.querySelector('button[aria-label=\"Add to Cart\"]');\n if (button) {\n button.disabled = true;\n waLog('WorkArena: Disabled the \"Add to Cart\" button', 'disableAddToCartButton');\n } else {\n waLog('WorkArena: Could not find the \"Add to Cart\" button', 'disableAddToCartButton');\n }\n }\n\n runInGsftMainOnlyAndProtectByURL(disableAddToCartButton, 'glideapp.servicecatalog_cat_item_view.do');\n \"\"\"\n return script\n\n def _get_remove_top_items_panel_script(self):\n \"\"\"Get script that removes the 'top items' panel that sometimes on the landing page of service catalog\n Disables the 'Top Requests' panel that sometimes appears on the landing page of the service catalog\n Runs in a loop to keep checking for the host element and shadow root\n URL is secured by running only on the catalog_home page; this is a heuristic to avoid running on other pages\n and does not check that the URL is an exact match, as moving back and forth between pages can cause the URL\n to change, but catalog_home will always be present.\n \"\"\"\n script = \"\"\"\n function removeTopItemsPanel() {\n waLog('Searching for top items panel...', 'removeTopItemsPanel');\n let headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n headings.forEach((heading) => {\n if (heading.textContent.includes(\"Top Requests\")) {\n let parentDiv = heading.closest('div.drag_section');\n if (parentDiv) {\n parentDiv.remove();\n waLog('Removed parent div for heading: ' + heading.textContent, 'removeTopItemsPanel');\n }","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog._get_remove_top_items_panel_script","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog._get_remove_top_items_panel_script#L252-L277","kind":"function","name":"_get_remove_top_items_panel_script","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":252,"end_line":277,"context_start_line":232,"context_end_line":297,"code":" Disables the 'Add to Cart' button on the service catalog page\n This is necessary so that agents running in parallel do not interfere with each other (cart is shared between sessions)\n\n \"\"\"\n script = \"\"\"\n function disableAddToCartButton() {\n waLog('Searching for top items panel...', 'disableAddToCartButton');\n let button = document.querySelector('button[aria-label=\"Add to Cart\"]');\n if (button) {\n button.disabled = true;\n waLog('WorkArena: Disabled the \"Add to Cart\" button', 'disableAddToCartButton');\n } else {\n waLog('WorkArena: Could not find the \"Add to Cart\" button', 'disableAddToCartButton');\n }\n }\n\n runInGsftMainOnlyAndProtectByURL(disableAddToCartButton, 'glideapp.servicecatalog_cat_item_view.do');\n \"\"\"\n return script\n\n def _get_remove_top_items_panel_script(self):\n \"\"\"Get script that removes the 'top items' panel that sometimes on the landing page of service catalog\n Disables the 'Top Requests' panel that sometimes appears on the landing page of the service catalog\n Runs in a loop to keep checking for the host element and shadow root\n URL is secured by running only on the catalog_home page; this is a heuristic to avoid running on other pages\n and does not check that the URL is an exact match, as moving back and forth between pages can cause the URL\n to change, but catalog_home will always be present.\n \"\"\"\n script = \"\"\"\n function removeTopItemsPanel() {\n waLog('Searching for top items panel...', 'removeTopItemsPanel');\n let headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n headings.forEach((heading) => {\n if (heading.textContent.includes(\"Top Requests\")) {\n let parentDiv = heading.closest('div.drag_section');\n if (parentDiv) {\n parentDiv.remove();\n waLog('Removed parent div for heading: ' + heading.textContent, 'removeTopItemsPanel');\n }\n }\n });\n }\n\n runInGsftMainOnlyAndProtectByURL(removeTopItemsPanel, `catalog_home`);\n \"\"\"\n return script\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n assert self.all_configs is not None, \"No configuration available for the task.\"\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.requested_item = self.config[\"item\"]\n self.short_description = self.config[\"description\"]\n self.quantity = self.config[\"quantity\"]\n self.requested_configuration = self.config[\"configuration\"]\n\n # Generate goal\n if self.config_only_in_desc:\n goal = self.get_pretty_printed_description()\n else:\n goal = f'Go to the hardware store and order {self.quantity} \"{self.requested_item}\"'\n if len(self.requested_configuration) > 0:","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.setup_goal#L279-L304","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":279,"end_line":304,"context_start_line":259,"context_end_line":324,"code":" \"\"\"\n script = \"\"\"\n function removeTopItemsPanel() {\n waLog('Searching for top items panel...', 'removeTopItemsPanel');\n let headings = Array.from(document.querySelectorAll('[role=\"heading\"]'));\n headings.forEach((heading) => {\n if (heading.textContent.includes(\"Top Requests\")) {\n let parentDiv = heading.closest('div.drag_section');\n if (parentDiv) {\n parentDiv.remove();\n waLog('Removed parent div for heading: ' + heading.textContent, 'removeTopItemsPanel');\n }\n }\n });\n }\n\n runInGsftMainOnlyAndProtectByURL(removeTopItemsPanel, `catalog_home`);\n \"\"\"\n return script\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n assert self.all_configs is not None, \"No configuration available for the task.\"\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.requested_item = self.config[\"item\"]\n self.short_description = self.config[\"description\"]\n self.quantity = self.config[\"quantity\"]\n self.requested_configuration = self.config[\"configuration\"]\n\n # Generate goal\n if self.config_only_in_desc:\n goal = self.get_pretty_printed_description()\n else:\n goal = f'Go to the hardware store and order {self.quantity} \"{self.requested_item}\"'\n if len(self.requested_configuration) > 0:\n goal += f\" with configuration {dict((k, v[1]) for k, v in self.requested_configuration.items())}\"\n info = {}\n\n # Used to keep track of the sysid of the request for validation\n self.request_sysid = None\n\n return goal, info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page=page)\n\n iframe = page.frame(self.js_prefix)\n\n # Find hardware buttons\n element = iframe.wait_for_selector(\"a:text('Hardware')\", strict=True)\n element.click()\n self._wait_for_ready(page=page)\n\n element = iframe.wait_for_selector(f\"h2:has-text('{self.requested_item}')\", strict=True)\n element.click()\n self._wait_for_ready(page=page, wait_for_form_api=True)\n\n quantity_input = iframe.wait_for_selector(\"#quantity\", strict=True)\n quantity_input.select_option(str(self.quantity))\n\n editable_fields = page.evaluate(f\"{self.form_js_selector}.getEditableFields()\")","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.cheat#L306-L378","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":306,"end_line":378,"context_start_line":286,"context_end_line":398,"code":" )\n self.requested_item = self.config[\"item\"]\n self.short_description = self.config[\"description\"]\n self.quantity = self.config[\"quantity\"]\n self.requested_configuration = self.config[\"configuration\"]\n\n # Generate goal\n if self.config_only_in_desc:\n goal = self.get_pretty_printed_description()\n else:\n goal = f'Go to the hardware store and order {self.quantity} \"{self.requested_item}\"'\n if len(self.requested_configuration) > 0:\n goal += f\" with configuration {dict((k, v[1]) for k, v in self.requested_configuration.items())}\"\n info = {}\n\n # Used to keep track of the sysid of the request for validation\n self.request_sysid = None\n\n return goal, info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page=page)\n\n iframe = page.frame(self.js_prefix)\n\n # Find hardware buttons\n element = iframe.wait_for_selector(\"a:text('Hardware')\", strict=True)\n element.click()\n self._wait_for_ready(page=page)\n\n element = iframe.wait_for_selector(f\"h2:has-text('{self.requested_item}')\", strict=True)\n element.click()\n self._wait_for_ready(page=page, wait_for_form_api=True)\n\n quantity_input = iframe.wait_for_selector(\"#quantity\", strict=True)\n quantity_input.select_option(str(self.quantity))\n\n editable_fields = page.evaluate(f\"{self.form_js_selector}.getEditableFields()\")\n\n lookup_map = {}\n for idx, field in enumerate(editable_fields):\n control_text = self._get_control_description(page, field)\n lookup_map[control_text] = field\n\n for field_label, (element, value) in self.requested_configuration.items():\n element_id = lookup_map[field_label]\n control_type = page.evaluate(f\"{self.form_js_selector}.getControl('{element_id}').type\")\n\n if control_type in (\"radio\",):\n num_options = page.evaluate(\n f\"{self.form_js_selector}.getControls('{element_id}').length\"\n )\n for i in range(num_options):\n control_handle = page.evaluate_handle(\n f\"{self.form_js_selector}.getControls('{element_id}')[{i}]\"\n )\n control_text = control_handle.evaluate(\"e => e.parentElement.innerText\")\n if control_text.startswith(\n value\n ): # the page changes the text dynamically adding subtract/add to the text\n control_id = control_handle.get_attribute(\"id\")\n iframe.wait_for_selector(f'label[for=\"{control_id}\"]', strict=True).click()\n break\n elif control_type == \"hidden\":\n element_control = page.evaluate_handle(\n f\"{self.form_js_selector}.getControl('{element_id}')\"\n )\n element_value = element_control.evaluate(\"e => e.value\")\n if element_value != str(value).lower():\n label_id = f\"ni.{element_id}_label\"\n element_label = iframe.wait_for_selector(\n f'label[id=\"{label_id}\"]', strict=True, timeout=1_000\n )\n element_label.click()\n elif control_type in (\"textarea\", \"text\"):\n element_control = page.evaluate_handle(\n f\"{self.form_js_selector}.getControl('{element_id}')\"\n ).as_element() # this look superfluous\n element_id = element_control.get_attribute(\"id\") # this look superfluous\n text_element = iframe.query_selector(f'[id=\"{element_id}\"]')\n text_element.click()\n fill_text(page=page, input_field=text_element, value=value, iframe=iframe)\n\n elif control_type == \"select-one\":\n iframe.locator(f\"id={element_id}\").select_option(value)\n else:\n raise ValueError(f\"Unknown control type {control_type}\")\n\n order_now_button = iframe.wait_for_selector(\"#oi_order_now_button\", strict=True)\n\n with page.expect_navigation():\n order_now_button.click()\n\n def _generate_random_config(self, page: Page):\n \"\"\"Generate a random configuration for the task\"\"\"\n self.task_is_setup = (\n False # This is a hack to avoid raising an exception in the setup method\n )\n self.setup(page=page, do_start=False)\n if self.fixed_request_item:\n self.requested_item = self.fixed_request_item\n else:\n # ... choose a random item to order\n self.requested_item = self.random.choice(list(META_CONFIGS.keys()))\n\n meta_config = META_CONFIGS[self.requested_item]\n self.fixed_config = {\n \"item\": self.requested_item,\n \"description\": meta_config[\"desc\"],\n \"quantity\": self.random.randint(1, 11),\n \"configuration\": {\n ctrl_name: (ctrl_type, self.random.choice(values))","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog._generate_random_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog._generate_random_config#L380-L402","kind":"function","name":"_generate_random_config","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":380,"end_line":402,"context_start_line":360,"context_end_line":422,"code":" element_label.click()\n elif control_type in (\"textarea\", \"text\"):\n element_control = page.evaluate_handle(\n f\"{self.form_js_selector}.getControl('{element_id}')\"\n ).as_element() # this look superfluous\n element_id = element_control.get_attribute(\"id\") # this look superfluous\n text_element = iframe.query_selector(f'[id=\"{element_id}\"]')\n text_element.click()\n fill_text(page=page, input_field=text_element, value=value, iframe=iframe)\n\n elif control_type == \"select-one\":\n iframe.locator(f\"id={element_id}\").select_option(value)\n else:\n raise ValueError(f\"Unknown control type {control_type}\")\n\n order_now_button = iframe.wait_for_selector(\"#oi_order_now_button\", strict=True)\n\n with page.expect_navigation():\n order_now_button.click()\n\n def _generate_random_config(self, page: Page):\n \"\"\"Generate a random configuration for the task\"\"\"\n self.task_is_setup = (\n False # This is a hack to avoid raising an exception in the setup method\n )\n self.setup(page=page, do_start=False)\n if self.fixed_request_item:\n self.requested_item = self.fixed_request_item\n else:\n # ... choose a random item to order\n self.requested_item = self.random.choice(list(META_CONFIGS.keys()))\n\n meta_config = META_CONFIGS[self.requested_item]\n self.fixed_config = {\n \"item\": self.requested_item,\n \"description\": meta_config[\"desc\"],\n \"quantity\": self.random.randint(1, 11),\n \"configuration\": {\n ctrl_name: (ctrl_type, self.random.choice(values))\n for ctrl_name, (ctrl_type, values) in meta_config[\"options\"].items()\n },\n }\n self.setup(page=page, do_start=True)\n\n def _get_control_description(self, page, field):\n \"\"\"\n Get the description of a control (e.g., the text of a radio button)\n \"\"\"\n # Wait for everything to be ready\n self._wait_for_ready(page, wait_for_form_api=True)\n\n control_type = page.evaluate(f\"{self.form_js_selector}.getControl('{field}').type\")\n if control_type in (\"radio\", \"select-one\"):\n return page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\")\n elif control_type in (\"textarea\", \"hidden\", \"text\"):\n control_handle = page.evaluate_handle(f\"{self.form_js_selector}.getControl('{field}')\")\n # The control text is not always in the control itself, but in a parent element.\n # Being a heuristic, we try to find it by going up the DOM tree.\n # This is up to the page implementation, 5 is an arbitrary number.\n for depth in range(5):\n control_text = control_handle.evaluate(\"e => e.innerText\")\n if control_text != \"\":\n break","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog._get_control_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog._get_control_description#L404-L428","kind":"function","name":"_get_control_description","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":404,"end_line":428,"context_start_line":384,"context_end_line":448,"code":" )\n self.setup(page=page, do_start=False)\n if self.fixed_request_item:\n self.requested_item = self.fixed_request_item\n else:\n # ... choose a random item to order\n self.requested_item = self.random.choice(list(META_CONFIGS.keys()))\n\n meta_config = META_CONFIGS[self.requested_item]\n self.fixed_config = {\n \"item\": self.requested_item,\n \"description\": meta_config[\"desc\"],\n \"quantity\": self.random.randint(1, 11),\n \"configuration\": {\n ctrl_name: (ctrl_type, self.random.choice(values))\n for ctrl_name, (ctrl_type, values) in meta_config[\"options\"].items()\n },\n }\n self.setup(page=page, do_start=True)\n\n def _get_control_description(self, page, field):\n \"\"\"\n Get the description of a control (e.g., the text of a radio button)\n \"\"\"\n # Wait for everything to be ready\n self._wait_for_ready(page, wait_for_form_api=True)\n\n control_type = page.evaluate(f\"{self.form_js_selector}.getControl('{field}').type\")\n if control_type in (\"radio\", \"select-one\"):\n return page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\")\n elif control_type in (\"textarea\", \"hidden\", \"text\"):\n control_handle = page.evaluate_handle(f\"{self.form_js_selector}.getControl('{field}')\")\n # The control text is not always in the control itself, but in a parent element.\n # Being a heuristic, we try to find it by going up the DOM tree.\n # This is up to the page implementation, 5 is an arbitrary number.\n for depth in range(5):\n control_text = control_handle.evaluate(\"e => e.innerText\")\n if control_text != \"\":\n break\n control_handle = control_handle.evaluate_handle(\"e => e.parentElement\")\n else:\n raise ValueError(f\"Could not find control text for {field}\")\n else:\n raise ValueError(f\"Unknown control type {control_type}\")\n return control_text\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n task_specs = {\n \"Quantity\": self.config[\"quantity\"],\n \"Configuration\": self.config[\"configuration\"],\n }\n if self.config_only_in_desc:\n task_info = f\"- Order the item in the following quantities and with the following configuration:\\n\"\n else:\n task_specs[\"Description\"] = self.config[\"description\"]\n task_info = f\"- {class_name_formatted} with the following specifications:\\n\"","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.get_pretty_printed_description#L430-L461","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":430,"end_line":461,"context_start_line":410,"context_end_line":481,"code":"\n control_type = page.evaluate(f\"{self.form_js_selector}.getControl('{field}').type\")\n if control_type in (\"radio\", \"select-one\"):\n return page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\")\n elif control_type in (\"textarea\", \"hidden\", \"text\"):\n control_handle = page.evaluate_handle(f\"{self.form_js_selector}.getControl('{field}')\")\n # The control text is not always in the control itself, but in a parent element.\n # Being a heuristic, we try to find it by going up the DOM tree.\n # This is up to the page implementation, 5 is an arbitrary number.\n for depth in range(5):\n control_text = control_handle.evaluate(\"e => e.innerText\")\n if control_text != \"\":\n break\n control_handle = control_handle.evaluate_handle(\"e => e.parentElement\")\n else:\n raise ValueError(f\"Could not find control text for {field}\")\n else:\n raise ValueError(f\"Unknown control type {control_type}\")\n return control_text\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n task_specs = {\n \"Quantity\": self.config[\"quantity\"],\n \"Configuration\": self.config[\"configuration\"],\n }\n if self.config_only_in_desc:\n task_info = f\"- Order the item in the following quantities and with the following configuration:\\n\"\n else:\n task_specs[\"Description\"] = self.config[\"description\"]\n task_info = f\"- {class_name_formatted} with the following specifications:\\n\"\n for k, v in task_specs.items():\n # Some values might be empty - like the configuration of the apple watch. It is more natural to exclude them\n if not v:\n continue\n # If the value is a dictionary, print it in a nested way\n if isinstance(v, dict):\n task_info += f\" - {k}:\\n\"\n for k2, v2 in v.items():\n task_info += f\" - {k2}: {v2[1]}\\n\"\n else:\n task_info += f\" - {k}: {v}\\n\"\n\n return task_info\n\n def teardown(self) -> None:\n \"\"\"\n Deletes the request (and automatically all its items)\n \"\"\"\n self._wait_for_ready(self.page)\n\n if hasattr(self, \"request_sysid\") and self.request_sysid is not None:\n db_delete_from_table(\n instance=self.instance, sys_id=self.request_sysid, table=\"sc_request\"\n )\n\n def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str, dict]:\n\n # Retrieve the request sysid from the URL\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n (self.request_sysid,) = parse.parse_qs(current_url.query).get(\"sysparm_sys_id\", [None])\n if self.request_sysid is None:\n return (\n 0,","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.teardown#L463-L472","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":463,"end_line":472,"context_start_line":443,"context_end_line":492,"code":" }\n if self.config_only_in_desc:\n task_info = f\"- Order the item in the following quantities and with the following configuration:\\n\"\n else:\n task_specs[\"Description\"] = self.config[\"description\"]\n task_info = f\"- {class_name_formatted} with the following specifications:\\n\"\n for k, v in task_specs.items():\n # Some values might be empty - like the configuration of the apple watch. It is more natural to exclude them\n if not v:\n continue\n # If the value is a dictionary, print it in a nested way\n if isinstance(v, dict):\n task_info += f\" - {k}:\\n\"\n for k2, v2 in v.items():\n task_info += f\" - {k2}: {v2[1]}\\n\"\n else:\n task_info += f\" - {k}: {v}\\n\"\n\n return task_info\n\n def teardown(self) -> None:\n \"\"\"\n Deletes the request (and automatically all its items)\n \"\"\"\n self._wait_for_ready(self.page)\n\n if hasattr(self, \"request_sysid\") and self.request_sysid is not None:\n db_delete_from_table(\n instance=self.instance, sys_id=self.request_sysid, table=\"sc_request\"\n )\n\n def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str, dict]:\n\n # Retrieve the request sysid from the URL\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n (self.request_sysid,) = parse.parse_qs(current_url.query).get(\"sysparm_sys_id\", [None])\n if self.request_sysid is None:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The request was not created, the sysid is not in the URL.\"},\n )\n\n # Short sleep to make sure the data is saved in the DB\n # TODO: improve this (noted in issue 291)\n sleep(3)\n r = get_request_by_id(instance=self.instance, sysid=self.request_sysid)\n if r is None:\n return 0, False, \"\", {\"message\": \"The request is not in the database.\"}","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog.validate#L474-L548","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":474,"end_line":548,"context_start_line":454,"context_end_line":568,"code":" if isinstance(v, dict):\n task_info += f\" - {k}:\\n\"\n for k2, v2 in v.items():\n task_info += f\" - {k2}: {v2[1]}\\n\"\n else:\n task_info += f\" - {k}: {v}\\n\"\n\n return task_info\n\n def teardown(self) -> None:\n \"\"\"\n Deletes the request (and automatically all its items)\n \"\"\"\n self._wait_for_ready(self.page)\n\n if hasattr(self, \"request_sysid\") and self.request_sysid is not None:\n db_delete_from_table(\n instance=self.instance, sys_id=self.request_sysid, table=\"sc_request\"\n )\n\n def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str, dict]:\n\n # Retrieve the request sysid from the URL\n current_url = parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n (self.request_sysid,) = parse.parse_qs(current_url.query).get(\"sysparm_sys_id\", [None])\n if self.request_sysid is None:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The request was not created, the sysid is not in the URL.\"},\n )\n\n # Short sleep to make sure the data is saved in the DB\n # TODO: improve this (noted in issue 291)\n sleep(3)\n r = get_request_by_id(instance=self.instance, sysid=self.request_sysid)\n if r is None:\n return 0, False, \"\", {\"message\": \"The request is not in the database.\"}\n\n if len(r[\"items\"]) == 0:\n return 0, False, \"\", {\"message\": \"No items were requested.\"}\n\n if len(r[\"items\"]) > 1:\n error_msg = (\n \"Multiple kinds of items were requested, but only a single one was expected.\"\n )\n return (\n 0,\n True,\n error_msg,\n {\"message\": error_msg},\n )\n else:\n (first_item,) = r[\"items\"]\n\n if first_item[\"short_description\"].lower() != self.short_description.lower():\n error_msg = \"The requested item is incorrect.\"\n return 0, True, error_msg, {\"message\": error_msg}\n\n if first_item[\"quantity\"] != str(self.quantity):\n error_msg = \"The requested quantity is incorrect.\"\n return 0, True, error_msg, {\"message\": error_msg}\n\n options = first_item[\"options\"]\n for k, (element_type, value) in self.requested_configuration.items():\n if element_type == \"checkbox\" or element_type == \"radio\":\n if not option_match_heuristic(value, options[k]):\n error_msg = (\n f\"The requested {k} is incorrect, expected {value} but got {options[k]}.\"\n )\n return (\n 0,\n True,\n error_msg,\n {\"message\": error_msg},\n )\n elif element_type == \"textarea\":\n if value.lower() not in options[k].lower():\n error_msg = (\n f\"The requested {k} is incorrect, expected {value} but got {options[k]}.\"\n )\n return (\n 0,\n True,\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n\ndef option_match_heuristic(value, option):\n def _process(x):\n x = str(x).lower()\n x = x.replace(\"_\", \"\")\n x = x.replace(\" \", \"\")\n return x\n\n return _process(value) == _process(option)\n\n\nclass OrderDeveloperLaptopTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Developer Laptop (Mac)\",\n **kwargs,","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.service_catalog._process","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.service_catalog._process#L552-L556","kind":"function","name":"_process","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":552,"end_line":556,"context_start_line":532,"context_end_line":576,"code":" if value.lower() not in options[k].lower():\n error_msg = (\n f\"The requested {k} is incorrect, expected {value} but got {options[k]}.\"\n )\n return (\n 0,\n True,\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n\ndef option_match_heuristic(value, option):\n def _process(x):\n x = str(x).lower()\n x = x.replace(\"_\", \"\")\n x = x.replace(\" \", \"\")\n return x\n\n return _process(value) == _process(option)\n\n\nclass OrderDeveloperLaptopTask(OrderHardwareTask):\n config_path = ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(\n *args,\n fixed_request_item=\"Developer Laptop (Mac)\",\n **kwargs,\n )\n\n\nclass OrderIpadMiniTask(OrderHardwareTask):\n config_path = ORDER_IPAD_MINI_TASK_CONFIG_PATH\n\n def __init__(self, *args, **kwargs):\n super().__init__(","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.form#L1-L1593","kind":"module","name":"src.browsergym.workarena.tasks.form","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1,"end_line":1593,"context_start_line":1,"context_end_line":1593,"code":"import inspect\nimport json\nimport logging\nimport playwright.sync_api\nimport re\n\nfrom collections import OrderedDict\nfrom english_words import get_english_words_set\nfrom faker import Faker\n\nfake = Faker()\nfrom playwright.sync_api._generated import Page\nfrom tenacity import retry, stop_after_delay, retry_if_exception_type\nfrom time import sleep\nfrom typing import List, Tuple\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..api.utils import (\n db_delete_from_table,\n table_api_call,\n table_column_info,\n HTTPError,\n)\nfrom ..config import (\n SNOW_BROWSER_TIMEOUT,\n # Paths to the configuration files\n CREATE_CHANGE_REQUEST_CONFIG_PATH,\n CREATE_HARDWARE_CONFIG_PATH,\n CREATE_INCIDENT_CONFIG_PATH,\n CREATE_PROBLEM_CONFIG_PATH,\n CREATE_USER_CONFIG_PATH,\n # Paths to the expected fields files\n EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH,\n EXPECTED_HARDWARE_FORM_FIELDS_PATH,\n EXPECTED_INCIDENT_FORM_FIELDS_PATH,\n EXPECTED_PROBLEM_FORM_FIELDS_PATH,\n EXPECTED_USER_FORM_FIELDS_PATH,\n EXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH,\n)\nfrom ..instance import SNowInstance\nfrom .utils.form import fill_text\nfrom .utils.utils import check_url_suffix_match, prettyprint_enum\n\n\nENGLISH_WORDS = list(get_english_words_set([\"web2\"]))\n\n\nclass ServiceNowFormTask(AbstractServiceNowTask):\n \"\"\"\n Generic task for record manipulation (create/edit) in a table using a Glide form.\n\n Class attributes:\n -----------------\n config_path: str\n Path to the JSON file containing all possible configurations for the task. Defined in subclasses\n expected_fields_path: str\n Path to the JSON file containing all expected fields for the task. Defined in subclasses\n\n Parameters:\n -----------------\n form_url: str\n The URL of the form to use to create the record.\n instance: SNowInstance\n The instance on which to create the record.\n extra_mandatory_fields: List\n List of fields that should be marked as mandatory in the form (overrides the page specification).\n unique_valued_fields: dict\n Dictionary of fields that should have a unique value. Keys are the field names and values are functions\n used to make the fields unique (e.g., appending self.unique).\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/create_hardware_asset_task.json\n for an example of a configuration file.\n check_record_created: bool\n Whether to check if the record is created in cheat. This step uses the localStorage to get the sys_id, which is None when creating multiple forms. Hence, we bypass this step in the cheat.\n \"\"\"\n\n config_path = None\n expected_fields_path = None\n\n def __init__(\n self,\n form_url: str,\n table_label: str,\n instance: SNowInstance = None,\n extra_mandatory_fields: List = [],\n prohibited_fields: List = [],\n unique_valued_fields: dict = {},\n fixed_config: dict = None,\n check_record_created: bool = True,\n seed: int = None,\n ) -> None:\n # The type of fields that we support interacting with\n self.supported_types = [\n \"boolean\",\n \"choice\",\n \"email\",\n \"integer\",\n \"ph_number\",\n \"reference\",\n \"string\",\n ]\n self.string_types = [\"email\", \"ph_number\", \"string\"]\n\n # Javascript variable names for the form API\n self.js_prefix = \"gsft_main\"\n self.js_api_forms = \"g_form\"\n self.form_js_selector = self.js_prefix + \".\" + self.js_api_forms\n\n # Extra mandatory fields (overriding the page specification)\n self.extra_mandatory_fields = extra_mandatory_fields\n\n # Prohibited fields: fields that we shouldn't interact with\n self.prohibited_fields = prohibited_fields\n self.table_metadata = None\n self.fields = None\n self.mandatory_fields = None\n self.optional_fields = None\n\n super().__init__(seed=seed, instance=instance, start_rel_url=form_url)\n\n self.form_url = form_url\n\n # Table pretty printed name\n self.table_label = table_label\n self.table_name = self.form_url.split(\"/\")[-1].split(\".do\")[0]\n\n # Key in which the sys_id of the created record will be stored in the local storage\n self.session_sys_id_field = f\"{id(self)}.record_sys_id\"\n\n # Fields that should have a unique value (will append them with a uuid)\n self.unique_valued_fields = unique_valued_fields\n\n # Fixed configuration\n # We set the task fields, template record and created sysids to allow for easy access in compositional task creation\n self.fixed_config = fixed_config\n self.template_record = None\n self.task_fields = None\n self.fields = None\n self.protected_fields = None # Fields that should not be edited\n if fixed_config is not None:\n self._set_required_config_attributes(fixed_config)\n\n self.n_extra_fields = None\n self.created_sysids = []\n if self.config_path:\n self.all_configs = self.all_configs()\n if self.expected_fields_path:\n with open(self.expected_fields_path, \"r\") as f:\n self.expected_fields = json.load(f)\n self.check_record_created = check_record_created\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _get_form(self, page):\n \"\"\"\n Loads a bunch of info about the form on a page into object variables\n \"\"\"\n # Extract Glide table information\n logging.debug(\"Extracting Glide table metadata\")\n # ... expand reference fields\n # XXX: We need to expand reference fields and the referenced field is missing from the\n # form's client-side info so we are going to use the meta API to get that info.\n self.table_metadata = table_column_info(instance=self.instance, table=self.table_name)\n # ... augment with rendered metadata\n # XXX: Additional useful info is present in the rendered HTML. We extract it from there.\n for f in self.table_metadata:\n loc = page.frame(name=self.js_prefix).locator(f\"#sys_display.{self.table_name}.{f}\")\n if loc.count() > 0:\n # Check if the field is dependent on another field\n self.table_metadata[f][\"dependent_on_field\"] = loc.first.get_attribute(\n \"data-dependent\"\n )\n\n # Get the table's pretty-printed label\n logging.debug(\"Extracting table pretty-printed title\")\n self.table_label = table_api_call(\n instance=self.instance,\n table=\"sys_db_object\",\n params={\n \"sysparm_query\": f\"name={self.table_name}\",\n },\n )[\"result\"][0][\"label\"].lower()\n\n def _get_fields(self, page: Page) -> None:\n \"\"\"\n Get the form fields; split them into mandatory and optional\n \"\"\"\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n\n # Get the form fields\n def is_field_visible(field):\n return page.evaluate(\n f\"\"\"\n {self.form_js_selector}.isVisible(\n {self.form_js_selector}.getGlideUIElement('{field}'),\n {self.form_js_selector}.getControl('{field}')\n );\"\"\"\n )\n\n logging.debug(\"Extracting valid form fields\")\n editable_fields = page.evaluate(f\"{self.form_js_selector}.getEditableFields()\")\n field_elements = page.evaluate(f\"{self.form_js_selector}.elements\")\n all_fields = [f[\"fieldName\"] for f in field_elements]\n self.fields = {\n f[\"fieldName\"]: f\n for f in field_elements\n if f[\"fieldName\"] in editable_fields\n and f[\"fieldName\"] not in self.prohibited_fields\n and f[\"type\"] in self.supported_types\n and self.table_metadata[f[\"fieldName\"]].get(\n \"dependent_on_field\", \"\"\n ) # Don't add a field that depends on one that we'll edit\n not in editable_fields\n }\n # ... and their labels\n for f in self.fields:\n self.fields[f][\"label\"] = page.evaluate(f\"{self.form_js_selector}.getLabelOf('{f}')\")\n\n # Split them into mandatory and optional\n self.mandatory_fields = [f for f in self.fields.keys() if self.fields[f][\"mandatory\"]]\n self.optional_fields = [f for f in set(self.fields.keys()) - set(self.mandatory_fields)]\n\n # Sanity check\n assert len(self.fields) > 0, \"No fields found on page.\"\n assert len(editable_fields) > 0, \"No editable fields found on page.\"\n # ... check that the script that marks some fields as mandatory worked\n assert set(self.extra_mandatory_fields) <= set(\n self.mandatory_fields\n ), \"Some extra mandatory fields are not mandatory in the form.\"\n # ... check that the script that makes some fields read-only worked\n assert all(\n f not in self.fields for f in self.prohibited_fields\n ), \"Some prohibited fields are editable in the form.\"\n # ... check that all the fields that the config expects are present and that extra fields are not visible\n all_visible_fields = set([f for f in all_fields if is_field_visible(f)])\n expected_visible_fields = set([f for f in self.expected_fields if is_field_visible(f)])\n set_diff = all_visible_fields.union(\n expected_visible_fields\n ) - all_visible_fields.intersection(expected_visible_fields)\n assert (\n len(set_diff) == 0\n ), f\"The fields {set_diff} are either missing or unexpectedly visible on the form. Re-run 'workarena-install' to correct this.\"\n\n def _preprocess_fields(self, field, value):\n \"\"\"\n Do some preprocessing on loaded fields\n\n For example, we don't want to load old dates since they won't match newly created entries\n\n \"\"\"\n logging.debug(f\"Preprocessing field {field}\")\n if field not in self.fields:\n return value\n\n field_type = self.table_metadata[field][\"type\"]\n\n # Extract display values for reference fields\n if field_type == \"reference\" and isinstance(value, dict):\n value = value[\"display_value\"]\n\n # Remove date/time/username from journal entries\n elif field_type == \"journal_input\" and re.match(\n r\"^20\\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) ([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d) - .*\",\n value,\n ):\n value = value[value.index(\"\\n\") + 1 :].strip().replace(\"\\n\", \"\").replace(\"\\r\", \"\")\n\n # Any other text-based input\n elif field_type in self.string_types:\n if value is not None:\n value = value.strip().replace(\"\\n\", \"\").replace(\"\\r\", \"\")\n\n return value\n\n def _wait_for_ready(self, page: Page, iframe_only=False) -> None:\n \"\"\"\n Waits for the main iframe and APIs to be fully loaded\n\n Parameters:\n ----------\n page: playwright.sync_api.Page\n The page on which to wait for the iframe to be loaded\n iframe_only: bool\n If True, only wait for the iframe to be loaded. If False, also wait for the APIs to be available.\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n try:\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n except:\n page.wait_for_load_state(\"networkidle\")\n return\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if not iframe_only:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n logging.debug(\"Waiting for Glide tabs API to be available\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix}.g_tabs2Sections !== 'undefined'\"\n )\n logging.debug(\"Detected Glide tabs API ready\")\n\n def get_init_scripts(self) -> List[str]:\n # Extract expected URL suffix\n url_suffix = parse.urlparse(self.start_url).path.split(\"/\")[-1]\n url_suffix = self.table_name\n\n # Add a few initialization scripts\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded();\",\n # ... Mark the extra mandatory fields as such\n f\"\"\"\n function addFormMandatoryFields() {{\n waLog('Setting mandatory fields', 'addFormMandatoryFields');\n {\";\".join([f\"{self.js_api_forms}.setMandatory('{f}', true)\" for f in self.extra_mandatory_fields])}\n waLog('Mandatory fields set successfully.', 'addFormMandatoryFields');\n }}\n\n runInGsftMainOnlyAndProtectByURL(addFormMandatoryFields, '{url_suffix}');\n \"\"\",\n f\"\"\"\n function patchSubmitButton() {{\n waLog('Attempting to override form submit function', 'patchSubmitButton');\n // Save the original function if it hasn't been saved yet\n if(typeof old_gsftSubmit == 'undefined'){{\n old_gsftSubmit = new Function('return ' + gsftSubmit.toString())();\n waLog('Saved original submit function', 'patchSubmitButton');\n }}\n\n // Override the function to save the sys_id in the local storage\n gsftSubmit = function(control, form, action_name) {{\n localStorage['{self.session_sys_id_field}'] = {self.js_api_forms}.getUniqueValue();\n old_gsftSubmit(control, form, action_name);\n }};\n waLog('Patched submit function. All done.', 'patchSubmitButton');\n }}\n\n runInGsftMainOnlyAndProtectByURL(patchSubmitButton, '{url_suffix}');\n \"\"\",\n # Ensure that only the expected fields are changed\n f\"\"\"\n function monitorChangeOnFields() {{\n let predefinedList = {json.dumps(self.protected_fields)};\n console.log('Predefined list: ' + predefinedList);\n document.querySelectorAll(\"input, select, textarea\").forEach((e) => {{\n // Get the field name - some fields are like incident.xyz.field_name\n let fieldName = e.name.split('.').pop();\n if (!predefinedList.includes(fieldName)) {{\n e.addEventListener(\"change\", () => {{\n window.WORKARENA_BAD_FIELD_CHANGED = true;\n console.log(\"Field \" + e.name + \" changed and was not expected to.\");\n }})\n waLog('Added change listener to field ' + e.name, 'monitorChangeOnFields');\n }}\n }})\n }}\n\n runInGsftMainOnlyAndProtectByURL(monitorChangeOnFields, '{url_suffix}');\n \"\"\",\n ]\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n self._get_form(page)\n\n def _fill_fields(\n self,\n page: Page,\n iframe: playwright.sync_api.Frame,\n task_fields: List[str],\n update: bool = False,\n ) -> None:\n \"\"\"\n Fill the fields in the form with the values from the template record. The fields to fill are specified in the\n task_fields list. Update is a flag that indicates if the task is an update task.\n \"\"\"\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n if self.table_metadata is None:\n self._get_form(page)\n if self.fields is None:\n self._get_fields(page)\n\n # From now on, we assume we are on the form page\n self._wait_for_ready(page)\n\n # Retry on TypeError since in very rare occasions, element evaluates to null, which raises a TypeError\n @retry(\n stop=stop_after_delay(SNOW_BROWSER_TIMEOUT // 1000),\n retry=retry_if_exception_type(TypeError),\n )\n def show_field_tab(field):\n \"\"\"\n Finds the control that allows to show the section where a field is located\n and clicks on it.\n\n \"\"\"\n section = page.evaluate(\n f\"\"\"() => {{\n const element = {self.form_js_selector}.getElement('{field}');\n const ancestors = element.ancestors();\n for (let ancestor of ancestors) {{\n // Ancestor IDs are of the form \"section-
\"\n if (ancestor.id.startsWith('section-')) {{\n return ancestor.id;\n }}\n }}\n return null; // Return null if no matching ancestor is found\n }}\"\"\"\n )\n section_id = section.split(\"-\")[-1]\n tab_sections = {\n s.split(\".\")[-1]: i\n for i, s in enumerate(page.evaluate(f\"{self.js_prefix}.g_tabs2Sections.tabIDs\"))\n }\n\n # If the section is not in the tabs do nothing (it's probably the main section)\n if section_id not in tab_sections:\n return\n\n page.evaluate_handle(\n f\"\"\"{self.js_prefix}.g_tabs2Sections.tabsTabs[\n {tab_sections[section_id]}\n ].element\"\"\"\n ).click(force=True)\n\n for field in task_fields:\n # Get the field's input control\n control = iframe.get_by_label(\n page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\"),\n exact=True,\n )\n if control.count() > 1:\n control = control.nth(0)\n # If the field is in a section, click on its header to make it visible\n show_field_tab(field)\n\n # Some fields are marked as string by the API but accept selection-based input\n # We use the select tag condition to match these fields. Others are marked as integers.\n if self.table_metadata[field][\"type\"] == \"choice\":\n control.select_option(str(self.template_record[field]))\n\n # Checkboxes\n elif self.table_metadata[field][\"type\"] == \"boolean\":\n control.set_checked(1 if self.template_record[field] == \"true\" else 0)\n\n # Any text-based input\n else:\n fill_text(\n page=page,\n iframe=iframe,\n input_field=control,\n value=self.template_record[field],\n )\n\n # Click on the submit button\n page.wait_for_timeout(1000)\n if update:\n iframe.locator(\"#sysverb_update\").click()\n else:\n iframe.locator(\"#sysverb_insert\").click()\n\n # Check if the record was created\n if self.check_record_created:\n # This does not work if multiple forms are created at once. The localStorage returns null after t\n# ... truncated ...","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.ServiceNowFormTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.ServiceNowFormTask#L51-L550","kind":"class","name":"ServiceNowFormTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":51,"end_line":550,"context_start_line":31,"context_end_line":570,"code":" CREATE_HARDWARE_CONFIG_PATH,\n CREATE_INCIDENT_CONFIG_PATH,\n CREATE_PROBLEM_CONFIG_PATH,\n CREATE_USER_CONFIG_PATH,\n # Paths to the expected fields files\n EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH,\n EXPECTED_HARDWARE_FORM_FIELDS_PATH,\n EXPECTED_INCIDENT_FORM_FIELDS_PATH,\n EXPECTED_PROBLEM_FORM_FIELDS_PATH,\n EXPECTED_USER_FORM_FIELDS_PATH,\n EXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH,\n)\nfrom ..instance import SNowInstance\nfrom .utils.form import fill_text\nfrom .utils.utils import check_url_suffix_match, prettyprint_enum\n\n\nENGLISH_WORDS = list(get_english_words_set([\"web2\"]))\n\n\nclass ServiceNowFormTask(AbstractServiceNowTask):\n \"\"\"\n Generic task for record manipulation (create/edit) in a table using a Glide form.\n\n Class attributes:\n -----------------\n config_path: str\n Path to the JSON file containing all possible configurations for the task. Defined in subclasses\n expected_fields_path: str\n Path to the JSON file containing all expected fields for the task. Defined in subclasses\n\n Parameters:\n -----------------\n form_url: str\n The URL of the form to use to create the record.\n instance: SNowInstance\n The instance on which to create the record.\n extra_mandatory_fields: List\n List of fields that should be marked as mandatory in the form (overrides the page specification).\n unique_valued_fields: dict\n Dictionary of fields that should have a unique value. Keys are the field names and values are functions\n used to make the fields unique (e.g., appending self.unique).\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/create_hardware_asset_task.json\n for an example of a configuration file.\n check_record_created: bool\n Whether to check if the record is created in cheat. This step uses the localStorage to get the sys_id, which is None when creating multiple forms. Hence, we bypass this step in the cheat.\n \"\"\"\n\n config_path = None\n expected_fields_path = None\n\n def __init__(\n self,\n form_url: str,\n table_label: str,\n instance: SNowInstance = None,\n extra_mandatory_fields: List = [],\n prohibited_fields: List = [],\n unique_valued_fields: dict = {},\n fixed_config: dict = None,\n check_record_created: bool = True,\n seed: int = None,\n ) -> None:\n # The type of fields that we support interacting with\n self.supported_types = [\n \"boolean\",\n \"choice\",\n \"email\",\n \"integer\",\n \"ph_number\",\n \"reference\",\n \"string\",\n ]\n self.string_types = [\"email\", \"ph_number\", \"string\"]\n\n # Javascript variable names for the form API\n self.js_prefix = \"gsft_main\"\n self.js_api_forms = \"g_form\"\n self.form_js_selector = self.js_prefix + \".\" + self.js_api_forms\n\n # Extra mandatory fields (overriding the page specification)\n self.extra_mandatory_fields = extra_mandatory_fields\n\n # Prohibited fields: fields that we shouldn't interact with\n self.prohibited_fields = prohibited_fields\n self.table_metadata = None\n self.fields = None\n self.mandatory_fields = None\n self.optional_fields = None\n\n super().__init__(seed=seed, instance=instance, start_rel_url=form_url)\n\n self.form_url = form_url\n\n # Table pretty printed name\n self.table_label = table_label\n self.table_name = self.form_url.split(\"/\")[-1].split(\".do\")[0]\n\n # Key in which the sys_id of the created record will be stored in the local storage\n self.session_sys_id_field = f\"{id(self)}.record_sys_id\"\n\n # Fields that should have a unique value (will append them with a uuid)\n self.unique_valued_fields = unique_valued_fields\n\n # Fixed configuration\n # We set the task fields, template record and created sysids to allow for easy access in compositional task creation\n self.fixed_config = fixed_config\n self.template_record = None\n self.task_fields = None\n self.fields = None\n self.protected_fields = None # Fields that should not be edited\n if fixed_config is not None:\n self._set_required_config_attributes(fixed_config)\n\n self.n_extra_fields = None\n self.created_sysids = []\n if self.config_path:\n self.all_configs = self.all_configs()\n if self.expected_fields_path:\n with open(self.expected_fields_path, \"r\") as f:\n self.expected_fields = json.load(f)\n self.check_record_created = check_record_created\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _get_form(self, page):\n \"\"\"\n Loads a bunch of info about the form on a page into object variables\n \"\"\"\n # Extract Glide table information\n logging.debug(\"Extracting Glide table metadata\")\n # ... expand reference fields\n # XXX: We need to expand reference fields and the referenced field is missing from the\n # form's client-side info so we are going to use the meta API to get that info.\n self.table_metadata = table_column_info(instance=self.instance, table=self.table_name)\n # ... augment with rendered metadata\n # XXX: Additional useful info is present in the rendered HTML. We extract it from there.\n for f in self.table_metadata:\n loc = page.frame(name=self.js_prefix).locator(f\"#sys_display.{self.table_name}.{f}\")\n if loc.count() > 0:\n # Check if the field is dependent on another field\n self.table_metadata[f][\"dependent_on_field\"] = loc.first.get_attribute(\n \"data-dependent\"\n )\n\n # Get the table's pretty-printed label\n logging.debug(\"Extracting table pretty-printed title\")\n self.table_label = table_api_call(\n instance=self.instance,\n table=\"sys_db_object\",\n params={\n \"sysparm_query\": f\"name={self.table_name}\",\n },\n )[\"result\"][0][\"label\"].lower()\n\n def _get_fields(self, page: Page) -> None:\n \"\"\"\n Get the form fields; split them into mandatory and optional\n \"\"\"\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n\n # Get the form fields\n def is_field_visible(field):\n return page.evaluate(\n f\"\"\"\n {self.form_js_selector}.isVisible(\n {self.form_js_selector}.getGlideUIElement('{field}'),\n {self.form_js_selector}.getControl('{field}')\n );\"\"\"\n )\n\n logging.debug(\"Extracting valid form fields\")\n editable_fields = page.evaluate(f\"{self.form_js_selector}.getEditableFields()\")\n field_elements = page.evaluate(f\"{self.form_js_selector}.elements\")\n all_fields = [f[\"fieldName\"] for f in field_elements]\n self.fields = {\n f[\"fieldName\"]: f\n for f in field_elements\n if f[\"fieldName\"] in editable_fields\n and f[\"fieldName\"] not in self.prohibited_fields\n and f[\"type\"] in self.supported_types\n and self.table_metadata[f[\"fieldName\"]].get(\n \"dependent_on_field\", \"\"\n ) # Don't add a field that depends on one that we'll edit\n not in editable_fields\n }\n # ... and their labels\n for f in self.fields:\n self.fields[f][\"label\"] = page.evaluate(f\"{self.form_js_selector}.getLabelOf('{f}')\")\n\n # Split them into mandatory and optional\n self.mandatory_fields = [f for f in self.fields.keys() if self.fields[f][\"mandatory\"]]\n self.optional_fields = [f for f in set(self.fields.keys()) - set(self.mandatory_fields)]\n\n # Sanity check\n assert len(self.fields) > 0, \"No fields found on page.\"\n assert len(editable_fields) > 0, \"No editable fields found on page.\"\n # ... check that the script that marks some fields as mandatory worked\n assert set(self.extra_mandatory_fields) <= set(\n self.mandatory_fields\n ), \"Some extra mandatory fields are not mandatory in the form.\"\n # ... check that the script that makes some fields read-only worked\n assert all(\n f not in self.fields for f in self.prohibited_fields\n ), \"Some prohibited fields are editable in the form.\"\n # ... check that all the fields that the config expects are present and that extra fields are not visible\n all_visible_fields = set([f for f in all_fields if is_field_visible(f)])\n expected_visible_fields = set([f for f in self.expected_fields if is_field_visible(f)])\n set_diff = all_visible_fields.union(\n expected_visible_fields\n ) - all_visible_fields.intersection(expected_visible_fields)\n assert (\n len(set_diff) == 0\n ), f\"The fields {set_diff} are either missing or unexpectedly visible on the form. Re-run 'workarena-install' to correct this.\"\n\n def _preprocess_fields(self, field, value):\n \"\"\"\n Do some preprocessing on loaded fields\n\n For example, we don't want to load old dates since they won't match newly created entries\n\n \"\"\"\n logging.debug(f\"Preprocessing field {field}\")\n if field not in self.fields:\n return value\n\n field_type = self.table_metadata[field][\"type\"]\n\n # Extract display values for reference fields\n if field_type == \"reference\" and isinstance(value, dict):\n value = value[\"display_value\"]\n\n # Remove date/time/username from journal entries\n elif field_type == \"journal_input\" and re.match(\n r\"^20\\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) ([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d) - .*\",\n value,\n ):\n value = value[value.index(\"\\n\") + 1 :].strip().replace(\"\\n\", \"\").replace(\"\\r\", \"\")\n\n # Any other text-based input\n elif field_type in self.string_types:\n if value is not None:\n value = value.strip().replace(\"\\n\", \"\").replace(\"\\r\", \"\")\n\n return value\n\n def _wait_for_ready(self, page: Page, iframe_only=False) -> None:\n \"\"\"\n Waits for the main iframe and APIs to be fully loaded\n\n Parameters:\n ----------\n page: playwright.sync_api.Page\n The page on which to wait for the iframe to be loaded\n iframe_only: bool\n If True, only wait for the iframe to be loaded. If False, also wait for the APIs to be available.\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n try:\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n except:\n page.wait_for_load_state(\"networkidle\")\n return\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if not iframe_only:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n logging.debug(\"Waiting for Glide tabs API to be available\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix}.g_tabs2Sections !== 'undefined'\"\n )\n logging.debug(\"Detected Glide tabs API ready\")\n\n def get_init_scripts(self) -> List[str]:\n # Extract expected URL suffix\n url_suffix = parse.urlparse(self.start_url).path.split(\"/\")[-1]\n url_suffix = self.table_name\n\n # Add a few initialization scripts\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded();\",\n # ... Mark the extra mandatory fields as such\n f\"\"\"\n function addFormMandatoryFields() {{\n waLog('Setting mandatory fields', 'addFormMandatoryFields');\n {\";\".join([f\"{self.js_api_forms}.setMandatory('{f}', true)\" for f in self.extra_mandatory_fields])}\n waLog('Mandatory fields set successfully.', 'addFormMandatoryFields');\n }}\n\n runInGsftMainOnlyAndProtectByURL(addFormMandatoryFields, '{url_suffix}');\n \"\"\",\n f\"\"\"\n function patchSubmitButton() {{\n waLog('Attempting to override form submit function', 'patchSubmitButton');\n // Save the original function if it hasn't been saved yet\n if(typeof old_gsftSubmit == 'undefined'){{\n old_gsftSubmit = new Function('return ' + gsftSubmit.toString())();\n waLog('Saved original submit function', 'patchSubmitButton');\n }}\n\n // Override the function to save the sys_id in the local storage\n gsftSubmit = function(control, form, action_name) {{\n localStorage['{self.session_sys_id_field}'] = {self.js_api_forms}.getUniqueValue();\n old_gsftSubmit(control, form, action_name);\n }};\n waLog('Patched submit function. All done.', 'patchSubmitButton');\n }}\n\n runInGsftMainOnlyAndProtectByURL(patchSubmitButton, '{url_suffix}');\n \"\"\",\n # Ensure that only the expected fields are changed\n f\"\"\"\n function monitorChangeOnFields() {{\n let predefinedList = {json.dumps(self.protected_fields)};\n console.log('Predefined list: ' + predefinedList);\n document.querySelectorAll(\"input, select, textarea\").forEach((e) => {{\n // Get the field name - some fields are like incident.xyz.field_name\n let fieldName = e.name.split('.').pop();\n if (!predefinedList.includes(fieldName)) {{\n e.addEventListener(\"change\", () => {{\n window.WORKARENA_BAD_FIELD_CHANGED = true;\n console.log(\"Field \" + e.name + \" changed and was not expected to.\");\n }})\n waLog('Added change listener to field ' + e.name, 'monitorChangeOnFields');\n }}\n }})\n }}\n\n runInGsftMainOnlyAndProtectByURL(monitorChangeOnFields, '{url_suffix}');\n \"\"\",\n ]\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n self._get_form(page)\n\n def _fill_fields(\n self,\n page: Page,\n iframe: playwright.sync_api.Frame,\n task_fields: List[str],\n update: bool = False,\n ) -> None:\n \"\"\"\n Fill the fields in the form with the values from the template record. The fields to fill are specified in the\n task_fields list. Update is a flag that indicates if the task is an update task.\n \"\"\"\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n if self.table_metadata is None:\n self._get_form(page)\n if self.fields is None:\n self._get_fields(page)\n\n # From now on, we assume we are on the form page\n self._wait_for_ready(page)\n\n # Retry on TypeError since in very rare occasions, element evaluates to null, which raises a TypeError\n @retry(\n stop=stop_after_delay(SNOW_BROWSER_TIMEOUT // 1000),\n retry=retry_if_exception_type(TypeError),\n )\n def show_field_tab(field):\n \"\"\"\n Finds the control that allows to show the section where a field is located\n and clicks on it.\n\n \"\"\"\n section = page.evaluate(\n f\"\"\"() => {{\n const element = {self.form_js_selector}.getElement('{field}');\n const ancestors = element.ancestors();\n for (let ancestor of ancestors) {{\n // Ancestor IDs are of the form \"section-
\"\n if (ancestor.id.startsWith('section-')) {{\n return ancestor.id;\n }}\n }}\n return null; // Return null if no matching ancestor is found\n }}\"\"\"\n )\n section_id = section.split(\"-\")[-1]\n tab_sections = {\n s.split(\".\")[-1]: i\n for i, s in enumerate(page.evaluate(f\"{self.js_prefix}.g_tabs2Sections.tabIDs\"))\n }\n\n # If the section is not in the tabs do nothing (it's probably the main section)\n if section_id not in tab_sections:\n return\n\n page.evaluate_handle(\n f\"\"\"{self.js_prefix}.g_tabs2Sections.tabsTabs[\n {tab_sections[section_id]}\n ].element\"\"\"\n ).click(force=True)\n\n for field in task_fields:\n # Get the field's input control\n control = iframe.get_by_label(\n page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\"),\n exact=True,\n )\n if control.count() > 1:\n control = control.nth(0)\n # If the field is in a section, click on its header to make it visible\n show_field_tab(field)\n\n # Some fields are marked as string by the API but accept selection-based input\n # We use the select tag condition to match these fields. Others are marked as integers.\n if self.table_metadata[field][\"type\"] == \"choice\":\n control.select_option(str(self.template_record[field]))\n\n # Checkboxes\n elif self.table_metadata[field][\"type\"] == \"boolean\":\n control.set_checked(1 if self.template_record[field] == \"true\" else 0)\n\n # Any text-based input\n else:\n fill_text(\n page=page,\n iframe=iframe,\n input_field=control,\n value=self.template_record[field],\n )\n\n # Click on the submit button\n page.wait_for_timeout(1000)\n if update:\n iframe.locator(\"#sysverb_update\").click()\n else:\n iframe.locator(\"#sysverb_insert\").click()\n\n # Check if the record was created\n if self.check_record_created:\n # This does not work if multiple forms are created at once. The localStorage returns null after the first form\n for attempt in range(5):\n # in update tasks, the sys_id is already known as the asset is created from the start\n if update:\n sys_id = self.record_sys_id\n else:\n sys_id = page.evaluate(\"localStorage\").get(self.session_sys_id_field, None)\n\n # Pull the record from the database\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"sys_id={sys_id}\",\n \"sysparm_display_value\": True,\n },\n )[\"result\"]\n if len(r\n# ... truncated ...","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.GenericNewRecordTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.GenericNewRecordTask#L553-L922","kind":"class","name":"GenericNewRecordTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":553,"end_line":922,"context_start_line":533,"context_end_line":942,"code":" # XXX: We skip empty-string values because 1) they are not really interesting to\n # ask for since the agent doesn't have to do anything. They also cause issues\n # in the validation since they don't get saved properly to the database.\n choices = [v for k, v in table_metadata[field][\"choices\"].items() if k != \"\"]\n new_value = self.random.choice(choices)\n elif table_metadata[field][\"type\"] in self.string_types:\n # ... if the field is a string, we want to make sure that it's not empty\n\n if table_metadata[field][\"type\"] == \"string\":\n new_value = \" \".join(self.random.choice(ENGLISH_WORDS, size=5))\n elif table_metadata[field][\"type\"] == \"email\":\n new_value = f\"{'.'.join(self.random.choice(ENGLISH_WORDS, size=2))}@workarena.com\"\n elif table_metadata[field][\"type\"] == \"ph_number\":\n new_value = (\n f\"(514) {self.random.randint(100, 999)}-{self.random.randint(1000, 9999)}\"\n )\n\n return new_value\n\n\nclass GenericNewRecordTask(ServiceNowFormTask):\n \"\"\"\n Generic task to create a new record in a table using a Glide form.\n\n Parameters:\n -----------\n min_fields: int\n Minimum number of fields to fill (except if mandatory is more).\n max_fields: int\n Maximum number of fields to fill (except if mandatory is more).\n \"\"\"\n\n config_path = None\n expected_fields_path = None\n\n def __init__(\n self,\n form_url: str,\n table_label: str,\n instance: SNowInstance = None,\n extra_mandatory_fields: List = [],\n prohibited_fields: List = [],\n unique_valued_fields: dict = {},\n min_fields: int = 5,\n max_fields: int = None,\n fixed_config: dict = None,\n seed: int = None,\n check_record_created: bool = True,\n ) -> None:\n super().__init__(\n seed=seed,\n form_url=form_url,\n table_label=table_label,\n instance=instance,\n extra_mandatory_fields=extra_mandatory_fields,\n prohibited_fields=prohibited_fields,\n unique_valued_fields=unique_valued_fields,\n fixed_config=fixed_config,\n check_record_created=check_record_created,\n )\n # Maximum number of fields to fill (except if mandatory is more)\n self.min_fields = min_fields\n self.max_fields = 999999999 if max_fields is None else max_fields\n self.page_on_form_view = (\n False # Indicates if the page is on the form view; used in validation\n )\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n assert self.all_configs is not None, \"No configuration available for the task.\"\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n # If fixed_config is not None we already set the required attributes in the constructor\n if self.fixed_config is None:\n self._set_required_config_attributes(config)\n self.protected_fields = self.task_fields\n # Generate the goal\n goal = (\n f\"Create a new {self.table_label} with \"\n + prettyprint_enum(\n [\n f'a value of \"{self.template_record[f]}\"'\n + f' for field \"{config[\"fields\"][f]}\"'\n for f in self.task_fields\n ]\n )\n + \".\"\n )\n info = {}\n\n return goal, info\n\n def _generate_random_config(self, page: Page) -> None:\n \"\"\"Generate a random configuration for the task.\"\"\"\n self.setup(page=page)\n\n # Determine task fields\n logging.debug(\"Determining task fields\")\n # ... check that we have enough fields\n assert (\n len(self.fields) >= self.min_fields\n ), f\"Only {len(self.fields)} fields are available and task expects at least {self.min_fields} to fill.\"\n # ... make sure we select a number of fields within the allowed range\n self.n_extra_fields = self.random.randint(\n self.min_fields - len(self.mandatory_fields),\n max(\n 0,\n min(\n len(self.optional_fields),\n self.max_fields - len(self.mandatory_fields),\n ),\n )\n + 1,\n )\n # ... select final fields\n self.task_fields = (\n self.mandatory_fields\n + self.random.choice(\n list(self.optional_fields), size=self.n_extra_fields, replace=False\n ).tolist()\n )\n\n # Load a random record from the database and use its values as a template\n logging.debug(\"Loading a record from the database to use as a template\")\n # ... build a query to find a record with non-empty mandatory fields\n query_non_empty_mandatory_fields = \"^\".join(\n [f\"{field}ISNOTEMPTY\" for field in self.mandatory_fields]\n )\n # ... find how many entries there are in the table\n n_entries = len(\n table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_fields\": \"sys_id\",\n \"sysparm_query\": query_non_empty_mandatory_fields,\n },\n )[\"result\"]\n )\n assert n_entries > 0, \"No entries found to serve as template for the task.\"\n # ... sample a random record\n self.template_record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_limit\": 1,\n \"sysparm_offset\": self.random.randint(0, n_entries),\n \"sysparm_display_value\": True,\n \"sysparm_query\": query_non_empty_mandatory_fields,\n },\n )[\"result\"][0]\n # ... preprocess its fields\n self.template_record = {\n f: self._preprocess_fields(f, v) for f, v in self.template_record.items()\n }\n # ... make unique any field that must have a unique value\n for f, func in self.unique_valued_fields.items():\n self.template_record[f] = func(self.template_record[f])\n\n # Replace some field values\n for f in self.fields:\n new_value = self.get_new_field_value(f, self.template_record, self.table_metadata)\n self.template_record[f] = new_value\n\n # Make sure the value satisfies the max length for the field\n self.template_record = {\n f: (\n v[: self.table_metadata[f][\"max_length\"]]\n if isinstance(v, str) and self.table_metadata[f][\"type\"] in self.string_types\n else v\n )\n for f, v in self.template_record.items()\n }\n self.created_sysids = []\n\n # generate the goal\n goal = (\n f\"Create a new {self.table_label} with \"\n + \" and \".join(\n [\n f'a value of \"{self.template_record[f]}\"'\n + f' for field \"{self.fields[f][\"label\"]}\"'\n for f in self.task_fields\n ]\n )\n + \".\"\n )\n info = {}\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Create\", \"\").replace(\"Task\", \"\")\n\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n table_metadata = table_column_info(instance=self.instance, table=self.table_name)\n # pretty field names that are displayed to the user\n task_fields = []\n for field in self.task_fields:\n # In feasible tasks, the fields are always present\n if field in table_metadata:\n field_name = table_metadata[field][\"label\"]\n # In infeasible tasks, the fields are absent from table_metadata\n else:\n field_name = \" \".join(field.split(\"_\")).capitalize()\n\n task_fields.append(field_name)\n\n field_values = [self.template_record[field] for field in self.task_fields]\n current_task_info = dict(zip(task_fields, field_values))\n task_info = f\"- Create a {class_name_formatted} with the following information: \\n\"\n for field, value in current_task_info.items():\n task_info += f\" - {field}: {value} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n # If we are on the list view of the table, click on the \"New\" button\n self._wait_for_ready(page, iframe_only=True)\n iframe = page.frame_locator(f'iframe[name=\"{self.js_prefix}\"]')\n url = parse.urlparse(parse.unquote(self.page.evaluate(\"() => window.location.href\")))\n if url.path.endswith(\"_list.do\"):\n # click on the sysverb_new button\n with page.expect_navigation():\n iframe.locator(\"#sysverb_new\").click()\n iframe = page.frame_locator(f'iframe[name=\"{self.js_prefix}\"]')\n # On the change request page, additional steps need to be taken to open the form\n if self.table_label == \"change request\":\n self._wait_for_ready(page, iframe_only=True)\n iframe.get_by_label(\"All\").click()\n iframe.get_by_text(\"Normal\").first.click()\n self._fill_fields(page, iframe, self.task_fields)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Caveat: we check only if the expected fields have the right value. We don't Check\n if there are extra fields that shouldn't be there. We could have issues\n matching other fields since calculation rules may have changed through time.\n Maybe we should assign a random value from our list of choices to the fields\n that are not part of the task.\n\n \"\"\"\n\n right_url = self._page_on_right_url(page)\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n protected_field_changed = page.evaluate(\n \"() => window.gsft_main.WORKARENA_BAD_FIELD_CHANGED\"\n )\n if protected_field_changed:\n return (\n 0,\n True,\n \"\",\n {\"message\": \"Some fields outside of the task scope have been changed.\"},\n )\n if self.table_metadata is None and self.page_is_form_view:\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n self._wait_for_ready(page, iframe_only=True)\n self._get_form(page)\n if self.fields is None and self.page_is_form_view:\n self._get_fields(page)\n\n # Retrieve the created record's sys_id from the session storage\n sys_id = page.evaluate(\"localStorage\").get(self.session_sys_id_field, None)\n\n # Check that a record has actually been created\n if sys_id is None:\n logging.info(\"No record has been created.\")\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The form has not been submitted.\"},\n )\n\n # Add the sysid to the list of created sysids\n # This is used to clean up the database after the task is completed.\n self.created_sysids.append(sys_id)\n\n # Pull the record from the database\n # XXX: It's possible that the record is not found, e.g., if form submission was rejected due to client-side\n # validation errors. In this case, we should not raise an error and simply consider that no record was\n # created. This is non-terminal for the task.\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"sys_id={sys_id}\",\n \"sysparm_display_value\": True,\n },\n wait_for_record=True,\n max_retries=20, # Wait up to 10 seconds\n raise_on_wait_expired=False,\n )[\"result\"]\n\n # This can happen if the form was submitted but was rejected due to invalid inputs (e.g., missing mandatory fields)\n if len(record) == 0:\n logging.info(\n \"The record was not found in the database. Perhaps the form was not submitted correctly. \"\n + sys_id,\n )\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"The record was not found in the database. Perhaps the form was not submitted correctly.\"\n },\n )\n\n # Extract display values for reference fields\n record = {\n f: v if not isinstance(v, dict) else v[\"display_value\"] for f, v in record[0].items()\n }\n\n # Check that the record matches the expected values\n for f in self.task_fields:\n if record[f] != self.template_record[f]:\n logging.info(\n f'The field \"{self.fields[f][\"label\"]}\" has the wrong value. Expected: \"{self.template_record[f]}\", got: \"{record[f]}\".'\n )\n error_msg = f'The field \"{self.fields[f][\"label\"]}\" has the wrong value.'\n return (\n 0,\n True, # End episode (incorrect information pushed to the DB)\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"The record was successfully created.\"},\n )\n\n def _page_on_right_url(self, page: Page) -> bool:\n \"\"\"Checks if the page is on the right URL for validation + sets the page_on_form_view attribute\"\"\"\n page.wait_for_load_state(\"domcontentloaded\")\n self._wait_for_ready(page, iframe_only=True)\n # check that the page is at the right url\n list_url = self.start_url.replace(\".do\", \"_list.do\") # list view of records\n # Check whether we are in the form or list view\n self.page_is_form_view = check_url_suffix_match(\n page, expected_url=self.start_url, task=self\n )\n page_is_list_view = check_url_suffix_match(page, expected_url=list_url, task=self)\n\n right_url = self.page_is_form_view or page_is_list_view\n\n return right_url\n\n def teardown(self) -> None:\n self._wait_for_ready(self.page, iframe_only=True)\n\n # Retrieve the current record's sys_id from the session storage\n sys_id = self.page.evaluate(\"localStorage\").get(self.session_sys_id_field, None)\n\n # Also include any other sysid that was encountered in validation\n ids = set([sys_id] + self.created_sysids)\n\n for sys_id in ids:\n if sys_id is not None:\n try:\n db_delete_from_table(\n instance=self.instance, sys_id=sys_id, table=self.table_name\n )\n except HTTPError:\n # sys_id was stored in local storage (for submitted)\n # but the record is absent from the database (probably invalid form)\n pass\n\n\nclass EditRecordTask(ServiceNowFormTask, CompositionalBuildingBlockTask):\n \"\"\"\n Generic task to edit an existing record in a table using a Glide form.\n Class Attributes\n ----------------\n config_path: str\n The path to the JSON file containing all configurations for the task. Defined by subclasses\n expected_fields_path: str\n The path to the JSON file containing all expected fields for the task. Defined by subclasses\n Args\n ----\n form_url: str\n The URL of the form to use to edit the record.\n table_label: str\n The pretty-printed name of the table.\n instance: SNowInstance\n The instance on which to edit the record.\n extra_mandatory_fields: List","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.EditRecordTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.EditRecordTask#L925-L1217","kind":"class","name":"EditRecordTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":925,"end_line":1217,"context_start_line":905,"context_end_line":1237,"code":" self._wait_for_ready(self.page, iframe_only=True)\n\n # Retrieve the current record's sys_id from the session storage\n sys_id = self.page.evaluate(\"localStorage\").get(self.session_sys_id_field, None)\n\n # Also include any other sysid that was encountered in validation\n ids = set([sys_id] + self.created_sysids)\n\n for sys_id in ids:\n if sys_id is not None:\n try:\n db_delete_from_table(\n instance=self.instance, sys_id=sys_id, table=self.table_name\n )\n except HTTPError:\n # sys_id was stored in local storage (for submitted)\n # but the record is absent from the database (probably invalid form)\n pass\n\n\nclass EditRecordTask(ServiceNowFormTask, CompositionalBuildingBlockTask):\n \"\"\"\n Generic task to edit an existing record in a table using a Glide form.\n Class Attributes\n ----------------\n config_path: str\n The path to the JSON file containing all configurations for the task. Defined by subclasses\n expected_fields_path: str\n The path to the JSON file containing all expected fields for the task. Defined by subclasses\n Args\n ----\n form_url: str\n The URL of the form to use to edit the record.\n table_label: str\n The pretty-printed name of the table.\n instance: SNowInstance\n The instance on which to edit the record.\n extra_mandatory_fields: List\n List of fields that should be marked as mandatory in the form (overrides the page specification).\n prohibited_fields: List\n List of fields that should not be edited.\n unique_valued_fields: dict\n Dictionary of fields that should have a unique value. Keys are the field names and values are functions\n used to make the fields unique (e.g., appending self.unique).\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n a randomly selected one\n record_sys_id: str\n The sys_id of the record to edit. If provided, the task will edit this record instead of creating a new one.\n record_number: str\n The number of the record to edit. If provided, the task's cheat will select records based on it rather than picking the first element of the list.\n new_values: dict\n Dictionary mapping fields to their new values. These are values that will be used to either replace the current\n values in the record or add them to the record if they are not already present.\n \"\"\"\n\n def __init__(\n self,\n form_url: str,\n table_label: str,\n instance: SNowInstance = None,\n extra_mandatory_fields: List = [],\n prohibited_fields: List = [],\n unique_valued_fields: dict = {},\n fixed_config: dict = None,\n record_sys_id: str = None,\n record_number: str = None,\n new_values: dict = None,\n seed: int = None,\n ) -> None:\n super().__init__(\n seed=seed,\n form_url=form_url,\n table_label=table_label,\n instance=instance,\n extra_mandatory_fields=extra_mandatory_fields,\n prohibited_fields=prohibited_fields,\n unique_valued_fields=unique_valued_fields,\n fixed_config=fixed_config,\n )\n # sys_id of the record that will be edited\n self.record_sys_id = record_sys_id\n self.record_number = record_number\n self.delete_record_on_teardown = False\n self.new_values = new_values # dict mapping fields to their new values\n # If the record sys_id is provided, the task will fetch its template record and task fields\n if self.record_sys_id is not None:\n fixed_config = {}\n template_record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"sys_id={self.record_sys_id}\",\n },\n )[\"result\"][0]\n fixed_config[\"template_record\"] = template_record\n fixed_config[\"task_fields\"] = list(self.new_values.keys())\n table_info = table_column_info(instance=self.instance, table=self.table_name)\n fixed_config[\"fields\"] = {f: table_info[f][\"label\"] for f in self.new_values.keys()}\n\n self.fixed_config = fixed_config\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n\n # If fixed_config is not None we already set the required attributes in the constructor\n # If record_sys_id is not None, the required attributes are not set in the constructor either\n if self.fixed_config is None or self.record_sys_id is not None:\n self._set_required_config_attributes(config)\n\n # Make the new values unique if needed\n for f, func in self.unique_valued_fields.items():\n if f in self.new_values:\n self.new_values[f] = func(self.new_values[f])\n\n self.protected_fields = list(self.new_values.keys())\n if self.record_sys_id is None:\n self._create_record()\n self.delete_record_on_teardown = True\n # Replace the values in the template record\n for f, v in self.new_values.items():\n self.template_record[f] = v\n self.start_url = f\"{self.start_url}%3Fsys_id%3D{self.record_sys_id}\"\n\n # Generate the goal\n goal = self.get_pretty_printed_description()\n\n info = {}\n\n return goal, info\n\n def _create_record(self) -> None:\n \"\"\"Create a record to edit.\"\"\"\n # Data to create the record\n data = {}\n for field in self.template_record:\n value = self.template_record[field]\n if type(value) == dict:\n value = value[\"display_value\"]\n # Skip sys fields as they are not editable\n if not value or \"sys\" in field:\n continue\n data[field] = value\n\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,\n data=json.dumps(data),\n method=\"POST\",\n )\n self.record_sys_id = result[\"result\"][\"sys_id\"]\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Edit\", \"\").replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n table_metadata = table_column_info(instance=self.instance, table=self.table_name)\n task_fields = [\n table_metadata[field][\"label\"] for field in self.new_values\n ] # pretty field names that are displayed to the user\n field_values = [self.template_record[field] for field in self.new_values]\n current_task_info = dict(zip(task_fields, field_values))\n # In L3, this is part of an enumeration\n task_info = \"- \" if self.level == 3 else \"\"\n\n task_info += (\n f\"Edit the {self.table_label} record by replacing the value of \"\n + prettyprint_enum(\n [\n f' field \"{field}\"' + f' with value \"{value}\"'\n for field, value in current_task_info.items()\n ]\n )\n + \".\"\n )\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page, iframe_only=True)\n iframe = page.frame_locator(f'iframe[name=\"{self.js_prefix}\"]')\n url = parse.urlparse(parse.unquote(self.page.evaluate(\"() => window.location.href\")))\n\n # Open the record preview, then the record\n if url.path.endswith(\"_list.do\"):\n # If the record number is provided, click on the record with that number\n if self.record_number:\n iframe.locator(f\"[aria-label='Preview record: {self.record_number}']\").click()\n # ....otherwise, click on the first record\n else:\n iframe.locator(\"td\").get_by_role(\"button\").first.click()\n page.wait_for_timeout(500)\n\n iframe.get_by_text(\"Open Record\").click()\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n page.wait_for_timeout(1000)\n self._fill_fields(page, iframe, self.new_values.keys(), update=True)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Caveat: we check only if the expected fields have the right value. We don't Check\n if there are extra fields that shouldn't be there. We could have issues\n matching other fields since calculation rules may have changed through time.\n Maybe we should assign a random value from our list of choices to the fields\n that are not part of the task.\n\n \"\"\"\n page.wait_for_load_state(\"domcontentloaded\")\n # check that the page is at the right url\n list_url = self.start_url.replace(\".do\", \"_list.do\") # list view of records\n # Check whether we are in the form or list view\n page_is_form_view = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n page_is_list_view = check_url_suffix_match(page, expected_url=list_url, task=self)\n right_url = page_is_form_view or page_is_list_view\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n self._wait_for_ready(page, iframe_only=True)\n protected_field_changed = page.evaluate(\n \"() => window.gsft_main.WORKARENA_BAD_FIELD_CHANGED\"\n )\n if protected_field_changed:\n return (\n 0,\n True,\n \"\",\n {\"message\": \"Some fields outside of the task scope have been changed.\"},\n )\n if self.table_metadata is None:\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n self._wait_for_ready(page, iframe_only=True)\n self._get_form(page)\n if self.fields is None and page_is_form_view:\n self._get_fields(page)\n\n # Pull the record from the database\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"sys_id={self.record_sys_id}\",\n \"sysparm_display_value\": True,\n },\n wait_for_record=True,\n )[\"result\"]\n\n # This can happen if the form was submitted but was rejected due to invalid inputs (e.g., missing mandatory fields)\n if len(record) == 0:\n logging.info(\n \"The record was not found in the database. Perhaps it was deleted.\"\n + self.record_sys_id,\n )\n return (\n 0,\n True,\n \"\",\n {\"message\": \"The record was not found in the database. Perhaps it was deleted.\"},\n )\n\n # Extract display values for reference fields\n record = {\n f: v if not isinstance(v, dict) else v[\"display_value\"] for f, v in record[0].items()\n }\n\n # Check that the record matches the expected values\n for f in self.new_values.keys():\n if \"sys_\" in f:\n continue\n if record[f] != self.template_record[f]:\n logging.info(\n f'The field \"{self.table_metadata[f][\"label\"]}\" has the wrong value. Expected: \"{self.template_record[f]}\", got: \"{record[f]}\".'\n )\n error_msg = f'The field \"{self.table_metadata[f][\"label\"]}\" has the wrong value.'\n return (\n 0,\n False,\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"The record was successfully edited.\"},\n )\n\n def teardown(self) -> None:\n # Delete the record created for the task\n if self.delete_record_on_teardown:\n db_delete_from_table(\n instance=self.instance, sys_id=self.record_sys_id, table=self.table_name\n )\n\n\nclass CreateChangeRequestTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new change request in the system.\n\n \"\"\"\n\n config_path = CREATE_CHANGE_REQUEST_CONFIG_PATH\n expected_fields_path = EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/change_request.do\",\n table_label=\"change request\",\n prohibited_fields=[\"chg_model\", \"state\"],","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.CreateChangeRequestTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.CreateChangeRequestTask#L1220-L1257","kind":"class","name":"CreateChangeRequestTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1220,"end_line":1257,"context_start_line":1200,"context_end_line":1277,"code":" False,\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"The record was successfully edited.\"},\n )\n\n def teardown(self) -> None:\n # Delete the record created for the task\n if self.delete_record_on_teardown:\n db_delete_from_table(\n instance=self.instance, sys_id=self.record_sys_id, table=self.table_name\n )\n\n\nclass CreateChangeRequestTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new change request in the system.\n\n \"\"\"\n\n config_path = CREATE_CHANGE_REQUEST_CONFIG_PATH\n expected_fields_path = EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/change_request.do\",\n table_label=\"change request\",\n prohibited_fields=[\"chg_model\", \"state\"],\n fixed_config=fixed_config,\n )\n self.__dict__.update(kwargs)\n\n def _page_on_right_url(self, page: playwright.sync_api.Page) -> bool:\n \"\"\"\n The change request form lands in a view different from the list view. We need to check for this as well.\n \"\"\"\n right_url = super()._page_on_right_url(page)\n # Change request creation leads to a different page when in comp task; we need to check this case as well\n change_request_landing_page = \"/now/nav/ui/classic/params/target/sn_chg_model_ui_landing.do\"\n page_is_change_landing = (\n check_url_suffix_match(page, expected_url=change_request_landing_page, task=self)\n if self.table_label == \"change request\"\n else False\n )\n\n right_url = right_url or page_is_change_landing\n\n return right_url\n\n\nclass CreateIncidentTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new incident in the system.\n \"\"\"\n\n config_path = CREATE_INCIDENT_CONFIG_PATH\n expected_fields_path = EXPECTED_INCIDENT_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n check_record_created=True,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.CreateIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.CreateIncidentTask#L1260-L1285","kind":"class","name":"CreateIncidentTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1260,"end_line":1285,"context_start_line":1240,"context_end_line":1305,"code":" self.__dict__.update(kwargs)\n\n def _page_on_right_url(self, page: playwright.sync_api.Page) -> bool:\n \"\"\"\n The change request form lands in a view different from the list view. We need to check for this as well.\n \"\"\"\n right_url = super()._page_on_right_url(page)\n # Change request creation leads to a different page when in comp task; we need to check this case as well\n change_request_landing_page = \"/now/nav/ui/classic/params/target/sn_chg_model_ui_landing.do\"\n page_is_change_landing = (\n check_url_suffix_match(page, expected_url=change_request_landing_page, task=self)\n if self.table_label == \"change request\"\n else False\n )\n\n right_url = right_url or page_is_change_landing\n\n return right_url\n\n\nclass CreateIncidentTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new incident in the system.\n \"\"\"\n\n config_path = CREATE_INCIDENT_CONFIG_PATH\n expected_fields_path = EXPECTED_INCIDENT_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n check_record_created=True,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/incident.do\",\n table_label=\"incident\",\n prohibited_fields=[\"state\"],\n fixed_config=fixed_config,\n check_record_created=check_record_created,\n )\n self.__dict__.update(kwargs)\n\n\nclass CreateHardwareAssetTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new user in the system.\n\n \"\"\"\n\n config_path = CREATE_HARDWARE_CONFIG_PATH\n expected_fields_path = EXPECTED_HARDWARE_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/alm_hardware.do\",\n table_label=\"hardware asset\",\n prohibited_fields=[\"install_status\"],","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.CreateHardwareAssetTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.CreateHardwareAssetTask#L1288-L1315","kind":"class","name":"CreateHardwareAssetTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1288,"end_line":1315,"context_start_line":1268,"context_end_line":1335,"code":" def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n check_record_created=True,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/incident.do\",\n table_label=\"incident\",\n prohibited_fields=[\"state\"],\n fixed_config=fixed_config,\n check_record_created=check_record_created,\n )\n self.__dict__.update(kwargs)\n\n\nclass CreateHardwareAssetTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new user in the system.\n\n \"\"\"\n\n config_path = CREATE_HARDWARE_CONFIG_PATH\n expected_fields_path = EXPECTED_HARDWARE_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/alm_hardware.do\",\n table_label=\"hardware asset\",\n prohibited_fields=[\"install_status\"],\n extra_mandatory_fields=[\n \"model\",\n \"model_category\",\n \"serial_number\",\n \"vendor\",\n ],\n unique_valued_fields={\"serial_number\": lambda x: f\"SN-{self.unique_id}\"},\n fixed_config=fixed_config,\n )\n self.__dict__.update(kwargs)\n\n\nclass CreateProblemTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new problem in the system.\n\n \"\"\"\n\n config_path = CREATE_PROBLEM_CONFIG_PATH\n expected_fields_path = EXPECTED_PROBLEM_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n check_record_created=True,\n **kwargs,\n ) -> None:\n super().__init__(","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.CreateProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.CreateProblemTask#L1318-L1348","kind":"class","name":"CreateProblemTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1318,"end_line":1348,"context_start_line":1298,"context_end_line":1368,"code":" self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/alm_hardware.do\",\n table_label=\"hardware asset\",\n prohibited_fields=[\"install_status\"],\n extra_mandatory_fields=[\n \"model\",\n \"model_category\",\n \"serial_number\",\n \"vendor\",\n ],\n unique_valued_fields={\"serial_number\": lambda x: f\"SN-{self.unique_id}\"},\n fixed_config=fixed_config,\n )\n self.__dict__.update(kwargs)\n\n\nclass CreateProblemTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new problem in the system.\n\n \"\"\"\n\n config_path = CREATE_PROBLEM_CONFIG_PATH\n expected_fields_path = EXPECTED_PROBLEM_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n check_record_created=True,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/problem.do\",\n table_label=\"problem\",\n prohibited_fields=[\"state\", \"first_reported_by_task\"],\n fixed_config=fixed_config,\n check_record_created=check_record_created,\n # TODO: The last field is disabled because somehow the value is not in the autocomplete\n # list even though it's in the database. I'm not sure why. It doesn't matter much\n # since in the future we'll pre-generate tasks and keep only the ones where the\n # cheat function works.\n )\n self.__dict__.update(kwargs)\n\n\nclass CreateUserTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new user in the system.\n\n \"\"\"\n\n config_path = CREATE_USER_CONFIG_PATH\n expected_fields_path = EXPECTED_USER_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/sys_user.do\",\n table_label=\"user\",\n extra_mandatory_fields=[\"user_name\", \"first_name\", \"last_name\", \"email\"],","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.CreateUserTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.CreateUserTask#L1351-L1386","kind":"class","name":"CreateUserTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1351,"end_line":1386,"context_start_line":1331,"context_end_line":1406,"code":" fixed_config: dict = None,\n check_record_created=True,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/problem.do\",\n table_label=\"problem\",\n prohibited_fields=[\"state\", \"first_reported_by_task\"],\n fixed_config=fixed_config,\n check_record_created=check_record_created,\n # TODO: The last field is disabled because somehow the value is not in the autocomplete\n # list even though it's in the database. I'm not sure why. It doesn't matter much\n # since in the future we'll pre-generate tasks and keep only the ones where the\n # cheat function works.\n )\n self.__dict__.update(kwargs)\n\n\nclass CreateUserTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new user in the system.\n\n \"\"\"\n\n config_path = CREATE_USER_CONFIG_PATH\n expected_fields_path = EXPECTED_USER_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/sys_user.do\",\n table_label=\"user\",\n extra_mandatory_fields=[\"user_name\", \"first_name\", \"last_name\", \"email\"],\n # XXX We use an OrderedDict to ensure that the fields are filled in the right order as the email requires the first and last name\n unique_valued_fields=OrderedDict(\n [\n (\"first_name\", lambda x: fake.first_name() + \"-\" + fake.first_name()),\n (\"last_name\", lambda x: fake.last_name() + \"-\" + fake.last_name()),\n (\"user_name\", lambda x: str(abs(hash(x + self.unique_id)))),\n (\n \"email\",\n lambda x: self.template_record[\"first_name\"].lower()\n + \".\"\n + self.template_record[\"last_name\"].lower()\n + \"@workarena.com\",\n ),\n ]\n ),\n fixed_config=fixed_config,\n )\n self.__dict__.update(kwargs)\n\n\nclass EditHardwareAssetTask(EditRecordTask):\n \"\"\"\n Task to create a new user in the system.\n\n \"\"\"\n\n config_path = CREATE_HARDWARE_CONFIG_PATH\n expected_fields_path = EXPECTED_HARDWARE_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n record_sys_id: str = None,\n new_values: dict = None,\n **kwargs,\n ) -> None:","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.EditHardwareAssetTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.EditHardwareAssetTask#L1389-L1420","kind":"class","name":"EditHardwareAssetTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1389,"end_line":1420,"context_start_line":1369,"context_end_line":1440,"code":" # XXX We use an OrderedDict to ensure that the fields are filled in the right order as the email requires the first and last name\n unique_valued_fields=OrderedDict(\n [\n (\"first_name\", lambda x: fake.first_name() + \"-\" + fake.first_name()),\n (\"last_name\", lambda x: fake.last_name() + \"-\" + fake.last_name()),\n (\"user_name\", lambda x: str(abs(hash(x + self.unique_id)))),\n (\n \"email\",\n lambda x: self.template_record[\"first_name\"].lower()\n + \".\"\n + self.template_record[\"last_name\"].lower()\n + \"@workarena.com\",\n ),\n ]\n ),\n fixed_config=fixed_config,\n )\n self.__dict__.update(kwargs)\n\n\nclass EditHardwareAssetTask(EditRecordTask):\n \"\"\"\n Task to create a new user in the system.\n\n \"\"\"\n\n config_path = CREATE_HARDWARE_CONFIG_PATH\n expected_fields_path = EXPECTED_HARDWARE_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n record_sys_id: str = None,\n new_values: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/alm_hardware.do\",\n table_label=\"hardware asset\",\n prohibited_fields=[\"install_status\"],\n unique_valued_fields={\"serial_number\": lambda x: f\"SN-{self.unique_id}\"},\n new_values=new_values,\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n )\n if self.new_values is None:\n self.new_values = {\"department\": \"Finance\"}\n self.__dict__.update(kwargs)\n\n\nclass EditProblemTask(EditRecordTask):\n \"\"\"\n Task to edit a problem in the system.\n\n \"\"\"\n\n expected_fields_path = EXPECTED_PROBLEM_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n new_values: dict = None,\n record_sys_id: str = None,\n record_number: str = None,\n **kwargs,\n ) -> None:","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.EditProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.EditProblemTask#L1423-L1465","kind":"class","name":"EditProblemTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1423,"end_line":1465,"context_start_line":1403,"context_end_line":1485,"code":" record_sys_id: str = None,\n new_values: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/alm_hardware.do\",\n table_label=\"hardware asset\",\n prohibited_fields=[\"install_status\"],\n unique_valued_fields={\"serial_number\": lambda x: f\"SN-{self.unique_id}\"},\n new_values=new_values,\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n )\n if self.new_values is None:\n self.new_values = {\"department\": \"Finance\"}\n self.__dict__.update(kwargs)\n\n\nclass EditProblemTask(EditRecordTask):\n \"\"\"\n Task to edit a problem in the system.\n\n \"\"\"\n\n expected_fields_path = EXPECTED_PROBLEM_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n new_values: dict = None,\n record_sys_id: str = None,\n record_number: str = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/problem.do\",\n table_label=\"problem\",\n prohibited_fields=[\"state\", \"first_reported_by_task\"],\n new_values=new_values,\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n record_number=record_number,\n )\n if self.new_values is None:\n self.new_values = {\"assigned_to\": \"\"}\n self.__dict__.update(kwargs)\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n if self.level == 2:\n description = \"Re-assign a lowest priority problem from the user with the most assigned problems to the user with the least assigned problems.\"\n return description\n else:\n return \"\"\n\n\nclass EditChangeRequestScheduleTask(EditRecordTask):\n \"\"\"Task to edit an existing change request's empty schedule (start and end dates).\"\"\"\n\n expected_fields_path = EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n new_values: dict = None,\n record_sys_id: str = None,\n skip_description: bool = False,\n goal_type: str = \"base\",\n level: int = 2,\n **kwargs,\n ) -> None:\n \"\"\"","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.EditChangeRequestScheduleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.EditChangeRequestScheduleTask#L1468-L1530","kind":"class","name":"EditChangeRequestScheduleTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1468,"end_line":1530,"context_start_line":1448,"context_end_line":1550,"code":" fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n record_number=record_number,\n )\n if self.new_values is None:\n self.new_values = {\"assigned_to\": \"\"}\n self.__dict__.update(kwargs)\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n if self.level == 2:\n description = \"Re-assign a lowest priority problem from the user with the most assigned problems to the user with the least assigned problems.\"\n return description\n else:\n return \"\"\n\n\nclass EditChangeRequestScheduleTask(EditRecordTask):\n \"\"\"Task to edit an existing change request's empty schedule (start and end dates).\"\"\"\n\n expected_fields_path = EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n new_values: dict = None,\n record_sys_id: str = None,\n skip_description: bool = False,\n goal_type: str = \"base\",\n level: int = 2,\n **kwargs,\n ) -> None:\n \"\"\"\n args:\n -----\n skip_description: bool\n Whether to skip the description field in the change request. Used in comp tasks when this class is used multiple times.\n goal_type: str\n Choice of \"base\", \"priority\", \"tight\", \"tight priority\". The type of goal to generate. Used in compositional tasks.\n level: int\n The level of the compositional task. Used in compositional tasks.\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/change_request.do\",\n table_label=\"change request\",\n prohibited_fields=[\"chg_model\", \"state\"],\n new_values=new_values,\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n )\n self.skip_description = skip_description\n self.goal_type = goal_type\n self.level = level\n self.__dict__.update(kwargs)\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.skip_description or self.level == 3:\n return \"\"\n elif self.goal_type == \"base\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one day between conescutive change requests in the schedule.\"\n elif self.goal_type == \"priority\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one day between conescutive change requests in the schedule and the higher impact change requests should be tackled first.\"\n elif self.goal_type == \"tight\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one hour between conescutive change requests in the schedule.\"\n elif self.goal_type == \"tight priority\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one hour between conescutive change requests in the schedule and the higher impact change requests should be tackled first.\"\n\n task_info += \" Finally, all change requests must respect the desired durations, which are determined by the risk level:\\n\"\n task_info += \" - High risk: 3 days \\n\"\n task_info += \" - Moderate risk: 2 days \\n\"\n task_info += \" - Low risk: 1 day \\n\"\n\n return task_info\n\n\nclass EditIncidentTask(EditRecordTask):\n \"\"\"\n Task to edit a new incident in the system.\n\n \"\"\"\n\n expected_fields_path = EXPECTED_INCIDENT_FORM_FIELDS_PATH\n\n def __init__(\n self,\n instance=None,\n fixed_config: dict = None,\n new_values: dict = None,\n record_sys_id: str = None,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.EditIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.EditIncidentTask#L1533-L1560","kind":"class","name":"EditIncidentTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1533,"end_line":1560,"context_start_line":1513,"context_end_line":1580,"code":" \"\"\"\n if self.skip_description or self.level == 3:\n return \"\"\n elif self.goal_type == \"base\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one day between conescutive change requests in the schedule.\"\n elif self.goal_type == \"priority\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one day between conescutive change requests in the schedule and the higher impact change requests should be tackled first.\"\n elif self.goal_type == \"tight\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one hour between conescutive change requests in the schedule.\"\n elif self.goal_type == \"tight priority\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one hour between conescutive change requests in the schedule and the higher impact change requests should be tackled first.\"\n\n task_info += \" Finally, all change requests must respect the desired durations, which are determined by the risk level:\\n\"\n task_info += \" - High risk: 3 days \\n\"\n task_info += \" - Moderate risk: 2 days \\n\"\n task_info += \" - Low risk: 1 day \\n\"\n\n return task_info\n\n\nclass EditIncidentTask(EditRecordTask):\n \"\"\"\n Task to edit a new incident in the system.\n\n \"\"\"\n\n expected_fields_path = EXPECTED_INCIDENT_FORM_FIELDS_PATH\n\n def __init__(\n self,\n instance=None,\n fixed_config: dict = None,\n new_values: dict = None,\n record_sys_id: str = None,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/incident.do\",\n table_label=\"incident\",\n prohibited_fields=[\"state\"],\n fixed_config=fixed_config,\n new_values=new_values,\n record_sys_id=record_sys_id,\n )\n if self.new_values is None:\n self.new_values = {\"assigned_to\": \"fred.luddy\"}\n self.__dict__.update(kwargs)\n\n\nclass CreateItemRequestTask(GenericNewRecordTask, CompositionalBuildingBlockTask):\n \"\"\"\n Task to create a new item request in the system.\n \"\"\"\n\n expected_fields_path = EXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH\n\n def __init__(\n self, instance=None, fixed_config: dict = None, check_record_created=True, **kwargs\n ) -> None:\n super().__init__(\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/sc_req_item.do\",\n table_label=\"sc_req_item\",\n fixed_config=fixed_config,\n check_record_created=check_record_created,\n )\n self.__dict__.update(kwargs)","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.CreateItemRequestTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.form.CreateItemRequestTask#L1563-L1580","kind":"class","name":"CreateItemRequestTask","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1563,"end_line":1580,"context_start_line":1543,"context_end_line":1593,"code":" instance=None,\n fixed_config: dict = None,\n new_values: dict = None,\n record_sys_id: str = None,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/incident.do\",\n table_label=\"incident\",\n prohibited_fields=[\"state\"],\n fixed_config=fixed_config,\n new_values=new_values,\n record_sys_id=record_sys_id,\n )\n if self.new_values is None:\n self.new_values = {\"assigned_to\": \"fred.luddy\"}\n self.__dict__.update(kwargs)\n\n\nclass CreateItemRequestTask(GenericNewRecordTask, CompositionalBuildingBlockTask):\n \"\"\"\n Task to create a new item request in the system.\n \"\"\"\n\n expected_fields_path = EXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH\n\n def __init__(\n self, instance=None, fixed_config: dict = None, check_record_created=True, **kwargs\n ) -> None:\n super().__init__(\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/sc_req_item.do\",\n table_label=\"sc_req_item\",\n fixed_config=fixed_config,\n check_record_created=check_record_created,\n )\n self.__dict__.update(kwargs)\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if inspect.isclass(var)\n and not issubclass(var, CompositionalBuildingBlockTask)\n and issubclass(var, ServiceNowFormTask)\n and var is not GenericNewRecordTask\n and var is not ServiceNowFormTask\n]","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.__init__#L1570-L1580","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1570,"end_line":1580,"context_start_line":1550,"context_end_line":1593,"code":" instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/incident.do\",\n table_label=\"incident\",\n prohibited_fields=[\"state\"],\n fixed_config=fixed_config,\n new_values=new_values,\n record_sys_id=record_sys_id,\n )\n if self.new_values is None:\n self.new_values = {\"assigned_to\": \"fred.luddy\"}\n self.__dict__.update(kwargs)\n\n\nclass CreateItemRequestTask(GenericNewRecordTask, CompositionalBuildingBlockTask):\n \"\"\"\n Task to create a new item request in the system.\n \"\"\"\n\n expected_fields_path = EXPECTED_REQUEST_ITEM_FORM_FIELDS_PATH\n\n def __init__(\n self, instance=None, fixed_config: dict = None, check_record_created=True, **kwargs\n ) -> None:\n super().__init__(\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/sc_req_item.do\",\n table_label=\"sc_req_item\",\n fixed_config=fixed_config,\n check_record_created=check_record_created,\n )\n self.__dict__.update(kwargs)\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if inspect.isclass(var)\n and not issubclass(var, CompositionalBuildingBlockTask)\n and issubclass(var, ServiceNowFormTask)\n and var is not GenericNewRecordTask\n and var is not ServiceNowFormTask\n]","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.all_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.all_configs#L157-L159","kind":"function","name":"all_configs","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":157,"end_line":159,"context_start_line":137,"context_end_line":179,"code":" # Fixed configuration\n # We set the task fields, template record and created sysids to allow for easy access in compositional task creation\n self.fixed_config = fixed_config\n self.template_record = None\n self.task_fields = None\n self.fields = None\n self.protected_fields = None # Fields that should not be edited\n if fixed_config is not None:\n self._set_required_config_attributes(fixed_config)\n\n self.n_extra_fields = None\n self.created_sysids = []\n if self.config_path:\n self.all_configs = self.all_configs()\n if self.expected_fields_path:\n with open(self.expected_fields_path, \"r\") as f:\n self.expected_fields = json.load(f)\n self.check_record_created = check_record_created\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _get_form(self, page):\n \"\"\"\n Loads a bunch of info about the form on a page into object variables\n \"\"\"\n # Extract Glide table information\n logging.debug(\"Extracting Glide table metadata\")\n # ... expand reference fields\n # XXX: We need to expand reference fields and the referenced field is missing from the\n # form's client-side info so we are going to use the meta API to get that info.\n self.table_metadata = table_column_info(instance=self.instance, table=self.table_name)\n # ... augment with rendered metadata\n # XXX: Additional useful info is present in the rendered HTML. We extract it from there.\n for f in self.table_metadata:\n loc = page.frame(name=self.js_prefix).locator(f\"#sys_display.{self.table_name}.{f}\")\n if loc.count() > 0:\n # Check if the field is dependent on another field\n self.table_metadata[f][\"dependent_on_field\"] = loc.first.get_attribute(\n \"data-dependent\"\n )","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._get_form","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._get_form#L161-L189","kind":"function","name":"_get_form","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":161,"end_line":189,"context_start_line":141,"context_end_line":209,"code":" self.task_fields = None\n self.fields = None\n self.protected_fields = None # Fields that should not be edited\n if fixed_config is not None:\n self._set_required_config_attributes(fixed_config)\n\n self.n_extra_fields = None\n self.created_sysids = []\n if self.config_path:\n self.all_configs = self.all_configs()\n if self.expected_fields_path:\n with open(self.expected_fields_path, \"r\") as f:\n self.expected_fields = json.load(f)\n self.check_record_created = check_record_created\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def _get_form(self, page):\n \"\"\"\n Loads a bunch of info about the form on a page into object variables\n \"\"\"\n # Extract Glide table information\n logging.debug(\"Extracting Glide table metadata\")\n # ... expand reference fields\n # XXX: We need to expand reference fields and the referenced field is missing from the\n # form's client-side info so we are going to use the meta API to get that info.\n self.table_metadata = table_column_info(instance=self.instance, table=self.table_name)\n # ... augment with rendered metadata\n # XXX: Additional useful info is present in the rendered HTML. We extract it from there.\n for f in self.table_metadata:\n loc = page.frame(name=self.js_prefix).locator(f\"#sys_display.{self.table_name}.{f}\")\n if loc.count() > 0:\n # Check if the field is dependent on another field\n self.table_metadata[f][\"dependent_on_field\"] = loc.first.get_attribute(\n \"data-dependent\"\n )\n\n # Get the table's pretty-printed label\n logging.debug(\"Extracting table pretty-printed title\")\n self.table_label = table_api_call(\n instance=self.instance,\n table=\"sys_db_object\",\n params={\n \"sysparm_query\": f\"name={self.table_name}\",\n },\n )[\"result\"][0][\"label\"].lower()\n\n def _get_fields(self, page: Page) -> None:\n \"\"\"\n Get the form fields; split them into mandatory and optional\n \"\"\"\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n\n # Get the form fields\n def is_field_visible(field):\n return page.evaluate(\n f\"\"\"\n {self.form_js_selector}.isVisible(\n {self.form_js_selector}.getGlideUIElement('{field}'),\n {self.form_js_selector}.getControl('{field}')\n );\"\"\"\n )\n\n logging.debug(\"Extracting valid form fields\")","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._get_fields","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._get_fields#L191-L251","kind":"function","name":"_get_fields","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":191,"end_line":251,"context_start_line":171,"context_end_line":271,"code":" # ... augment with rendered metadata\n # XXX: Additional useful info is present in the rendered HTML. We extract it from there.\n for f in self.table_metadata:\n loc = page.frame(name=self.js_prefix).locator(f\"#sys_display.{self.table_name}.{f}\")\n if loc.count() > 0:\n # Check if the field is dependent on another field\n self.table_metadata[f][\"dependent_on_field\"] = loc.first.get_attribute(\n \"data-dependent\"\n )\n\n # Get the table's pretty-printed label\n logging.debug(\"Extracting table pretty-printed title\")\n self.table_label = table_api_call(\n instance=self.instance,\n table=\"sys_db_object\",\n params={\n \"sysparm_query\": f\"name={self.table_name}\",\n },\n )[\"result\"][0][\"label\"].lower()\n\n def _get_fields(self, page: Page) -> None:\n \"\"\"\n Get the form fields; split them into mandatory and optional\n \"\"\"\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n\n # Get the form fields\n def is_field_visible(field):\n return page.evaluate(\n f\"\"\"\n {self.form_js_selector}.isVisible(\n {self.form_js_selector}.getGlideUIElement('{field}'),\n {self.form_js_selector}.getControl('{field}')\n );\"\"\"\n )\n\n logging.debug(\"Extracting valid form fields\")\n editable_fields = page.evaluate(f\"{self.form_js_selector}.getEditableFields()\")\n field_elements = page.evaluate(f\"{self.form_js_selector}.elements\")\n all_fields = [f[\"fieldName\"] for f in field_elements]\n self.fields = {\n f[\"fieldName\"]: f\n for f in field_elements\n if f[\"fieldName\"] in editable_fields\n and f[\"fieldName\"] not in self.prohibited_fields\n and f[\"type\"] in self.supported_types\n and self.table_metadata[f[\"fieldName\"]].get(\n \"dependent_on_field\", \"\"\n ) # Don't add a field that depends on one that we'll edit\n not in editable_fields\n }\n # ... and their labels\n for f in self.fields:\n self.fields[f][\"label\"] = page.evaluate(f\"{self.form_js_selector}.getLabelOf('{f}')\")\n\n # Split them into mandatory and optional\n self.mandatory_fields = [f for f in self.fields.keys() if self.fields[f][\"mandatory\"]]\n self.optional_fields = [f for f in set(self.fields.keys()) - set(self.mandatory_fields)]\n\n # Sanity check\n assert len(self.fields) > 0, \"No fields found on page.\"\n assert len(editable_fields) > 0, \"No editable fields found on page.\"\n # ... check that the script that marks some fields as mandatory worked\n assert set(self.extra_mandatory_fields) <= set(\n self.mandatory_fields\n ), \"Some extra mandatory fields are not mandatory in the form.\"\n # ... check that the script that makes some fields read-only worked\n assert all(\n f not in self.fields for f in self.prohibited_fields\n ), \"Some prohibited fields are editable in the form.\"\n # ... check that all the fields that the config expects are present and that extra fields are not visible\n all_visible_fields = set([f for f in all_fields if is_field_visible(f)])\n expected_visible_fields = set([f for f in self.expected_fields if is_field_visible(f)])\n set_diff = all_visible_fields.union(\n expected_visible_fields\n ) - all_visible_fields.intersection(expected_visible_fields)\n assert (\n len(set_diff) == 0\n ), f\"The fields {set_diff} are either missing or unexpectedly visible on the form. Re-run 'workarena-install' to correct this.\"\n\n def _preprocess_fields(self, field, value):\n \"\"\"\n Do some preprocessing on loaded fields\n\n For example, we don't want to load old dates since they won't match newly created entries\n\n \"\"\"\n logging.debug(f\"Preprocessing field {field}\")\n if field not in self.fields:\n return value\n\n field_type = self.table_metadata[field][\"type\"]\n\n # Extract display values for reference fields\n if field_type == \"reference\" and isinstance(value, dict):\n value = value[\"display_value\"]\n\n # Remove date/time/username from journal entries\n elif field_type == \"journal_input\" and re.match(","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._preprocess_fields","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._preprocess_fields#L253-L282","kind":"function","name":"_preprocess_fields","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":253,"end_line":282,"context_start_line":233,"context_end_line":302,"code":" assert len(self.fields) > 0, \"No fields found on page.\"\n assert len(editable_fields) > 0, \"No editable fields found on page.\"\n # ... check that the script that marks some fields as mandatory worked\n assert set(self.extra_mandatory_fields) <= set(\n self.mandatory_fields\n ), \"Some extra mandatory fields are not mandatory in the form.\"\n # ... check that the script that makes some fields read-only worked\n assert all(\n f not in self.fields for f in self.prohibited_fields\n ), \"Some prohibited fields are editable in the form.\"\n # ... check that all the fields that the config expects are present and that extra fields are not visible\n all_visible_fields = set([f for f in all_fields if is_field_visible(f)])\n expected_visible_fields = set([f for f in self.expected_fields if is_field_visible(f)])\n set_diff = all_visible_fields.union(\n expected_visible_fields\n ) - all_visible_fields.intersection(expected_visible_fields)\n assert (\n len(set_diff) == 0\n ), f\"The fields {set_diff} are either missing or unexpectedly visible on the form. Re-run 'workarena-install' to correct this.\"\n\n def _preprocess_fields(self, field, value):\n \"\"\"\n Do some preprocessing on loaded fields\n\n For example, we don't want to load old dates since they won't match newly created entries\n\n \"\"\"\n logging.debug(f\"Preprocessing field {field}\")\n if field not in self.fields:\n return value\n\n field_type = self.table_metadata[field][\"type\"]\n\n # Extract display values for reference fields\n if field_type == \"reference\" and isinstance(value, dict):\n value = value[\"display_value\"]\n\n # Remove date/time/username from journal entries\n elif field_type == \"journal_input\" and re.match(\n r\"^20\\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) ([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d) - .*\",\n value,\n ):\n value = value[value.index(\"\\n\") + 1 :].strip().replace(\"\\n\", \"\").replace(\"\\r\", \"\")\n\n # Any other text-based input\n elif field_type in self.string_types:\n if value is not None:\n value = value.strip().replace(\"\\n\", \"\").replace(\"\\r\", \"\")\n\n return value\n\n def _wait_for_ready(self, page: Page, iframe_only=False) -> None:\n \"\"\"\n Waits for the main iframe and APIs to be fully loaded\n\n Parameters:\n ----------\n page: playwright.sync_api.Page\n The page on which to wait for the iframe to be loaded\n iframe_only: bool\n If True, only wait for the iframe to be loaded. If False, also wait for the APIs to be available.\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n try:\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n except:\n page.wait_for_load_state(\"networkidle\")","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._wait_for_ready","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._wait_for_ready#L284-L315","kind":"function","name":"_wait_for_ready","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":284,"end_line":315,"context_start_line":264,"context_end_line":335,"code":" field_type = self.table_metadata[field][\"type\"]\n\n # Extract display values for reference fields\n if field_type == \"reference\" and isinstance(value, dict):\n value = value[\"display_value\"]\n\n # Remove date/time/username from journal entries\n elif field_type == \"journal_input\" and re.match(\n r\"^20\\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) ([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d) - .*\",\n value,\n ):\n value = value[value.index(\"\\n\") + 1 :].strip().replace(\"\\n\", \"\").replace(\"\\r\", \"\")\n\n # Any other text-based input\n elif field_type in self.string_types:\n if value is not None:\n value = value.strip().replace(\"\\n\", \"\").replace(\"\\r\", \"\")\n\n return value\n\n def _wait_for_ready(self, page: Page, iframe_only=False) -> None:\n \"\"\"\n Waits for the main iframe and APIs to be fully loaded\n\n Parameters:\n ----------\n page: playwright.sync_api.Page\n The page on which to wait for the iframe to be loaded\n iframe_only: bool\n If True, only wait for the iframe to be loaded. If False, also wait for the APIs to be available.\n\n \"\"\"\n logging.debug(f\"Waiting for {self.js_prefix} to be fully loaded\")\n try:\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n except:\n page.wait_for_load_state(\"networkidle\")\n return\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if not iframe_only:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n logging.debug(\"Waiting for Glide tabs API to be available\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix}.g_tabs2Sections !== 'undefined'\"\n )\n logging.debug(\"Detected Glide tabs API ready\")\n\n def get_init_scripts(self) -> List[str]:\n # Extract expected URL suffix\n url_suffix = parse.urlparse(self.start_url).path.split(\"/\")[-1]\n url_suffix = self.table_name\n\n # Add a few initialization scripts\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded();\",\n # ... Mark the extra mandatory fields as such\n f\"\"\"\n function addFormMandatoryFields() {{\n waLog('Setting mandatory fields', 'addFormMandatoryFields');\n {\";\".join([f\"{self.js_api_forms}.setMandatory('{f}', true)\" for f in self.extra_mandatory_fields])}\n waLog('Mandatory fields set successfully.', 'addFormMandatoryFields');\n }}\n\n runInGsftMainOnlyAndProtectByURL(addFormMandatoryFields, '{url_suffix}');\n \"\"\",\n f\"\"\"","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.get_init_scripts","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.get_init_scripts#L317-L374","kind":"function","name":"get_init_scripts","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":317,"end_line":374,"context_start_line":297,"context_end_line":394,"code":" try:\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n except:\n page.wait_for_load_state(\"networkidle\")\n return\n logging.debug(f\"Detected {self.js_prefix} ready\")\n\n if not iframe_only:\n logging.debug(\"Waiting for Glide form API to be available\")\n page.wait_for_function(f\"window.{self.form_js_selector}\")\n logging.debug(\"Detected Glide form API ready\")\n\n logging.debug(\"Waiting for Glide tabs API to be available\")\n page.wait_for_function(\n f\"typeof window.{self.js_prefix}.g_tabs2Sections !== 'undefined'\"\n )\n logging.debug(\"Detected Glide tabs API ready\")\n\n def get_init_scripts(self) -> List[str]:\n # Extract expected URL suffix\n url_suffix = parse.urlparse(self.start_url).path.split(\"/\")[-1]\n url_suffix = self.table_name\n\n # Add a few initialization scripts\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded();\",\n # ... Mark the extra mandatory fields as such\n f\"\"\"\n function addFormMandatoryFields() {{\n waLog('Setting mandatory fields', 'addFormMandatoryFields');\n {\";\".join([f\"{self.js_api_forms}.setMandatory('{f}', true)\" for f in self.extra_mandatory_fields])}\n waLog('Mandatory fields set successfully.', 'addFormMandatoryFields');\n }}\n\n runInGsftMainOnlyAndProtectByURL(addFormMandatoryFields, '{url_suffix}');\n \"\"\",\n f\"\"\"\n function patchSubmitButton() {{\n waLog('Attempting to override form submit function', 'patchSubmitButton');\n // Save the original function if it hasn't been saved yet\n if(typeof old_gsftSubmit == 'undefined'){{\n old_gsftSubmit = new Function('return ' + gsftSubmit.toString())();\n waLog('Saved original submit function', 'patchSubmitButton');\n }}\n\n // Override the function to save the sys_id in the local storage\n gsftSubmit = function(control, form, action_name) {{\n localStorage['{self.session_sys_id_field}'] = {self.js_api_forms}.getUniqueValue();\n old_gsftSubmit(control, form, action_name);\n }};\n waLog('Patched submit function. All done.', 'patchSubmitButton');\n }}\n\n runInGsftMainOnlyAndProtectByURL(patchSubmitButton, '{url_suffix}');\n \"\"\",\n # Ensure that only the expected fields are changed\n f\"\"\"\n function monitorChangeOnFields() {{\n let predefinedList = {json.dumps(self.protected_fields)};\n console.log('Predefined list: ' + predefinedList);\n document.querySelectorAll(\"input, select, textarea\").forEach((e) => {{\n // Get the field name - some fields are like incident.xyz.field_name\n let fieldName = e.name.split('.').pop();\n if (!predefinedList.includes(fieldName)) {{\n e.addEventListener(\"change\", () => {{\n window.WORKARENA_BAD_FIELD_CHANGED = true;\n console.log(\"Field \" + e.name + \" changed and was not expected to.\");\n }})\n waLog('Added change listener to field ' + e.name, 'monitorChangeOnFields');\n }}\n }})\n }}\n\n runInGsftMainOnlyAndProtectByURL(monitorChangeOnFields, '{url_suffix}');\n \"\"\",\n ]\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n self._get_form(page)\n\n def _fill_fields(\n self,\n page: Page,\n iframe: playwright.sync_api.Frame,\n task_fields: List[str],\n update: bool = False,\n ) -> None:\n \"\"\"\n Fill the fields in the form with the values from the template record. The fields to fill are specified in the\n task_fields list. Update is a flag that indicates if the task is an update task.\n \"\"\"\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n if self.table_metadata is None:","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.start","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.start#L376-L379","kind":"function","name":"start","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":376,"end_line":379,"context_start_line":356,"context_end_line":399,"code":" function monitorChangeOnFields() {{\n let predefinedList = {json.dumps(self.protected_fields)};\n console.log('Predefined list: ' + predefinedList);\n document.querySelectorAll(\"input, select, textarea\").forEach((e) => {{\n // Get the field name - some fields are like incident.xyz.field_name\n let fieldName = e.name.split('.').pop();\n if (!predefinedList.includes(fieldName)) {{\n e.addEventListener(\"change\", () => {{\n window.WORKARENA_BAD_FIELD_CHANGED = true;\n console.log(\"Field \" + e.name + \" changed and was not expected to.\");\n }})\n waLog('Added change listener to field ' + e.name, 'monitorChangeOnFields');\n }}\n }})\n }}\n\n runInGsftMainOnlyAndProtectByURL(monitorChangeOnFields, '{url_suffix}');\n \"\"\",\n ]\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n self._get_form(page)\n\n def _fill_fields(\n self,\n page: Page,\n iframe: playwright.sync_api.Frame,\n task_fields: List[str],\n update: bool = False,\n ) -> None:\n \"\"\"\n Fill the fields in the form with the values from the template record. The fields to fill are specified in the\n task_fields list. Update is a flag that indicates if the task is an update task.\n \"\"\"\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n if self.table_metadata is None:\n self._get_form(page)\n if self.fields is None:\n self._get_fields(page)\n\n # From now on, we assume we are on the form page","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._fill_fields","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._fill_fields#L381-L501","kind":"function","name":"_fill_fields","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":381,"end_line":501,"context_start_line":361,"context_end_line":521,"code":" let fieldName = e.name.split('.').pop();\n if (!predefinedList.includes(fieldName)) {{\n e.addEventListener(\"change\", () => {{\n window.WORKARENA_BAD_FIELD_CHANGED = true;\n console.log(\"Field \" + e.name + \" changed and was not expected to.\");\n }})\n waLog('Added change listener to field ' + e.name, 'monitorChangeOnFields');\n }}\n }})\n }}\n\n runInGsftMainOnlyAndProtectByURL(monitorChangeOnFields, '{url_suffix}');\n \"\"\",\n ]\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n self._get_form(page)\n\n def _fill_fields(\n self,\n page: Page,\n iframe: playwright.sync_api.Frame,\n task_fields: List[str],\n update: bool = False,\n ) -> None:\n \"\"\"\n Fill the fields in the form with the values from the template record. The fields to fill are specified in the\n task_fields list. Update is a flag that indicates if the task is an update task.\n \"\"\"\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n if self.table_metadata is None:\n self._get_form(page)\n if self.fields is None:\n self._get_fields(page)\n\n # From now on, we assume we are on the form page\n self._wait_for_ready(page)\n\n # Retry on TypeError since in very rare occasions, element evaluates to null, which raises a TypeError\n @retry(\n stop=stop_after_delay(SNOW_BROWSER_TIMEOUT // 1000),\n retry=retry_if_exception_type(TypeError),\n )\n def show_field_tab(field):\n \"\"\"\n Finds the control that allows to show the section where a field is located\n and clicks on it.\n\n \"\"\"\n section = page.evaluate(\n f\"\"\"() => {{\n const element = {self.form_js_selector}.getElement('{field}');\n const ancestors = element.ancestors();\n for (let ancestor of ancestors) {{\n // Ancestor IDs are of the form \"section-
\"\n if (ancestor.id.startsWith('section-')) {{\n return ancestor.id;\n }}\n }}\n return null; // Return null if no matching ancestor is found\n }}\"\"\"\n )\n section_id = section.split(\"-\")[-1]\n tab_sections = {\n s.split(\".\")[-1]: i\n for i, s in enumerate(page.evaluate(f\"{self.js_prefix}.g_tabs2Sections.tabIDs\"))\n }\n\n # If the section is not in the tabs do nothing (it's probably the main section)\n if section_id not in tab_sections:\n return\n\n page.evaluate_handle(\n f\"\"\"{self.js_prefix}.g_tabs2Sections.tabsTabs[\n {tab_sections[section_id]}\n ].element\"\"\"\n ).click(force=True)\n\n for field in task_fields:\n # Get the field's input control\n control = iframe.get_by_label(\n page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\"),\n exact=True,\n )\n if control.count() > 1:\n control = control.nth(0)\n # If the field is in a section, click on its header to make it visible\n show_field_tab(field)\n\n # Some fields are marked as string by the API but accept selection-based input\n # We use the select tag condition to match these fields. Others are marked as integers.\n if self.table_metadata[field][\"type\"] == \"choice\":\n control.select_option(str(self.template_record[field]))\n\n # Checkboxes\n elif self.table_metadata[field][\"type\"] == \"boolean\":\n control.set_checked(1 if self.template_record[field] == \"true\" else 0)\n\n # Any text-based input\n else:\n fill_text(\n page=page,\n iframe=iframe,\n input_field=control,\n value=self.template_record[field],\n )\n\n # Click on the submit button\n page.wait_for_timeout(1000)\n if update:\n iframe.locator(\"#sysverb_update\").click()\n else:\n iframe.locator(\"#sysverb_insert\").click()\n\n # Check if the record was created\n if self.check_record_created:\n # This does not work if multiple forms are created at once. The localStorage returns null after the first form\n for attempt in range(5):\n # in update tasks, the sys_id is already known as the asset is created from the start\n if update:\n sys_id = self.record_sys_id\n else:\n sys_id = page.evaluate(\"localStorage\").get(self.session_sys_id_field, None)\n\n # Pull the record from the database\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"sys_id={sys_id}\",\n \"sysparm_display_value\": True,\n },\n )[\"result\"]\n if len(record) > 0:\n break\n page.wait_for_timeout(1500)\n if attempt == 4:\n raise ValueError(\"The record was not created.\")\n\n def _set_required_config_attributes(self, config: dict) -> None:\n \"\"\"\n Set the required attributes for the task configuration.\n \"\"\"\n # XXX Warning: Some subclasses may expect a specific order of elements\n self.template_record = config[\"template_record\"]\n for f, func in self.unique_valued_fields.items():\n self.template_record[f] = func(self.template_record[f])\n self.task_fields = config[\"task_fields\"]\n\n def get_new_field_value(self, field: str, template_record: dict, table_metadata: dict) -> str:\n \"\"\"\n Generate a new value for a field based on the field type.\n \"\"\"\n new_value = template_record[\n field\n ] # Default to the template value in case the task field is not of the supported types\n if field in self.unique_valued_fields:\n return new_value","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._set_required_config_attributes","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._set_required_config_attributes#L503-L511","kind":"function","name":"_set_required_config_attributes","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":503,"end_line":511,"context_start_line":483,"context_end_line":531,"code":" if update:\n sys_id = self.record_sys_id\n else:\n sys_id = page.evaluate(\"localStorage\").get(self.session_sys_id_field, None)\n\n # Pull the record from the database\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"sys_id={sys_id}\",\n \"sysparm_display_value\": True,\n },\n )[\"result\"]\n if len(record) > 0:\n break\n page.wait_for_timeout(1500)\n if attempt == 4:\n raise ValueError(\"The record was not created.\")\n\n def _set_required_config_attributes(self, config: dict) -> None:\n \"\"\"\n Set the required attributes for the task configuration.\n \"\"\"\n # XXX Warning: Some subclasses may expect a specific order of elements\n self.template_record = config[\"template_record\"]\n for f, func in self.unique_valued_fields.items():\n self.template_record[f] = func(self.template_record[f])\n self.task_fields = config[\"task_fields\"]\n\n def get_new_field_value(self, field: str, template_record: dict, table_metadata: dict) -> str:\n \"\"\"\n Generate a new value for a field based on the field type.\n \"\"\"\n new_value = template_record[\n field\n ] # Default to the template value in case the task field is not of the supported types\n if field in self.unique_valued_fields:\n return new_value\n if \"choices\" in table_metadata[field]:\n if (\n # ... if the field has choices that are not available in the UI\n template_record[field] not in table_metadata[field][\"choices\"].values()\n or\n # ... avoid empty values if there are other choices\n (\n (template_record[field] is None or template_record[field] == \"\")\n and len(table_metadata[field][\"choices\"]) > 1\n )","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.get_new_field_value","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.get_new_field_value#L513-L550","kind":"function","name":"get_new_field_value","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":513,"end_line":550,"context_start_line":493,"context_end_line":570,"code":" \"sysparm_query\": f\"sys_id={sys_id}\",\n \"sysparm_display_value\": True,\n },\n )[\"result\"]\n if len(record) > 0:\n break\n page.wait_for_timeout(1500)\n if attempt == 4:\n raise ValueError(\"The record was not created.\")\n\n def _set_required_config_attributes(self, config: dict) -> None:\n \"\"\"\n Set the required attributes for the task configuration.\n \"\"\"\n # XXX Warning: Some subclasses may expect a specific order of elements\n self.template_record = config[\"template_record\"]\n for f, func in self.unique_valued_fields.items():\n self.template_record[f] = func(self.template_record[f])\n self.task_fields = config[\"task_fields\"]\n\n def get_new_field_value(self, field: str, template_record: dict, table_metadata: dict) -> str:\n \"\"\"\n Generate a new value for a field based on the field type.\n \"\"\"\n new_value = template_record[\n field\n ] # Default to the template value in case the task field is not of the supported types\n if field in self.unique_valued_fields:\n return new_value\n if \"choices\" in table_metadata[field]:\n if (\n # ... if the field has choices that are not available in the UI\n template_record[field] not in table_metadata[field][\"choices\"].values()\n or\n # ... avoid empty values if there are other choices\n (\n (template_record[field] is None or template_record[field] == \"\")\n and len(table_metadata[field][\"choices\"]) > 1\n )\n ):\n # XXX: We skip empty-string values because 1) they are not really interesting to\n # ask for since the agent doesn't have to do anything. They also cause issues\n # in the validation since they don't get saved properly to the database.\n choices = [v for k, v in table_metadata[field][\"choices\"].items() if k != \"\"]\n new_value = self.random.choice(choices)\n elif table_metadata[field][\"type\"] in self.string_types:\n # ... if the field is a string, we want to make sure that it's not empty\n\n if table_metadata[field][\"type\"] == \"string\":\n new_value = \" \".join(self.random.choice(ENGLISH_WORDS, size=5))\n elif table_metadata[field][\"type\"] == \"email\":\n new_value = f\"{'.'.join(self.random.choice(ENGLISH_WORDS, size=2))}@workarena.com\"\n elif table_metadata[field][\"type\"] == \"ph_number\":\n new_value = (\n f\"(514) {self.random.randint(100, 999)}-{self.random.randint(1000, 9999)}\"\n )\n\n return new_value\n\n\nclass GenericNewRecordTask(ServiceNowFormTask):\n \"\"\"\n Generic task to create a new record in a table using a Glide form.\n\n Parameters:\n -----------\n min_fields: int\n Minimum number of fields to fill (except if mandatory is more).\n max_fields: int\n Maximum number of fields to fill (except if mandatory is more).\n \"\"\"\n\n config_path = None\n expected_fields_path = None\n\n def __init__(\n self,\n form_url: str,","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.setup_goal#L1007-L1037","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1007,"end_line":1037,"context_start_line":987,"context_end_line":1057,"code":" self.record_number = record_number\n self.delete_record_on_teardown = False\n self.new_values = new_values # dict mapping fields to their new values\n # If the record sys_id is provided, the task will fetch its template record and task fields\n if self.record_sys_id is not None:\n fixed_config = {}\n template_record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"sys_id={self.record_sys_id}\",\n },\n )[\"result\"][0]\n fixed_config[\"template_record\"] = template_record\n fixed_config[\"task_fields\"] = list(self.new_values.keys())\n table_info = table_column_info(instance=self.instance, table=self.table_name)\n fixed_config[\"fields\"] = {f: table_info[f][\"label\"] for f in self.new_values.keys()}\n\n self.fixed_config = fixed_config\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n\n # If fixed_config is not None we already set the required attributes in the constructor\n # If record_sys_id is not None, the required attributes are not set in the constructor either\n if self.fixed_config is None or self.record_sys_id is not None:\n self._set_required_config_attributes(config)\n\n # Make the new values unique if needed\n for f, func in self.unique_valued_fields.items():\n if f in self.new_values:\n self.new_values[f] = func(self.new_values[f])\n\n self.protected_fields = list(self.new_values.keys())\n if self.record_sys_id is None:\n self._create_record()\n self.delete_record_on_teardown = True\n # Replace the values in the template record\n for f, v in self.new_values.items():\n self.template_record[f] = v\n self.start_url = f\"{self.start_url}%3Fsys_id%3D{self.record_sys_id}\"\n\n # Generate the goal\n goal = self.get_pretty_printed_description()\n\n info = {}\n\n return goal, info\n\n def _create_record(self) -> None:\n \"\"\"Create a record to edit.\"\"\"\n # Data to create the record\n data = {}\n for field in self.template_record:\n value = self.template_record[field]\n if type(value) == dict:\n value = value[\"display_value\"]\n # Skip sys fields as they are not editable\n if not value or \"sys\" in field:\n continue\n data[field] = value\n\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,\n data=json.dumps(data),\n method=\"POST\",\n )","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._generate_random_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._generate_random_config#L626-L722","kind":"function","name":"_generate_random_config","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":626,"end_line":722,"context_start_line":606,"context_end_line":742,"code":" # If fixed_config is not None we already set the required attributes in the constructor\n if self.fixed_config is None:\n self._set_required_config_attributes(config)\n self.protected_fields = self.task_fields\n # Generate the goal\n goal = (\n f\"Create a new {self.table_label} with \"\n + prettyprint_enum(\n [\n f'a value of \"{self.template_record[f]}\"'\n + f' for field \"{config[\"fields\"][f]}\"'\n for f in self.task_fields\n ]\n )\n + \".\"\n )\n info = {}\n\n return goal, info\n\n def _generate_random_config(self, page: Page) -> None:\n \"\"\"Generate a random configuration for the task.\"\"\"\n self.setup(page=page)\n\n # Determine task fields\n logging.debug(\"Determining task fields\")\n # ... check that we have enough fields\n assert (\n len(self.fields) >= self.min_fields\n ), f\"Only {len(self.fields)} fields are available and task expects at least {self.min_fields} to fill.\"\n # ... make sure we select a number of fields within the allowed range\n self.n_extra_fields = self.random.randint(\n self.min_fields - len(self.mandatory_fields),\n max(\n 0,\n min(\n len(self.optional_fields),\n self.max_fields - len(self.mandatory_fields),\n ),\n )\n + 1,\n )\n # ... select final fields\n self.task_fields = (\n self.mandatory_fields\n + self.random.choice(\n list(self.optional_fields), size=self.n_extra_fields, replace=False\n ).tolist()\n )\n\n # Load a random record from the database and use its values as a template\n logging.debug(\"Loading a record from the database to use as a template\")\n # ... build a query to find a record with non-empty mandatory fields\n query_non_empty_mandatory_fields = \"^\".join(\n [f\"{field}ISNOTEMPTY\" for field in self.mandatory_fields]\n )\n # ... find how many entries there are in the table\n n_entries = len(\n table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_fields\": \"sys_id\",\n \"sysparm_query\": query_non_empty_mandatory_fields,\n },\n )[\"result\"]\n )\n assert n_entries > 0, \"No entries found to serve as template for the task.\"\n # ... sample a random record\n self.template_record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_limit\": 1,\n \"sysparm_offset\": self.random.randint(0, n_entries),\n \"sysparm_display_value\": True,\n \"sysparm_query\": query_non_empty_mandatory_fields,\n },\n )[\"result\"][0]\n # ... preprocess its fields\n self.template_record = {\n f: self._preprocess_fields(f, v) for f, v in self.template_record.items()\n }\n # ... make unique any field that must have a unique value\n for f, func in self.unique_valued_fields.items():\n self.template_record[f] = func(self.template_record[f])\n\n # Replace some field values\n for f in self.fields:\n new_value = self.get_new_field_value(f, self.template_record, self.table_metadata)\n self.template_record[f] = new_value\n\n # Make sure the value satisfies the max length for the field\n self.template_record = {\n f: (\n v[: self.table_metadata[f][\"max_length\"]]\n if isinstance(v, str) and self.table_metadata[f][\"type\"] in self.string_types\n else v\n )\n for f, v in self.template_record.items()\n }\n self.created_sysids = []\n\n # generate the goal\n goal = (\n f\"Create a new {self.table_label} with \"\n + \" and \".join(\n [\n f'a value of \"{self.template_record[f]}\"'\n + f' for field \"{self.fields[f][\"label\"]}\"'\n for f in self.task_fields\n ]\n )\n + \".\"\n )\n info = {}\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Create\", \"\").replace(\"Task\", \"\")\n\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n table_metadata = table_column_info(instance=self.instance, table=self.table_name)\n # pretty field names that are displayed to the user\n task_fields = []\n for field in self.task_fields:\n # In feasible tasks, the fields are always present\n if field in table_metadata:\n field_name = table_metadata[field][\"label\"]\n # In infeasible tasks, the fields are absent from table_metadata","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.get_pretty_printed_description#L1510-L1530","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1510,"end_line":1530,"context_start_line":1490,"context_end_line":1550,"code":" goal_type: str\n Choice of \"base\", \"priority\", \"tight\", \"tight priority\". The type of goal to generate. Used in compositional tasks.\n level: int\n The level of the compositional task. Used in compositional tasks.\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/change_request.do\",\n table_label=\"change request\",\n prohibited_fields=[\"chg_model\", \"state\"],\n new_values=new_values,\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n )\n self.skip_description = skip_description\n self.goal_type = goal_type\n self.level = level\n self.__dict__.update(kwargs)\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n \"\"\"\n if self.skip_description or self.level == 3:\n return \"\"\n elif self.goal_type == \"base\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one day between conescutive change requests in the schedule.\"\n elif self.goal_type == \"priority\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one day between conescutive change requests in the schedule and the higher impact change requests should be tackled first.\"\n elif self.goal_type == \"tight\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one hour between conescutive change requests in the schedule.\"\n elif self.goal_type == \"tight priority\":\n task_info = \"Edit the schedule of the change requests by setting the start and end dates so that the change requests do not overlap. There should not be more than one hour between conescutive change requests in the schedule and the higher impact change requests should be tackled first.\"\n\n task_info += \" Finally, all change requests must respect the desired durations, which are determined by the risk level:\\n\"\n task_info += \" - High risk: 3 days \\n\"\n task_info += \" - Moderate risk: 2 days \\n\"\n task_info += \" - Low risk: 1 day \\n\"\n\n return task_info\n\n\nclass EditIncidentTask(EditRecordTask):\n \"\"\"\n Task to edit a new incident in the system.\n\n \"\"\"\n\n expected_fields_path = EXPECTED_INCIDENT_FORM_FIELDS_PATH\n\n def __init__(\n self,\n instance=None,\n fixed_config: dict = None,\n new_values: dict = None,\n record_sys_id: str = None,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.cheat#L1091-L1112","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1091,"end_line":1112,"context_start_line":1071,"context_end_line":1132,"code":" table_metadata[field][\"label\"] for field in self.new_values\n ] # pretty field names that are displayed to the user\n field_values = [self.template_record[field] for field in self.new_values]\n current_task_info = dict(zip(task_fields, field_values))\n # In L3, this is part of an enumeration\n task_info = \"- \" if self.level == 3 else \"\"\n\n task_info += (\n f\"Edit the {self.table_label} record by replacing the value of \"\n + prettyprint_enum(\n [\n f' field \"{field}\"' + f' with value \"{value}\"'\n for field, value in current_task_info.items()\n ]\n )\n + \".\"\n )\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page, iframe_only=True)\n iframe = page.frame_locator(f'iframe[name=\"{self.js_prefix}\"]')\n url = parse.urlparse(parse.unquote(self.page.evaluate(\"() => window.location.href\")))\n\n # Open the record preview, then the record\n if url.path.endswith(\"_list.do\"):\n # If the record number is provided, click on the record with that number\n if self.record_number:\n iframe.locator(f\"[aria-label='Preview record: {self.record_number}']\").click()\n # ....otherwise, click on the first record\n else:\n iframe.locator(\"td\").get_by_role(\"button\").first.click()\n page.wait_for_timeout(500)\n\n iframe.get_by_text(\"Open Record\").click()\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n page.wait_for_timeout(1000)\n self._fill_fields(page, iframe, self.new_values.keys(), update=True)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Caveat: we check only if the expected fields have the right value. We don't Check\n if there are extra fields that shouldn't be there. We could have issues\n matching other fields since calculation rules may have changed through time.\n Maybe we should assign a random value from our list of choices to the fields\n that are not part of the task.\n\n \"\"\"\n page.wait_for_load_state(\"domcontentloaded\")\n # check that the page is at the right url\n list_url = self.start_url.replace(\".do\", \"_list.do\") # list view of records\n # Check whether we are in the form or list view\n page_is_form_view = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n page_is_list_view = check_url_suffix_match(page, expected_url=list_url, task=self)\n right_url = page_is_form_view or page_is_list_view\n if not right_url:","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.validate#L1114-L1210","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1114,"end_line":1210,"context_start_line":1094,"context_end_line":1230,"code":" iframe = page.frame_locator(f'iframe[name=\"{self.js_prefix}\"]')\n url = parse.urlparse(parse.unquote(self.page.evaluate(\"() => window.location.href\")))\n\n # Open the record preview, then the record\n if url.path.endswith(\"_list.do\"):\n # If the record number is provided, click on the record with that number\n if self.record_number:\n iframe.locator(f\"[aria-label='Preview record: {self.record_number}']\").click()\n # ....otherwise, click on the first record\n else:\n iframe.locator(\"td\").get_by_role(\"button\").first.click()\n page.wait_for_timeout(500)\n\n iframe.get_by_text(\"Open Record\").click()\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n page.wait_for_timeout(1000)\n self._fill_fields(page, iframe, self.new_values.keys(), update=True)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Caveat: we check only if the expected fields have the right value. We don't Check\n if there are extra fields that shouldn't be there. We could have issues\n matching other fields since calculation rules may have changed through time.\n Maybe we should assign a random value from our list of choices to the fields\n that are not part of the task.\n\n \"\"\"\n page.wait_for_load_state(\"domcontentloaded\")\n # check that the page is at the right url\n list_url = self.start_url.replace(\".do\", \"_list.do\") # list view of records\n # Check whether we are in the form or list view\n page_is_form_view = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n page_is_list_view = check_url_suffix_match(page, expected_url=list_url, task=self)\n right_url = page_is_form_view or page_is_list_view\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n self._wait_for_ready(page, iframe_only=True)\n protected_field_changed = page.evaluate(\n \"() => window.gsft_main.WORKARENA_BAD_FIELD_CHANGED\"\n )\n if protected_field_changed:\n return (\n 0,\n True,\n \"\",\n {\"message\": \"Some fields outside of the task scope have been changed.\"},\n )\n if self.table_metadata is None:\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n self._wait_for_ready(page, iframe_only=True)\n self._get_form(page)\n if self.fields is None and page_is_form_view:\n self._get_fields(page)\n\n # Pull the record from the database\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"sys_id={self.record_sys_id}\",\n \"sysparm_display_value\": True,\n },\n wait_for_record=True,\n )[\"result\"]\n\n # This can happen if the form was submitted but was rejected due to invalid inputs (e.g., missing mandatory fields)\n if len(record) == 0:\n logging.info(\n \"The record was not found in the database. Perhaps it was deleted.\"\n + self.record_sys_id,\n )\n return (\n 0,\n True,\n \"\",\n {\"message\": \"The record was not found in the database. Perhaps it was deleted.\"},\n )\n\n # Extract display values for reference fields\n record = {\n f: v if not isinstance(v, dict) else v[\"display_value\"] for f, v in record[0].items()\n }\n\n # Check that the record matches the expected values\n for f in self.new_values.keys():\n if \"sys_\" in f:\n continue\n if record[f] != self.template_record[f]:\n logging.info(\n f'The field \"{self.table_metadata[f][\"label\"]}\" has the wrong value. Expected: \"{self.template_record[f]}\", got: \"{record[f]}\".'\n )\n error_msg = f'The field \"{self.table_metadata[f][\"label\"]}\" has the wrong value.'\n return (\n 0,\n False,\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"The record was successfully edited.\"},\n )\n\n def teardown(self) -> None:\n # Delete the record created for the task\n if self.delete_record_on_teardown:\n db_delete_from_table(\n instance=self.instance, sys_id=self.record_sys_id, table=self.table_name\n )\n\n\nclass CreateChangeRequestTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new change request in the system.\n\n \"\"\"\n\n config_path = CREATE_CHANGE_REQUEST_CONFIG_PATH\n expected_fields_path = EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._page_on_right_url","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._page_on_right_url#L1242-L1257","kind":"function","name":"_page_on_right_url","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1242,"end_line":1257,"context_start_line":1222,"context_end_line":1277,"code":" Task to create a new change request in the system.\n\n \"\"\"\n\n config_path = CREATE_CHANGE_REQUEST_CONFIG_PATH\n expected_fields_path = EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/change_request.do\",\n table_label=\"change request\",\n prohibited_fields=[\"chg_model\", \"state\"],\n fixed_config=fixed_config,\n )\n self.__dict__.update(kwargs)\n\n def _page_on_right_url(self, page: playwright.sync_api.Page) -> bool:\n \"\"\"\n The change request form lands in a view different from the list view. We need to check for this as well.\n \"\"\"\n right_url = super()._page_on_right_url(page)\n # Change request creation leads to a different page when in comp task; we need to check this case as well\n change_request_landing_page = \"/now/nav/ui/classic/params/target/sn_chg_model_ui_landing.do\"\n page_is_change_landing = (\n check_url_suffix_match(page, expected_url=change_request_landing_page, task=self)\n if self.table_label == \"change request\"\n else False\n )\n\n right_url = right_url or page_is_change_landing\n\n return right_url\n\n\nclass CreateIncidentTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new incident in the system.\n \"\"\"\n\n config_path = CREATE_INCIDENT_CONFIG_PATH\n expected_fields_path = EXPECTED_INCIDENT_FORM_FIELDS_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n check_record_created=True,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.teardown#L1212-L1217","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1212,"end_line":1217,"context_start_line":1192,"context_end_line":1237,"code":" continue\n if record[f] != self.template_record[f]:\n logging.info(\n f'The field \"{self.table_metadata[f][\"label\"]}\" has the wrong value. Expected: \"{self.template_record[f]}\", got: \"{record[f]}\".'\n )\n error_msg = f'The field \"{self.table_metadata[f][\"label\"]}\" has the wrong value.'\n return (\n 0,\n False,\n error_msg,\n {\"message\": error_msg},\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"The record was successfully edited.\"},\n )\n\n def teardown(self) -> None:\n # Delete the record created for the task\n if self.delete_record_on_teardown:\n db_delete_from_table(\n instance=self.instance, sys_id=self.record_sys_id, table=self.table_name\n )\n\n\nclass CreateChangeRequestTask(GenericNewRecordTask):\n \"\"\"\n Task to create a new change request in the system.\n\n \"\"\"\n\n config_path = CREATE_CHANGE_REQUEST_CONFIG_PATH\n expected_fields_path = EXPECTED_CHANGE_REQUEST_FORM_FIELDS_PATH\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n form_url=\"/now/nav/ui/classic/params/target/change_request.do\",\n table_label=\"change request\",\n prohibited_fields=[\"chg_model\", \"state\"],","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form._create_record","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form._create_record#L1039-L1058","kind":"function","name":"_create_record","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1039,"end_line":1058,"context_start_line":1019,"context_end_line":1078,"code":" for f, func in self.unique_valued_fields.items():\n if f in self.new_values:\n self.new_values[f] = func(self.new_values[f])\n\n self.protected_fields = list(self.new_values.keys())\n if self.record_sys_id is None:\n self._create_record()\n self.delete_record_on_teardown = True\n # Replace the values in the template record\n for f, v in self.new_values.items():\n self.template_record[f] = v\n self.start_url = f\"{self.start_url}%3Fsys_id%3D{self.record_sys_id}\"\n\n # Generate the goal\n goal = self.get_pretty_printed_description()\n\n info = {}\n\n return goal, info\n\n def _create_record(self) -> None:\n \"\"\"Create a record to edit.\"\"\"\n # Data to create the record\n data = {}\n for field in self.template_record:\n value = self.template_record[field]\n if type(value) == dict:\n value = value[\"display_value\"]\n # Skip sys fields as they are not editable\n if not value or \"sys\" in field:\n continue\n data[field] = value\n\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,\n data=json.dumps(data),\n method=\"POST\",\n )\n self.record_sys_id = result[\"result\"][\"sys_id\"]\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Edit\", \"\").replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n table_metadata = table_column_info(instance=self.instance, table=self.table_name)\n task_fields = [\n table_metadata[field][\"label\"] for field in self.new_values\n ] # pretty field names that are displayed to the user\n field_values = [self.template_record[field] for field in self.new_values]\n current_task_info = dict(zip(task_fields, field_values))\n # In L3, this is part of an enumeration\n task_info = \"- \" if self.level == 3 else \"\"\n\n task_info += (","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.is_field_visible","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.is_field_visible#L200-L207","kind":"function","name":"is_field_visible","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":200,"end_line":207,"context_start_line":180,"context_end_line":227,"code":"\n # Get the table's pretty-printed label\n logging.debug(\"Extracting table pretty-printed title\")\n self.table_label = table_api_call(\n instance=self.instance,\n table=\"sys_db_object\",\n params={\n \"sysparm_query\": f\"name={self.table_name}\",\n },\n )[\"result\"][0][\"label\"].lower()\n\n def _get_fields(self, page: Page) -> None:\n \"\"\"\n Get the form fields; split them into mandatory and optional\n \"\"\"\n page.wait_for_function(\n f\"typeof window.{self.js_prefix} !== 'undefined' && window.{self.js_prefix}.WORKARENA_LOAD_COMPLETE\",\n )\n\n # Get the form fields\n def is_field_visible(field):\n return page.evaluate(\n f\"\"\"\n {self.form_js_selector}.isVisible(\n {self.form_js_selector}.getGlideUIElement('{field}'),\n {self.form_js_selector}.getControl('{field}')\n );\"\"\"\n )\n\n logging.debug(\"Extracting valid form fields\")\n editable_fields = page.evaluate(f\"{self.form_js_selector}.getEditableFields()\")\n field_elements = page.evaluate(f\"{self.form_js_selector}.elements\")\n all_fields = [f[\"fieldName\"] for f in field_elements]\n self.fields = {\n f[\"fieldName\"]: f\n for f in field_elements\n if f[\"fieldName\"] in editable_fields\n and f[\"fieldName\"] not in self.prohibited_fields\n and f[\"type\"] in self.supported_types\n and self.table_metadata[f[\"fieldName\"]].get(\n \"dependent_on_field\", \"\"\n ) # Don't add a field that depends on one that we'll edit\n not in editable_fields\n }\n # ... and their labels\n for f in self.fields:\n self.fields[f][\"label\"] = page.evaluate(f\"{self.form_js_selector}.getLabelOf('{f}')\")\n","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.form.show_field_tab","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.form.show_field_tab#L407-L440","kind":"function","name":"show_field_tab","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":407,"end_line":440,"context_start_line":387,"context_end_line":460,"code":" ) -> None:\n \"\"\"\n Fill the fields in the form with the values from the template record. The fields to fill are specified in the\n task_fields list. Update is a flag that indicates if the task is an update task.\n \"\"\"\n # XXX We need to ensure the table metadata as well as fields are set\n # before we can proceed with the cheat function\n if self.table_metadata is None:\n self._get_form(page)\n if self.fields is None:\n self._get_fields(page)\n\n # From now on, we assume we are on the form page\n self._wait_for_ready(page)\n\n # Retry on TypeError since in very rare occasions, element evaluates to null, which raises a TypeError\n @retry(\n stop=stop_after_delay(SNOW_BROWSER_TIMEOUT // 1000),\n retry=retry_if_exception_type(TypeError),\n )\n def show_field_tab(field):\n \"\"\"\n Finds the control that allows to show the section where a field is located\n and clicks on it.\n\n \"\"\"\n section = page.evaluate(\n f\"\"\"() => {{\n const element = {self.form_js_selector}.getElement('{field}');\n const ancestors = element.ancestors();\n for (let ancestor of ancestors) {{\n // Ancestor IDs are of the form \"section-
\"\n if (ancestor.id.startsWith('section-')) {{\n return ancestor.id;\n }}\n }}\n return null; // Return null if no matching ancestor is found\n }}\"\"\"\n )\n section_id = section.split(\"-\")[-1]\n tab_sections = {\n s.split(\".\")[-1]: i\n for i, s in enumerate(page.evaluate(f\"{self.js_prefix}.g_tabs2Sections.tabIDs\"))\n }\n\n # If the section is not in the tabs do nothing (it's probably the main section)\n if section_id not in tab_sections:\n return\n\n page.evaluate_handle(\n f\"\"\"{self.js_prefix}.g_tabs2Sections.tabsTabs[\n {tab_sections[section_id]}\n ].element\"\"\"\n ).click(force=True)\n\n for field in task_fields:\n # Get the field's input control\n control = iframe.get_by_label(\n page.evaluate(f\"{self.form_js_selector}.getLabelOf('{field}')\"),\n exact=True,\n )\n if control.count() > 1:\n control = control.nth(0)\n # If the field is in a section, click on its header to make it visible\n show_field_tab(field)\n\n # Some fields are marked as string by the API but accept selection-based input\n # We use the select tag condition to match these fields. Others are marked as integers.\n if self.table_metadata[field][\"type\"] == \"choice\":\n control.select_option(str(self.template_record[field]))\n\n # Checkboxes\n elif self.table_metadata[field][\"type\"] == \"boolean\":\n control.set_checked(1 if self.template_record[field] == \"true\" else 0)","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.list#L1-L1497","kind":"module","name":"src.browsergym.workarena.tasks.list","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1,"end_line":1497,"context_start_line":1,"context_end_line":1497,"code":"\"\"\"\nTasks related to lists\n\n\"\"\"\n\nimport itertools\nimport json\nimport logging\nimport playwright.sync_api\nimport re\n\nfrom playwright.sync_api import Page\nfrom tenacity import retry, retry_if_exception_type, stop_after_delay\nfrom typing import List, Tuple\nfrom urllib import parse\nfrom warnings import warn\n\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..api.utils import table_api_call, table_column_info\nfrom ..config import (\n SNOW_BROWSER_TIMEOUT,\n FILTER_ASSET_LIST_CONFIG_PATH,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n FILTER_HARDWARE_LIST_CONFIG_PATH,\n FILTER_INCIDENT_LIST_CONFIG_PATH,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n FILTER_USER_LIST_CONFIG_PATH,\n SORT_ASSET_LIST_CONFIG_PATH,\n SORT_CHANGE_REQUEST_LIST_CONFIG_PATH,\n SORT_HARDWARE_LIST_CONFIG_PATH,\n SORT_INCIDENT_LIST_CONFIG_PATH,\n SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n SORT_USER_LIST_CONFIG_PATH,\n # EXPECTED FIELDS\n EXPECTED_ASSET_LIST_COLUMNS_PATH,\n EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n EXPECTED_HARDWARE_COLUMNS_PATH,\n EXPECTED_INCIDENT_COLUMNS_PATH,\n EXPECTED_PROBLEM_COLUMNS_PATH,\n EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n EXPECTED_USER_COLUMNS_PATH,\n)\nfrom .base import AbstractServiceNowTask\nfrom .utils.form import fill_text\nfrom .utils.utils import check_url_suffix_match\n\n\nLISTS = {\n \"alm_asset\": {\n \"url\": \"/now/nav/ui/classic/params/target/alm_asset_list.do\",\n \"forbidden_fields\": [\"sys_class_name\"],\n },\n \"alm_hardware\": {\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n \"forbidden_fields\": [],\n },\n \"change_request\": {\n \"url\": \"/now/nav/ui/classic/params/target/change_request_list.do\",\n \"forbidden_fields\": [],\n },\n \"incident\": {\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n \"forbidden_fields\": [],\n },\n \"sys_user\": {\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n \"forbidden_fields\": [\n \"sys_class_name\",\n \"roles\",\n \"sys_tags\",\n \"user_password\",\n \"password_needs_reset\",\n ],\n },\n \"sc_cat_item\": {\n \"url\": \"/now/nav/ui/classic/params/target/sc_cat_item_list.do\",\n \"forbidden_fields\": [\"roles\", \"sc_catalogs\"],\n },\n}\n\nEXTRACT_USER_LIST_INFO_CONFIG = [\n {\n \"start_rel_url\": \"/now/nav/ui/classic/params/target/sys_user_list.do%3Fsysparm_query%3Dactive%253Dtrue%255Ecompany%253D81fd65ecac1d55eb42a426568fc87a63%255Eemail%253Dlucius.bagnoli%40example.com%26sysparm_first_row%3D1%26sysparm_view%3D\",\n \"fields\": {\n \"user_name\": \"User ID\",\n \"email\": \"Email\",\n \"first_name\": \"First name\",\n \"last_name\": \"Last name\",\n },\n \"expected_values\": [\n {\n \"user_name\": \"lucius.bagnoli\",\n \"email\": \"lucius.bagnoli@example.com\",\n \"first_name\": \"Lucius\",\n \"last_name\": \"Bagnoli\",\n }\n ],\n }\n]\n\n\nclass ServiceNowListTask(AbstractServiceNowTask):\n OPERATOR_EQUALS = \"=\"\n OPERATOR_NOT_EQUALS = \"!=\"\n OPERATOR_STARTSWITH = \"STARTSWITH\"\n OPERATOR_ISEMPTY = \"ISEMPTY\"\n OPERATOR_EMPTYSTRING = \"EMPTYSTRING\"\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def _get_visible_list(self, page: Page):\n self._wait_for_ready(page)\n\n iframe = page.frame(\"gsft_main\")\n lst = iframe.locator(\"table.data_list_table\")\n lst.wait_for()\n\n # Validate the number of lists on the page\n if lst.count() > 1:\n warn(\n \"More than one list found on page. Using the first one.\",\n category=RuntimeWarning,\n )\n elif lst.count() == 0:\n raise RuntimeError(\"No list found on page.\")\n lst = lst.nth(0)\n\n # A javascript command that gets the list object\n javascript_selector = f\"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')\"\n\n return iframe, lst, javascript_selector\n\n @retry(\n stop=stop_after_delay(SNOW_BROWSER_TIMEOUT / 1000),\n retry=retry_if_exception_type(playwright.sync_api.Error),\n reraise=True,\n before_sleep=lambda _: logging.debug(\"Retrying due to a Playwright Error...\"),\n )\n def _extract_list_info(self, page: Page, with_data=False):\n \"\"\"\n Extract useful information about the list visible on the page\n\n \"\"\"\n self._wait_for_ready(page)\n\n # Grab the list component\n _, _, js_selector = self._get_visible_list(page)\n\n # Load some basic info\n list_info = {\n \"title\": page.evaluate(f\"{js_selector}.getTitle()\").lower(),\n \"glide_table\": page.evaluate(f\"{js_selector}.getTableName()\").lower(),\n \"query\": page.evaluate(f\"{js_selector}.getQuery()\"),\n \"fields\": page.evaluate(f\"{js_selector}.fields\"),\n \"js_selector\": js_selector,\n }\n\n # Get column info\n list_info[\"columns\"] = table_column_info(\n instance=self.instance,\n table=list_info[\"glide_table\"],\n )\n\n # Get the list data\n if with_data:\n data = table_api_call(\n instance=self.instance,\n table=list_info[\"glide_table\"],\n params={\n \"sysparm_query\": list_info[\"query\"],\n \"sysparm_fields\": list_info[\"fields\"],\n \"sysparm_display_value\": \"all\",\n },\n )[\"result\"]\n # Extract all display values (not raw values)\n data = [{k: v[\"display_value\"] for k, v in x.items()} for x in data]\n list_info[\"data\"] = data\n\n return list_info\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Waits for the main iframe to be fully loaded\n\n \"\"\"\n logging.debug(f\"Waiting for gsft_main to be fully loaded\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(\"Detected gsft_main ready\")\n\n logging.debug(\"Waiting for Glide list API to be available\")\n page.wait_for_function(\"window.gsft_main.GlideList2 !== undefined\")\n logging.debug(\"Detected Glide list API ready\")\n\n\nclass SortListTask(ServiceNowListTask):\n \"\"\"\n Sort a list according to a column. Works with any list.\n\n Parameters:\n -----------\n seed: int\n Random seed\n instance: SNowInstance\n The instance to use.\n list_url: str\n The relative URL of the list to sort.\n forbidden_fields: list[str]\n A list of fields that should not be used for sorting.\n This is used to avoid sorting by fields that are disabled\n in the UI.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/sort_change_request_list_task.json\n for an example of a configuration file.\n expected_fields_path:\n The path to the JSON file containing all expected fields for the task. Provided by subclasses\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n list_url=\"\",\n forbidden_fields=[],\n fixed_config: dict = None,\n expected_fields_path: str = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=list_url)\n self.min_sort_len = 1\n self.max_sort_len = 3\n self.forbidden_fields = forbidden_fields\n self.fixed_config = fixed_config\n self.config = None\n if hasattr(self, \"config_path\"):\n self.all_configs = self.all_configs()\n\n with open(expected_fields_path, \"r\") as f:\n self.expected_fields = set(json.load(f))\n self.list_info = None\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.sort_fields = self.config[\"sort_fields\"]\n self.sort_dirs = self.config[\"sort_dirs\"]\n\n # Get the task goal\n goal = self.config[\"goal\"]\n info = {}\n\n return goal, info\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n\n # Ensure that the fields that need to be sorted are visible (task feasibility check)\n self.list_info = self._extract_list_info(page)\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n return self.config[\"goal\"] + \"\\n\"\n\n def _generate_all_configs(self, seed: int, page: Page, n_fields_to_sort: int):\n self.setup(seed=seed, page=page)\n self._wait_for_ready(page)\n list_info = self._extract_list_info(page)\n\n # Get available fields\n available_fields = list(list_info[\"columns\"].keys())\n # ... remove forbidden fields\n available_fields = [f for f in available_fields if f not in self.forbidden_fields]\n\n field_txt = {k: x[\"label\"] for k, x in list_info[\"columns\"].items()}\n dir_txt = {\"asc\": \"ascending\", \"desc\": \"descending\"}\n\n # compute all field combinations\n all_sort_fields = list(itertools.combinations(available_fields, n_fields_to_sort))\n # compute all direction combinations\n all_sort_dirs = list(itertools.product(*[[\"asc\", \"desc\"] for _ in range(n_fields_to_sort)]))\n\n # product of field combinations x direction combinations\n all_configs = list(itertools.product(all_sort_fields, all_sort_dirs))\n\n all_configs = [\n {\n \"sort_fields\": sort_fields,\n \"sort_dirs\": sort_dirs,\n \"goal\": f'Sort the \"{list_info[\"title\"]}\" list by the following fields:\\n'\n + \"\\n\".join(\n [\n f\" - {field_txt[field]} ({dir_txt[dir]})\"\n for field, dir in zip(sort_fields, sort_dirs)\n ]\n ),\n }\n for sort_fields, sort_dirs in all_configs\n ]\n\n return all_configs\n\n def _generate_random_config(self, page: Page):\n self.setup(page=page)\n self._wait_for_ready(page)\n self.list_info = self._extract_list_info(page)\n # Get available fields\n available_fields = list(self.list_info[\"columns\"].keys())\n # ... remove forbidden fields\n available_fields = [f for f in available_fields if f not in self.forbidden_fields]\n\n sort_len = self.random.randint(\n self.min_sort_len, min(self.max_sort_len, len(available_fields)) + 1\n )\n\n # Pick random fields and directions to sort\n # Retry until the task is not initially solved\n try_again = True\n while try_again:\n try_again = False\n\n self.sort_fields = list(\n self.random.choice(available_fields, size=sort_len, replace=False)\n )\n self.sort_dirs = list(self.random.choice([\"asc\", \"desc\"], size=sort_len, replace=True))\n\n dir_txt = {\"asc\": \"ascending\", \"desc\": \"descending\"}\n\n sort_fields_txt = [\n self.list_info[\"columns\"][sort_field][\"label\"] for sort_field in self.sort_fields\n ]\n sort_dirs_txt = [dir_txt[sort_dir] for sort_dir in self.sort_dirs]\n\n # check if the task is already solved (can happen if the chosen field is already sorted in the default view)\n _, done, _, _ = self.validate(page, [])\n # if so, pick new fields\n if done:\n logging.warning(\"Trivial config for sort list task, picking a new config.\")\n try_again = True\n\n # generate goal\n goal = f'Sort the \"{self.list_info[\"title\"]}\" list by the following fields:\\n'\n goal += \"\\n\".join(\n [f\" - {field} ({dir})\" for field, dir in zip(sort_fields_txt, sort_dirs_txt)]\n )\n info = {}\n\n return goal, info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page)\n if self.list_info is None:\n self.list_info = self._extract_list_info(page)\n\n iframe, _, _ = self._get_visible_list(page)\n\n iframe.locator(\".list_filter_toggle\").click()\n\n # Wait for the filter to be visible\n iframe.wait_for_function(\n \"typeof document.querySelectorAll('.list_filter')[0] !== 'undefined' && document.querySelectorAll('.list_filter')[0].offsetParent !== null\"\n )\n\n dir_txt = {\"asc\": \"ascending\", \"desc\": \"descending\"}\n sort_fields_txt = [\n self.list_info[\"columns\"][sort_field][\"label\"] for sort_field in self.sort_fields\n ]\n sort_dirs_txt = [dir_txt[sort_dir] for sort_dir in self.sort_dirs]\n\n filter = iframe.locator(\".list_filter\")\n\n # skip filter rows, which are placed before sorting rows\n\n # Add all sorting conditions\n for i, (field_txt, dir_txt) in enumerate(zip(sort_fields_txt, sort_dirs_txt)):\n logging.debug(f\"Adding sort condition for column {repr(field_txt)} ({dir_txt}).\")\n filter.get_by_role(\"button\", name=\"Add Sort\").click()\n\n # TODO: Hack to solve bug where the sort condition has not yet appeared\n page.wait_for_timeout(500)\n\n # newly added row should be the last one\n row_index = filter.locator(\".filter_row\").count() - 1\n\n # Refresh since new rows are added at each iteration\n row = iframe.locator(\".filter_row\").nth(row_index)\n row_selectors = row.locator(\"select.filerTableSelect\")\n field_selector = row_selectors.nth(0)\n dir_selector = row_selectors.nth(1)\n\n # Choose field\n logging.debug(f\"Choosing sorting field {field_txt}\")\n field_selector.select_option(field_txt)\n\n # Choose sort order\n logging.debug(f\"Choosing sorting direction {dir_txt}\")\n dir_selector.select_option(dir_txt)\n\n # hack to wait for two events\n n_events_to_wait = 2\n\n def n_events_passed(event_info):\n nonlocal n_events_to_wait\n n_events_to_wait -= 1\n return n_events_to_wait == 0\n\n # click and wait for two navigations to happen (the iframe will navigate first, the page after)\n with page.expect_event(\"framenavigated\", predicate=n_events_passed):\n filter.get_by_label(\"Run filter\").click()\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n right_url = check_url_suffix_match(\n page, expected_url=self.start_url[: self.start_url.find(\"%3F\")], task=self\n )\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n self._wait_for_ready(page)\n if len(self.sort_fields) == 1:\n # XXX: Treat this as a separate case because the user may have sorted by clicking\n # on the column header. In that case, the URL will not contain the ORDERBY.\n # ... retrieve list\n list_info = self._extract_list_info(page)\n # ... get sorting info\n sort_by = page.evaluate(f'{list_info[\"js_selector\"]}.getOrderBy()')\n sort_dir = page.evaluate(f'{list_info[\"js_selector\"]}.sortDir')\n # ... check if the list is sorted correctly\n if sort_by == self.sort_fields[0] and sort_dir.lower() == self.sort_dirs[0]:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct sorting.\"},\n )\n\n else:\n # pre-process the URL\n page_url = page.evaluate(\"() => window.location.href\")\n page_url = parse.unquote(page_url)\n page_query = parse.urlparse(page_url).query\n page_qs = parse.parse_qs(page_query)\n\n # make sure \"sysparm_query\" is present\n if \"sysparm_query\" not in page_qs:\n return 0, False, \"\", {\"message\": \"No sysparm_query found in URL.\"}\n\n # concatenate desired order_by conditions\n order_dir = {\"asc\": \"\", \"desc\": \"DESC\"}\n sysparam_query_regex = r\"\\^\".join(\n [\n f\"ORDERBY{order_dir[dir]}{field}\"\n for field, dir in zip(self.sort_fields, self.sort_dirs)\n ]\n )\n sysparam_query_regex = (\n r\"^((?!ORDERBY).)*\" + sysparam_query_regex + r\"((?!ORDERBY).)*$\"\n ) # forbid undesired order_by conditions\n\n # check \"sysparm_query\" for the correct sort conditions\n page_sysparam_query = page_qs[\"sysparm_query\"][0]\n if page_sysparam_query and re.match(sysparam_query_regex, page_sysparam_query):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct sorting.\"},\n )\n\n return 0, False, \"\", {\"message\": \"Incorrect sorting.\"}\n\n\nclass FilterListTask(ServiceNowListTask):\n \"\"\"\n Filter a list according to a few columns. Works with any list.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n list_url: str\n The relative URL of the list to filter.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n expected_fields_path:\n The path to the JSON file containing all expected fields for the task. Provided by subclasses\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n list_url=\"\",\n fixed_config: dict = None,\n expected_fields_path: str = None,\n **kwargs,\n ) -> None:\n self.min_filter_len = 2\n self.max_filter_len = 5\n super().__init__(seed=seed, instance=instance, start_rel_url=list_url)\n self.fixed_config = fixed_config\n self.config = None\n if hasattr(self, \"config_path\"):\n self.all_configs = self.all_configs()\n\n with open(expected_fields_path, \"r\") as f:\n self.expected_fields = set(json.load(f))\n self.table_name = list_url.split(\"/\")[-1].split(\"_list.do\")[0]\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n self.filter_columns = config[\"filter_columns\"]\n self.filter_values = config[\"filter_values\"]\n # Base filter configs do not have filter_operands, so we default to \"is\"\n self.filter_operators = config.get(\"filter_operators\", [\"is\" for _\n# ... truncated ...","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.ServiceNowListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.ServiceNowListTask#L103-L201","kind":"class","name":"ServiceNowListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":103,"end_line":201,"context_start_line":83,"context_end_line":221,"code":" {\n \"start_rel_url\": \"/now/nav/ui/classic/params/target/sys_user_list.do%3Fsysparm_query%3Dactive%253Dtrue%255Ecompany%253D81fd65ecac1d55eb42a426568fc87a63%255Eemail%253Dlucius.bagnoli%40example.com%26sysparm_first_row%3D1%26sysparm_view%3D\",\n \"fields\": {\n \"user_name\": \"User ID\",\n \"email\": \"Email\",\n \"first_name\": \"First name\",\n \"last_name\": \"Last name\",\n },\n \"expected_values\": [\n {\n \"user_name\": \"lucius.bagnoli\",\n \"email\": \"lucius.bagnoli@example.com\",\n \"first_name\": \"Lucius\",\n \"last_name\": \"Bagnoli\",\n }\n ],\n }\n]\n\n\nclass ServiceNowListTask(AbstractServiceNowTask):\n OPERATOR_EQUALS = \"=\"\n OPERATOR_NOT_EQUALS = \"!=\"\n OPERATOR_STARTSWITH = \"STARTSWITH\"\n OPERATOR_ISEMPTY = \"ISEMPTY\"\n OPERATOR_EMPTYSTRING = \"EMPTYSTRING\"\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def _get_visible_list(self, page: Page):\n self._wait_for_ready(page)\n\n iframe = page.frame(\"gsft_main\")\n lst = iframe.locator(\"table.data_list_table\")\n lst.wait_for()\n\n # Validate the number of lists on the page\n if lst.count() > 1:\n warn(\n \"More than one list found on page. Using the first one.\",\n category=RuntimeWarning,\n )\n elif lst.count() == 0:\n raise RuntimeError(\"No list found on page.\")\n lst = lst.nth(0)\n\n # A javascript command that gets the list object\n javascript_selector = f\"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')\"\n\n return iframe, lst, javascript_selector\n\n @retry(\n stop=stop_after_delay(SNOW_BROWSER_TIMEOUT / 1000),\n retry=retry_if_exception_type(playwright.sync_api.Error),\n reraise=True,\n before_sleep=lambda _: logging.debug(\"Retrying due to a Playwright Error...\"),\n )\n def _extract_list_info(self, page: Page, with_data=False):\n \"\"\"\n Extract useful information about the list visible on the page\n\n \"\"\"\n self._wait_for_ready(page)\n\n # Grab the list component\n _, _, js_selector = self._get_visible_list(page)\n\n # Load some basic info\n list_info = {\n \"title\": page.evaluate(f\"{js_selector}.getTitle()\").lower(),\n \"glide_table\": page.evaluate(f\"{js_selector}.getTableName()\").lower(),\n \"query\": page.evaluate(f\"{js_selector}.getQuery()\"),\n \"fields\": page.evaluate(f\"{js_selector}.fields\"),\n \"js_selector\": js_selector,\n }\n\n # Get column info\n list_info[\"columns\"] = table_column_info(\n instance=self.instance,\n table=list_info[\"glide_table\"],\n )\n\n # Get the list data\n if with_data:\n data = table_api_call(\n instance=self.instance,\n table=list_info[\"glide_table\"],\n params={\n \"sysparm_query\": list_info[\"query\"],\n \"sysparm_fields\": list_info[\"fields\"],\n \"sysparm_display_value\": \"all\",\n },\n )[\"result\"]\n # Extract all display values (not raw values)\n data = [{k: v[\"display_value\"] for k, v in x.items()} for x in data]\n list_info[\"data\"] = data\n\n return list_info\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Waits for the main iframe to be fully loaded\n\n \"\"\"\n logging.debug(f\"Waiting for gsft_main to be fully loaded\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(\"Detected gsft_main ready\")\n\n logging.debug(\"Waiting for Glide list API to be available\")\n page.wait_for_function(\"window.gsft_main.GlideList2 !== undefined\")\n logging.debug(\"Detected Glide list API ready\")\n\n\nclass SortListTask(ServiceNowListTask):\n \"\"\"\n Sort a list according to a column. Works with any list.\n\n Parameters:\n -----------\n seed: int\n Random seed\n instance: SNowInstance\n The instance to use.\n list_url: str\n The relative URL of the list to sort.\n forbidden_fields: list[str]\n A list of fields that should not be used for sorting.\n This is used to avoid sorting by fields that are disabled\n in the UI.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.SortListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.SortListTask#L204-L495","kind":"class","name":"SortListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":204,"end_line":495,"context_start_line":184,"context_end_line":515,"code":" list_info[\"data\"] = data\n\n return list_info\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Waits for the main iframe to be fully loaded\n\n \"\"\"\n logging.debug(f\"Waiting for gsft_main to be fully loaded\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(\"Detected gsft_main ready\")\n\n logging.debug(\"Waiting for Glide list API to be available\")\n page.wait_for_function(\"window.gsft_main.GlideList2 !== undefined\")\n logging.debug(\"Detected Glide list API ready\")\n\n\nclass SortListTask(ServiceNowListTask):\n \"\"\"\n Sort a list according to a column. Works with any list.\n\n Parameters:\n -----------\n seed: int\n Random seed\n instance: SNowInstance\n The instance to use.\n list_url: str\n The relative URL of the list to sort.\n forbidden_fields: list[str]\n A list of fields that should not be used for sorting.\n This is used to avoid sorting by fields that are disabled\n in the UI.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/sort_change_request_list_task.json\n for an example of a configuration file.\n expected_fields_path:\n The path to the JSON file containing all expected fields for the task. Provided by subclasses\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n list_url=\"\",\n forbidden_fields=[],\n fixed_config: dict = None,\n expected_fields_path: str = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=list_url)\n self.min_sort_len = 1\n self.max_sort_len = 3\n self.forbidden_fields = forbidden_fields\n self.fixed_config = fixed_config\n self.config = None\n if hasattr(self, \"config_path\"):\n self.all_configs = self.all_configs()\n\n with open(expected_fields_path, \"r\") as f:\n self.expected_fields = set(json.load(f))\n self.list_info = None\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.sort_fields = self.config[\"sort_fields\"]\n self.sort_dirs = self.config[\"sort_dirs\"]\n\n # Get the task goal\n goal = self.config[\"goal\"]\n info = {}\n\n return goal, info\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n\n # Ensure that the fields that need to be sorted are visible (task feasibility check)\n self.list_info = self._extract_list_info(page)\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n return self.config[\"goal\"] + \"\\n\"\n\n def _generate_all_configs(self, seed: int, page: Page, n_fields_to_sort: int):\n self.setup(seed=seed, page=page)\n self._wait_for_ready(page)\n list_info = self._extract_list_info(page)\n\n # Get available fields\n available_fields = list(list_info[\"columns\"].keys())\n # ... remove forbidden fields\n available_fields = [f for f in available_fields if f not in self.forbidden_fields]\n\n field_txt = {k: x[\"label\"] for k, x in list_info[\"columns\"].items()}\n dir_txt = {\"asc\": \"ascending\", \"desc\": \"descending\"}\n\n # compute all field combinations\n all_sort_fields = list(itertools.combinations(available_fields, n_fields_to_sort))\n # compute all direction combinations\n all_sort_dirs = list(itertools.product(*[[\"asc\", \"desc\"] for _ in range(n_fields_to_sort)]))\n\n # product of field combinations x direction combinations\n all_configs = list(itertools.product(all_sort_fields, all_sort_dirs))\n\n all_configs = [\n {\n \"sort_fields\": sort_fields,\n \"sort_dirs\": sort_dirs,\n \"goal\": f'Sort the \"{list_info[\"title\"]}\" list by the following fields:\\n'\n + \"\\n\".join(\n [\n f\" - {field_txt[field]} ({dir_txt[dir]})\"\n for field, dir in zip(sort_fields, sort_dirs)\n ]\n ),\n }\n for sort_fields, sort_dirs in all_configs\n ]\n\n return all_configs\n\n def _generate_random_config(self, page: Page):\n self.setup(page=page)\n self._wait_for_ready(page)\n self.list_info = self._extract_list_info(page)\n # Get available fields\n available_fields = list(self.list_info[\"columns\"].keys())\n # ... remove forbidden fields\n available_fields = [f for f in available_fields if f not in self.forbidden_fields]\n\n sort_len = self.random.randint(\n self.min_sort_len, min(self.max_sort_len, len(available_fields)) + 1\n )\n\n # Pick random fields and directions to sort\n # Retry until the task is not initially solved\n try_again = True\n while try_again:\n try_again = False\n\n self.sort_fields = list(\n self.random.choice(available_fields, size=sort_len, replace=False)\n )\n self.sort_dirs = list(self.random.choice([\"asc\", \"desc\"], size=sort_len, replace=True))\n\n dir_txt = {\"asc\": \"ascending\", \"desc\": \"descending\"}\n\n sort_fields_txt = [\n self.list_info[\"columns\"][sort_field][\"label\"] for sort_field in self.sort_fields\n ]\n sort_dirs_txt = [dir_txt[sort_dir] for sort_dir in self.sort_dirs]\n\n # check if the task is already solved (can happen if the chosen field is already sorted in the default view)\n _, done, _, _ = self.validate(page, [])\n # if so, pick new fields\n if done:\n logging.warning(\"Trivial config for sort list task, picking a new config.\")\n try_again = True\n\n # generate goal\n goal = f'Sort the \"{self.list_info[\"title\"]}\" list by the following fields:\\n'\n goal += \"\\n\".join(\n [f\" - {field} ({dir})\" for field, dir in zip(sort_fields_txt, sort_dirs_txt)]\n )\n info = {}\n\n return goal, info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page)\n if self.list_info is None:\n self.list_info = self._extract_list_info(page)\n\n iframe, _, _ = self._get_visible_list(page)\n\n iframe.locator(\".list_filter_toggle\").click()\n\n # Wait for the filter to be visible\n iframe.wait_for_function(\n \"typeof document.querySelectorAll('.list_filter')[0] !== 'undefined' && document.querySelectorAll('.list_filter')[0].offsetParent !== null\"\n )\n\n dir_txt = {\"asc\": \"ascending\", \"desc\": \"descending\"}\n sort_fields_txt = [\n self.list_info[\"columns\"][sort_field][\"label\"] for sort_field in self.sort_fields\n ]\n sort_dirs_txt = [dir_txt[sort_dir] for sort_dir in self.sort_dirs]\n\n filter = iframe.locator(\".list_filter\")\n\n # skip filter rows, which are placed before sorting rows\n\n # Add all sorting conditions\n for i, (field_txt, dir_txt) in enumerate(zip(sort_fields_txt, sort_dirs_txt)):\n logging.debug(f\"Adding sort condition for column {repr(field_txt)} ({dir_txt}).\")\n filter.get_by_role(\"button\", name=\"Add Sort\").click()\n\n # TODO: Hack to solve bug where the sort condition has not yet appeared\n page.wait_for_timeout(500)\n\n # newly added row should be the last one\n row_index = filter.locator(\".filter_row\").count() - 1\n\n # Refresh since new rows are added at each iteration\n row = iframe.locator(\".filter_row\").nth(row_index)\n row_selectors = row.locator(\"select.filerTableSelect\")\n field_selector = row_selectors.nth(0)\n dir_selector = row_selectors.nth(1)\n\n # Choose field\n logging.debug(f\"Choosing sorting field {field_txt}\")\n field_selector.select_option(field_txt)\n\n # Choose sort order\n logging.debug(f\"Choosing sorting direction {dir_txt}\")\n dir_selector.select_option(dir_txt)\n\n # hack to wait for two events\n n_events_to_wait = 2\n\n def n_events_passed(event_info):\n nonlocal n_events_to_wait\n n_events_to_wait -= 1\n return n_events_to_wait == 0\n\n # click and wait for two navigations to happen (the iframe will navigate first, the page after)\n with page.expect_event(\"framenavigated\", predicate=n_events_passed):\n filter.get_by_label(\"Run filter\").click()\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n right_url = check_url_suffix_match(\n page, expected_url=self.start_url[: self.start_url.find(\"%3F\")], task=self\n )\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n self._wait_for_ready(page)\n if len(self.sort_fields) == 1:\n # XXX: Treat this as a separate case because the user may have sorted by clicking\n # on the column header. In that case, the URL will not contain the ORDERBY.\n # ... retrieve list\n list_info = self._extract_list_info(page)\n # ... get sorting info\n sort_by = page.evaluate(f'{list_info[\"js_selector\"]}.getOrderBy()')\n sort_dir = page.evaluate(f'{list_info[\"js_selector\"]}.sortDir')\n # ... check if the list is sorted correctly\n if sort_by == self.sort_fields[0] and sort_dir.lower() == self.sort_dirs[0]:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct sorting.\"},\n )\n\n else:\n # pre-process the URL\n page_url = page.evaluate(\"() => window.location.href\")\n page_url = parse.unquote(page_url)\n page_query = parse.urlparse(page_url).query\n page_qs = parse.parse_qs(page_query)\n\n # make sure \"sysparm_query\" is present\n if \"sysparm_query\" not in page_qs:\n return 0, False, \"\", {\"message\": \"No sysparm_query found in URL.\"}\n\n # concatenate desired order_by conditions\n order_dir = {\"asc\": \"\", \"desc\": \"DESC\"}\n sysparam_query_regex = r\"\\^\".join(\n [\n f\"ORDERBY{order_dir[dir]}{field}\"\n for field, dir in zip(self.sort_fields, self.sort_dirs)\n ]\n )\n sysparam_query_regex = (\n r\"^((?!ORDERBY).)*\" + sysparam_query_regex + r\"((?!ORDERBY).)*$\"\n ) # forbid undesired order_by conditions\n\n # check \"sysparm_query\" for the correct sort conditions\n page_sysparam_query = page_qs[\"sysparm_query\"][0]\n if page_sysparam_query and re.match(sysparam_query_regex, page_sysparam_query):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct sorting.\"},\n )\n\n return 0, False, \"\", {\"message\": \"Incorrect sorting.\"}\n\n\nclass FilterListTask(ServiceNowListTask):\n \"\"\"\n Filter a list according to a few columns. Works with any list.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n list_url: str\n The relative URL of the list to filter.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n expected_fields_path:\n The path to the JSON file containing all expected fields for the task. Provided by subclasses\n \"\"\"\n","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.FilterListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.FilterListTask#L498-L931","kind":"class","name":"FilterListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":498,"end_line":931,"context_start_line":478,"context_end_line":951,"code":" for field, dir in zip(self.sort_fields, self.sort_dirs)\n ]\n )\n sysparam_query_regex = (\n r\"^((?!ORDERBY).)*\" + sysparam_query_regex + r\"((?!ORDERBY).)*$\"\n ) # forbid undesired order_by conditions\n\n # check \"sysparm_query\" for the correct sort conditions\n page_sysparam_query = page_qs[\"sysparm_query\"][0]\n if page_sysparam_query and re.match(sysparam_query_regex, page_sysparam_query):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct sorting.\"},\n )\n\n return 0, False, \"\", {\"message\": \"Incorrect sorting.\"}\n\n\nclass FilterListTask(ServiceNowListTask):\n \"\"\"\n Filter a list according to a few columns. Works with any list.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n list_url: str\n The relative URL of the list to filter.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n expected_fields_path:\n The path to the JSON file containing all expected fields for the task. Provided by subclasses\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n list_url=\"\",\n fixed_config: dict = None,\n expected_fields_path: str = None,\n **kwargs,\n ) -> None:\n self.min_filter_len = 2\n self.max_filter_len = 5\n super().__init__(seed=seed, instance=instance, start_rel_url=list_url)\n self.fixed_config = fixed_config\n self.config = None\n if hasattr(self, \"config_path\"):\n self.all_configs = self.all_configs()\n\n with open(expected_fields_path, \"r\") as f:\n self.expected_fields = set(json.load(f))\n self.table_name = list_url.split(\"/\")[-1].split(\"_list.do\")[0]\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n self.filter_columns = config[\"filter_columns\"]\n self.filter_values = config[\"filter_values\"]\n # Base filter configs do not have filter_operands, so we default to \"is\"\n self.filter_operators = config.get(\"filter_operators\", [\"is\" for _ in self.filter_columns])\n self.filter_kind = config[\"filter_kind\"]\n list_info = config.get(\"list_info\")\n if list_info is None:\n list_info = {\"columns\": table_column_info(self.instance, self.table_name)}\n self.list_info = list_info\n self.filter_len = len(self.filter_columns)\n\n # Generate goal\n goal = self.get_pretty_printed_description(goal=True)\n info = {}\n\n return goal, info\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n\n def get_pretty_printed_description(self, goal=False) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n\n args:\n goal: bool\n If True, return as the goal of the task (without the starting dash)\n \"\"\"\n task_info = \"\" if goal else \"- \"\n task_info += (\n f\"Create a filter for the list to extract all entries where:\"\n + f\" {'and' if self.filter_kind == 'AND' else 'or'} \".join(\n [\n f'\\n - \"{self.list_info[\"columns\"][col][\"label\"]}\" {filter_operator} \"{val}\"'\n for col, filter_operator, val in zip(\n self.filter_columns, self.filter_operators, self.filter_values\n )\n ]\n )\n )\n\n return task_info\n\n def _generate_random_config(self, page: Page):\n self.setup(page=page)\n self._wait_for_ready(page)\n\n # Extract the list from the page\n self.list_info = self._extract_list_info(page)\n\n # Choose the columns to filter on\n allowed_types = [\"string\", \"choice\", \"reference\", \"translated_text\", \"boolean\"]\n valid_filter_columns = [\n k for k, v in self.list_info[\"columns\"].items() if v[\"type\"] in allowed_types\n ]\n assert len(valid_filter_columns) > 0, \"Not enough columns to filter on.\"\n self.filter_len = self.random.randint(\n self.min_filter_len, min(self.max_filter_len, len(valid_filter_columns)) + 1\n )\n self.filter_columns = list(\n self.random.choice(valid_filter_columns, self.filter_len, replace=False)\n )\n\n # Choose the filter kind\n if self.filter_len == 1:\n # If there is only one column to filter on, then the kind is always AND\n self.filter_kind = \"AND\"\n else:\n self.filter_kind = self.random.choice([\"AND\", \"OR\"])\n\n # Choose the values to filter on\n # We do this by loading a single record at random and using its values\n # This is significantly faster than loading all records and then filtering\n offset = self.random.randint(\n 0, page.evaluate(f'{self.list_info[\"js_selector\"]}.grandTotalRows')\n )\n data = table_api_call(\n instance=self.instance,\n table=self.list_info[\"glide_table\"],\n params={\n \"sysparm_query\": self.list_info[\"query\"],\n \"sysparm_fields\": \",\".join(self.filter_columns),\n \"sysparm_display_value\": \"all\",\n \"sysparm_limit\": \"1\",\n \"sysparm_offset\": f\"{offset}\",\n },\n )[\"result\"][0]\n # XXX: The use of \"\" as default display value is a hack, but it seems to work for now.\n self.filter_values = [\n data.get(c, {\"display_value\": \"\"})[\"display_value\"] for c in self.filter_columns\n ]\n\n # Make sure we expand empty strings to their expected display value (the API fails to do this)\n for i, (col, val) in enumerate(zip(self.filter_columns, self.filter_values)):\n if self.list_info[\"columns\"][col][\"type\"] == \"choice\" and val in [None, \"\"]:\n self.filter_values[i] = self.list_info[\"columns\"][col][\"choices\"].get(\n \"\", \"-- None --\"\n )\n # XXX: The use of -- None -- as default is a hack, but it seems to work for now.\n\n # Make sure there are no trailing spaces in the values\n self.filter_values = [v.strip() for v in self.filter_values]\n\n # Make sure we use only values that are available in the UI\n # (some database entries have old values that are no longer available)\n for i, (c, v) in enumerate(zip(self.filter_columns, self.filter_values)):\n if \"choices\" in self.list_info[\"columns\"][c]:\n if v not in self.list_info[\"columns\"][c][\"choices\"]:\n # replace with a random choice\n self.filter_values[i] = self.random.choice(\n list(self.list_info[\"columns\"][c][\"choices\"].values())\n )\n goal = (\n f\"Create a filter for the list to extract all entries where \"\n + f\" {'and' if self.filter_kind == 'AND' else 'or'} \".join(\n [\n f'\"{self.list_info[\"columns\"][col][\"label\"]}\" is \"{val}\"'\n for col, val in zip(self.filter_columns, self.filter_values)\n ]\n )\n + \".\"\n )\n\n return goal, {}\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page)\n\n iframe, _, _ = self._get_visible_list(page)\n\n iframe.locator(\".list_filter_toggle\").click()\n\n # Wait for the filter to be visible\n iframe.wait_for_function(\n \"typeof document.querySelectorAll('.list_filter')[0] !== 'undefined' && document.querySelectorAll('.list_filter')[0].offsetParent !== null\"\n )\n\n # Clear any existing filters\n # Use a while loop and click the first button until there are no more buttons\n while iframe.locator(\".filerTableAction.deleteButton:visible\").count() > 0:\n logging.debug(\"Clearing existing filter condition\")\n iframe.locator(\".filerTableAction.deleteButton:visible\").nth(0).click()\n\n # TODO: Hack to solve issue where the filters were not all removed\n page.wait_for_timeout(3000)\n\n # Add all filter conditions\n for i in range(len(self.filter_columns)):\n logging.debug(\n \"Adding filter condition for column \"\n + self.filter_columns[i]\n + \" with value \"\n + self.filter_values[i]\n )\n\n # Add conditions in this loop so that it looks more dynamic\n if i > 0:\n logging.debug(\"Need to create new filter condition of type \" + self.filter_kind)\n iframe.locator(\n f'.filterToolbar .filerTableAction:text-is(\"{self.filter_kind}\")'\n ).click()\n # TODO: Hack to solve bug where the filter condition has not yet appeared\n page.wait_for_timeout(1000)\n\n # Refresh since new rows are added at each iteration\n filter_rows = iframe.locator(\".filter_row\")\n row = filter_rows.nth(i)\n\n # Choose field\n logging.debug(\"Choosing field \" + self.filter_columns[i])\n field_selector = row.locator(\"select.filerTableSelect\").first\n field_selector.select_option(self.filter_columns[i])\n\n # Select the right operator\n operator = self.filter_operators[i]\n operator_symbol = (\n row.locator(\"select.condOperator\")\n .get_by_text(operator, exact=True)\n .get_attribute(\"value\")\n )\n logging.debug(f\"Choosing operator {operator}\")\n row.locator(\"select.condOperator\").select_option(operator_symbol)\n\n # Fill in the value\n logging.debug(\"Filling in value \" + self.filter_values[i])\n type_ = self.list_info[\"columns\"][self.filter_columns[i]][\"type\"]\n if type_ in [\"string\", \"reference\", \"translated_text\"]:\n # expect a textbox\n logging.debug(\"filling in textbox\")\n\n # If empty, don't do anything\n if self.filter_values[i] == \"\":\n continue\n\n # Find the value input field\n inputs = row.locator(\"#value input\")\n input_field = [\n inputs.nth(j) for j in range(inputs.count()) if inputs.nth(j).is_visible()\n ][0]\n fill_text(\n page=page,\n iframe=iframe,\n input_field=input_field,\n value=self.filter_values[i],\n )\n else:\n # expect a selector\n logging.debug(\"filling in selector\")\n # Find the value input field\n input_field = row.locator(\"#value select\")\n input_field.select_option(self.filter_values[i])\n\n iframe.locator(\".filterToolbar\").get_by_text(\"Run\").click()\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n\n Note: current implementation is limited to AND and OR filters (single type per filter) with equality operators\n\n \"\"\"\n right_url = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n self._wait_for_ready(page)\n\n # Retrieve the current query\n list_info = self._extract_list_info(page)\n current_query = list_info[\"query\"]\n\n if not current_query:\n return 0, False, \"\", {\"message\": \"There are no filters yet.\"}\n\n # Replace \"new query\" statements with the standard OR separator\n current_query = current_query.replace(\"^NQ\", \"^OR\")\n\n # Validate query kind is ok\n if \"^OR\" in current_query:\n current_kind = \"OR\"\n current_sep = \"^OR\"\n else:\n current_kind = \"AND\"\n current_sep = \"^\"\n\n if current_kind != self.filter_kind:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"The kind of filter used is incorrect: {current_query}.\"},\n )\n\n # Extract the query pieces for validation\n current_query = current_query.split(current_sep)\n\n # Validate query length is ok\n if len(current_query) != self.filter_len:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Incorrect number of filter conditions: {current_query}.\"},\n )\n\n # Parse column names, operators, and values\n current_columns, current_operators, current_values = [], [], []\n\n # Note that this is not exhaustive. If/when other operators are added, this will have to be updated.\n for predicate in current_query:\n if self.OPERATOR_EMPTYSTRING in predicate:\n current_columns.append(predicate.replace(self.OPERATOR_EMPTYSTRING, \"\").strip())\n current_operators.append(\"=\")\n current_values.append(\"\")\n elif self.OPERATOR_ISEMPTY in predicate:\n current_columns.append(predicate.replace(self.OPERATOR_ISEMPTY, \"\").strip())\n current_operators.append(\"=\")\n current_values.append(\"\")\n elif any(\n unsupported_operator in predicate\n for unsupported_operator in [self.OPERATOR_NOT_EQUALS, self.OPERATOR_STARTSWITH]\n ):\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Unexpected operator in filter condition: {current_query}.\"},\n )\n elif self.OPERATOR_EQUALS in predicate:\n col, val = predicate.split(self.OPERATOR_EQUALS, 1)\n current_columns.append(col.strip())\n current_operators.append(\"=\")\n current_values.append(val.strip())\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Unexpected operator in filter condition: {current_query}.\"},\n )\n\n if set(current_columns) != set(self.filter_columns):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Incorrect filter columns: {set(current_columns)}. Expected: {set(self.filter_columns)}.\"\n },\n )\n\n # Validate query values are ok\n # This is the tricky part because we need to expand the values to their display values\n # We also need to handle the case where the value is a reference\n\n # Handle filtering across multiple rows\n if len(set(current_columns)) < len(current_columns):\n if len(set(current_columns)) != 1:\n raise Exception(\"Filtering is only allowed across rows for the same column.\")\n # Filter multiple rows with a column\n is_homogenous_filter = True\n else:\n # Current setting where we use multiple columns to filter\n is_homogenous_filter = False\n for index, (col, val) in enumerate(zip(current_columns, current_values)):\n col_info = self.list_info[\"columns\"][col]\n # Get the column type\n if col_info[\"type\"] == \"reference\" and val != \"\":\n # Get the reference table\n ref_table = col_info[\"reference\"]\n ref_field = col_info[\"reference_attributes\"][\"display_field\"]\n if is_homogenous_filter:\n current_values[index] = table_api_call(\n instance=self.instance,\n table=ref_table,\n params={\n \"sysparm_query\": f\"sys_id={val}\",\n \"sysparm_fields\": ref_field,\n \"sysparm_display_value\": \"all\",\n },\n )[\"result\"][0][ref_field][\"display_value\"]\n else:\n # Get the reference display value\n current_values[current_columns.index(col)] = table_api_call(\n instance=self.instance,\n table=ref_table,\n params={\n \"sysparm_query\": f\"sys_id={val}\",\n \"sysparm_fields\": ref_field,\n \"sysparm_display_value\": \"all\",\n },\n )[\"result\"][0][ref_field][\"display_value\"]\n\n elif col_info[\"type\"] == \"choice\":\n # Get the choice display value\n current_values[current_columns.index(col)] = self.list_info[\"columns\"][col][\n \"choices\"\n ].get(val, \"-- None --\")\n # XXX: The above is a hack to address a rare glitch. Sometimes, empty values are allowed in the UI\n # but that value is not in the choices. Usually, the UI shows this as -- None -- so we use that.\n\n # Validate the values\n if set(current_values) != set(self.filter_values):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Incorrect filter values {set(current_values)}. Expected: {set(self.filter_values)}.\"\n },\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": f\"Correct filter: {list_info['query']}.\"},\n )\n\n\nclass ExtractListInfoTask(ServiceNowListTask):\n \"\"\"\n Extract information from some fields in a list. Works with any list.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n list_url: str\n The relative URL of the list to filter.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n config_path:\n The path to the JSON file containing all configurations for the task. Provided by subclasses\n list_name: str\n Name of the list to extract information from.","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.ExtractListInfoTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.ExtractListInfoTask#L934-L1182","kind":"class","name":"ExtractListInfoTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":934,"end_line":1182,"context_start_line":914,"context_end_line":1202,"code":"\n # Validate the values\n if set(current_values) != set(self.filter_values):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Incorrect filter values {set(current_values)}. Expected: {set(self.filter_values)}.\"\n },\n )\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": f\"Correct filter: {list_info['query']}.\"},\n )\n\n\nclass ExtractListInfoTask(ServiceNowListTask):\n \"\"\"\n Extract information from some fields in a list. Works with any list.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n list_url: str\n The relative URL of the list to filter.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n config_path:\n The path to the JSON file containing all configurations for the task. Provided by subclasses\n list_name: str\n Name of the list to extract information from.\n list_url: str\n url of the list to extract information from.\n unique_field_name: str\n Name of the field used as unique in the list. This field is required in configs.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n configs: str = \"\",\n list_name: str = \"\",\n list_url: str = \"\",\n unique_field_name: str = \"\",\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed, instance=instance, start_rel_url=list_url\n ) # For these tasks, the start URL is defined in the setup method, as the URL depends on the configuration\n self.fixed_config = fixed_config\n self.config = None\n self.all_configs = configs\n self.list_name = list_name\n self.table_name = \"\"\n self.unique_field_name = unique_field_name\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n self.fields = config[\"fields\"] # mapping between fields and their display names\n self.printed_field_names = {\n v: k for k, v in self.fields.items()\n } # mapping between fields and their system names\n self.expected_values = config[\n \"expected_values\"\n ] # mapping between fields and their expected values\n # This is setup here because the start_url depends on the config\n assert (\n self.unique_field_name in self.fields.keys()\n ), f\"Unique field name {self.unique_field_name} not in fields.\"\n assert all(\n [self.unique_field_name in expected_value for expected_value in self.expected_values]\n ), f\"Unique field name {self.unique_field_name} not in expected values.\"\n\n if not self.start_url or self.start_url == self.instance.snow_url:\n self.start_rel_url = config[\"start_rel_url\"]\n self.start_url = self.instance.snow_url + self.start_rel_url\n # table_name can be passed in the constructor or extracted from the start_rel_url, located in the config\n if self.table_name is None:\n self.table_name = self.start_rel_url.split(\"/\")[-1].split(\"_list.do\")[0]\n\n goal = self.get_pretty_printed_description()\n info = {}\n\n return goal, info\n\n def start(self, page: Page) -> None:\n super().start(page)\n # TODO: We should add a check to make sure the required columns are present in the list\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks and used as goal in L1 tasks.\n called by subclasses\n \"\"\"\n print_field_names = list(self.fields.values())\n print_field_names.remove(\n self.fields[self.unique_field_name]\n ) # the unique fields are the keys in the dict\n if len(print_field_names) > 1:\n fields_str = (\n '\"' + '\", \"'.join(print_field_names[:-1]) + f'\" and \"{print_field_names[-1]}\"'\n )\n printed_unique_field_name = self.fields[self.unique_field_name]\n task_description = (\n f\"- Extract information of field(s) {fields_str} \"\n + f'from the \"{self.list_name}\" list. Return the result as a json where keys are the values of the \"{printed_unique_field_name}\" field and values are mappings between the fields and the extracted information. Please provide this information in the chat.'\n )\n else:\n fields_str = print_field_names[0]\n task_description = f'- Extract information of field \"{fields_str}\" from the \"{self.list_name}\" list. Please provide this information in the chat.'\n\n return task_description\n\n def _wait_for_ready(self, page: Page) -> bool:\n \"\"\"\n Waits for the main iframe to be fully loaded; over-rides the parent method as the cheat\n can be called on a filtered list on which there is no gsft_main.\n\n Returns True if the gsft_main is present, False otherwise.\n \"\"\"\n gsft_main_present = False\n logging.debug(f\"Waiting up to 3 seconds for gsft_main to be ready\")\n try:\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\",\n timeout=3000,\n )\n logging.debug(\"Detected gsft_main ready\")\n gsft_main_present = True\n except TimeoutError:\n logging.debug(\n \"Timed out waiting for gsft_main to be ready; searching for GlideList API directly\"\n )\n pass\n\n logging.debug(\"Waiting for Glide list API to be available\")\n if gsft_main_present:\n page.wait_for_function(\"window.gsft_main.GlideList2 !== undefined\")\n else:\n page.wait_for_function(\"window.GlideList2 !== undefined\")\n\n logging.debug(\"Detected Glide list API ready\")\n\n return gsft_main_present\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n right_url = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n if not right_url:\n return\n gft_main_present = self._wait_for_ready(page)\n if gft_main_present:\n main_element = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n else:\n main_element = page\n\n main_element.wait_for_selector(\n f\"#hdr_{self.table_name}\"\n ) # Selector for the name of the columns\n # system name mapped to their order in the table\n all_column_elements = main_element.query_selector_all(f\"#hdr_{self.table_name} th\")\n required_fields_order = {}\n for i, element in enumerate(all_column_elements):\n if element.get_attribute(\"name\") in self.fields:\n required_fields_order[element.get_attribute(\"name\")] = i\n\n # Lines of the table\n table_lines = main_element.query_selector_all(\n f\".list2_body [record_class={self.table_name}]\"\n )\n\n # will hold the values to extract\n table_values = {}\n\n # Extract the values of the required fields\n for line_element in table_lines:\n line_fields = line_element.query_selector_all(\"td\")\n line_values = {}\n for field, order in required_fields_order.items():\n printed_field_name = self.fields[field]\n line_values[printed_field_name] = line_fields[order].inner_text()\n printed_unique_value_name = self.fields[self.unique_field_name]\n unique_field_value = line_values[printed_unique_value_name]\n line_values.pop(printed_unique_value_name)\n table_values[unique_field_value] = line_values\n\n # Add the \"extracted\" answer to the chat messages\n if len(self.fields) > 2:\n chat_messages.append({\"role\": \"assistant\", \"message\": json.dumps(table_values)})\n # In this case, we expect only one field to be extracted\n else:\n expected_field = list(self.fields.keys() - {self.unique_field_name})[0]\n pretty_field_name = self.fields[expected_field]\n # Here we assume that unique_field_value is unique in the table_values\n chat_messages.append(\n {\n \"role\": \"assistant\",\n \"message\": str(table_values[unique_field_value][pretty_field_name]),\n }\n )\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n\n Note: current implementation is limited to AND and OR filters (single type per filter) with equality operators\n\n \"\"\"\n if (\n len(chat_messages) == 0\n or chat_messages[-1][\"role\"] != \"assistant\"\n or not chat_messages[-1][\"message\"]\n ):\n return 0, False, \"\", {\"message\": \"No extracted values found.\"}\n\n # When 2 or more fields (unique field is always present so at least 2 fields are present), we expect a dict\n # Otherwise, we only look for the presence of the expected value in the message sent by the agent\n if len(self.fields) > 2:\n answer = json.loads(chat_messages[-1][\"message\"])\n for expected_line in self.expected_values:\n # Check if the line is in the visible lines\n if expected_line[self.unique_field_name] not in answer:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Value {expected_line[self.unique_field_name]} for unique field {self.unique_field_name} not found in the list.\"\n },\n )\n # Check if the values are correct\n unique_value = expected_line[self.unique_field_name]\n # This checks all fields inside the dict for the unique value\n for field, value in expected_line.items():\n # The unique field's presence is implicitly validated by the above check\n if field == self.unique_field_name:\n continue\n printed_field_name = self.fields[field]\n if answer[unique_value][printed_field_name] != value:\n return 0, False, \"\", {\"message\": \"Incorrect value.\"}\n # In this case, we expect only one field to be extracted\n else:\n # get the field that is not the unique field\n field = list(self.fields.keys() - {self.unique_field_name})[0]\n expected_value = str(self.expected_values[0][field])\n if expected_value not in chat_messages[-1][\"message\"]:\n return 0, False, \"\", {\"message\": \"Incorrect value.\"}\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct information extracted.\"},\n )\n\n\nclass FilterAssetListTask(FilterListTask):\n config_path = FILTER_ASSET_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_asset\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_ASSET_LIST_COLUMNS_PATH,\n **kwargs,\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.FilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.FilterAssetListTask#L1185-L1202","kind":"class","name":"FilterAssetListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1185,"end_line":1202,"context_start_line":1165,"context_end_line":1222,"code":" continue\n printed_field_name = self.fields[field]\n if answer[unique_value][printed_field_name] != value:\n return 0, False, \"\", {\"message\": \"Incorrect value.\"}\n # In this case, we expect only one field to be extracted\n else:\n # get the field that is not the unique field\n field = list(self.fields.keys() - {self.unique_field_name})[0]\n expected_value = str(self.expected_values[0][field])\n if expected_value not in chat_messages[-1][\"message\"]:\n return 0, False, \"\", {\"message\": \"Incorrect value.\"}\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct information extracted.\"},\n )\n\n\nclass FilterAssetListTask(FilterListTask):\n config_path = FILTER_ASSET_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_asset\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_ASSET_LIST_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterChangeRequestListTask(FilterListTask):\n config_path = FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"change_request\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n **kwargs,\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.FilterChangeRequestListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.FilterChangeRequestListTask#L1205-L1222","kind":"class","name":"FilterChangeRequestListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1205,"end_line":1222,"context_start_line":1185,"context_end_line":1242,"code":"class FilterAssetListTask(FilterListTask):\n config_path = FILTER_ASSET_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_asset\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_ASSET_LIST_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterChangeRequestListTask(FilterListTask):\n config_path = FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"change_request\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterHardwareListTask(FilterListTask):\n config_path = FILTER_HARDWARE_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_hardware\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_HARDWARE_COLUMNS_PATH,\n **kwargs,\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.FilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.FilterHardwareListTask#L1225-L1242","kind":"class","name":"FilterHardwareListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1225,"end_line":1242,"context_start_line":1205,"context_end_line":1262,"code":"class FilterChangeRequestListTask(FilterListTask):\n config_path = FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"change_request\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterHardwareListTask(FilterListTask):\n config_path = FILTER_HARDWARE_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_hardware\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_HARDWARE_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterIncidentListTask(FilterListTask):\n config_path = FILTER_INCIDENT_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"incident\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_INCIDENT_COLUMNS_PATH,\n **kwargs,\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.FilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.FilterIncidentListTask#L1245-L1262","kind":"class","name":"FilterIncidentListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1245,"end_line":1262,"context_start_line":1225,"context_end_line":1282,"code":"class FilterHardwareListTask(FilterListTask):\n config_path = FILTER_HARDWARE_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_hardware\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_HARDWARE_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterIncidentListTask(FilterListTask):\n config_path = FILTER_INCIDENT_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"incident\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_INCIDENT_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterProblemListForWorkLoadBalancingTask(FilterListTask, CompositionalBuildingBlockTask):\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=\"/now/nav/ui/classic/params/target/problem_list.do\",\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_PROBLEM_COLUMNS_PATH,\n **kwargs,\n )\n\n def get_pretty_printed_description(self, goal=False) -> str:","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.FilterProblemListForWorkLoadBalancingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.FilterProblemListForWorkLoadBalancingTask#L1265-L1285","kind":"class","name":"FilterProblemListForWorkLoadBalancingTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1265,"end_line":1285,"context_start_line":1245,"context_end_line":1305,"code":"class FilterIncidentListTask(FilterListTask):\n config_path = FILTER_INCIDENT_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"incident\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_INCIDENT_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterProblemListForWorkLoadBalancingTask(FilterListTask, CompositionalBuildingBlockTask):\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=\"/now/nav/ui/classic/params/target/problem_list.do\",\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_PROBLEM_COLUMNS_PATH,\n **kwargs,\n )\n\n def get_pretty_printed_description(self, goal=False) -> str:\n \"\"\"Override the parent method to provide a more detailed description of the task\"\"\"\n\n return self.goal\n\n\nclass FilterServiceCatalogItemListTask(FilterListTask):\n config_path = FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sc_cat_item\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n **kwargs,\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.FilterServiceCatalogItemListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.FilterServiceCatalogItemListTask#L1288-L1305","kind":"class","name":"FilterServiceCatalogItemListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1288,"end_line":1305,"context_start_line":1268,"context_end_line":1325,"code":" seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=\"/now/nav/ui/classic/params/target/problem_list.do\",\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_PROBLEM_COLUMNS_PATH,\n **kwargs,\n )\n\n def get_pretty_printed_description(self, goal=False) -> str:\n \"\"\"Override the parent method to provide a more detailed description of the task\"\"\"\n\n return self.goal\n\n\nclass FilterServiceCatalogItemListTask(FilterListTask):\n config_path = FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sc_cat_item\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterUserListTask(FilterListTask):\n config_path = FILTER_USER_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sys_user\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_USER_COLUMNS_PATH,\n **kwargs,\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.FilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.FilterUserListTask#L1308-L1325","kind":"class","name":"FilterUserListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1308,"end_line":1325,"context_start_line":1288,"context_end_line":1345,"code":"class FilterServiceCatalogItemListTask(FilterListTask):\n config_path = FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sc_cat_item\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass FilterUserListTask(FilterListTask):\n config_path = FILTER_USER_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sys_user\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_USER_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortAssetListTask(SortListTask):\n config_path = SORT_ASSET_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_asset\"][\"url\"],\n forbidden_fields=LISTS[\"alm_asset\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_ASSET_LIST_COLUMNS_PATH,\n **kwargs,","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.SortAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.SortAssetListTask#L1328-L1346","kind":"class","name":"SortAssetListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1328,"end_line":1346,"context_start_line":1308,"context_end_line":1366,"code":"class FilterUserListTask(FilterListTask):\n config_path = FILTER_USER_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sys_user\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_USER_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortAssetListTask(SortListTask):\n config_path = SORT_ASSET_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_asset\"][\"url\"],\n forbidden_fields=LISTS[\"alm_asset\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_ASSET_LIST_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortChangeRequestListTask(SortListTask):\n config_path = SORT_CHANGE_REQUEST_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"change_request\"][\"url\"],\n forbidden_fields=LISTS[\"change_request\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n **kwargs,","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.SortChangeRequestListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.SortChangeRequestListTask#L1349-L1367","kind":"class","name":"SortChangeRequestListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1349,"end_line":1367,"context_start_line":1329,"context_end_line":1387,"code":" config_path = SORT_ASSET_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_asset\"][\"url\"],\n forbidden_fields=LISTS[\"alm_asset\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_ASSET_LIST_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortChangeRequestListTask(SortListTask):\n config_path = SORT_CHANGE_REQUEST_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"change_request\"][\"url\"],\n forbidden_fields=LISTS[\"change_request\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortHardwareListTask(SortListTask):\n config_path = SORT_HARDWARE_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_hardware\"][\"url\"],\n forbidden_fields=LISTS[\"alm_hardware\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_HARDWARE_COLUMNS_PATH,\n **kwargs,","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.SortHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.SortHardwareListTask#L1370-L1388","kind":"class","name":"SortHardwareListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1370,"end_line":1388,"context_start_line":1350,"context_end_line":1408,"code":" config_path = SORT_CHANGE_REQUEST_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"change_request\"][\"url\"],\n forbidden_fields=LISTS[\"change_request\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortHardwareListTask(SortListTask):\n config_path = SORT_HARDWARE_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_hardware\"][\"url\"],\n forbidden_fields=LISTS[\"alm_hardware\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_HARDWARE_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortIncidentListTask(SortListTask):\n config_path = SORT_INCIDENT_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"incident\"][\"url\"],\n forbidden_fields=LISTS[\"incident\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_INCIDENT_COLUMNS_PATH,\n **kwargs,","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.SortIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.SortIncidentListTask#L1391-L1409","kind":"class","name":"SortIncidentListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1391,"end_line":1409,"context_start_line":1371,"context_end_line":1429,"code":" config_path = SORT_HARDWARE_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_hardware\"][\"url\"],\n forbidden_fields=LISTS[\"alm_hardware\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_HARDWARE_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortIncidentListTask(SortListTask):\n config_path = SORT_INCIDENT_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"incident\"][\"url\"],\n forbidden_fields=LISTS[\"incident\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_INCIDENT_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortServiceCatalogItemListTask(SortListTask):\n config_path = SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sc_cat_item\"][\"url\"],\n forbidden_fields=LISTS[\"sc_cat_item\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n **kwargs,","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.SortServiceCatalogItemListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.SortServiceCatalogItemListTask#L1412-L1430","kind":"class","name":"SortServiceCatalogItemListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1412,"end_line":1430,"context_start_line":1392,"context_end_line":1450,"code":" config_path = SORT_INCIDENT_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"incident\"][\"url\"],\n forbidden_fields=LISTS[\"incident\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_INCIDENT_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortServiceCatalogItemListTask(SortListTask):\n config_path = SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sc_cat_item\"][\"url\"],\n forbidden_fields=LISTS[\"sc_cat_item\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortUserListTask(SortListTask):\n config_path = SORT_USER_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sys_user\"][\"url\"],\n forbidden_fields=LISTS[\"sys_user\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_USER_COLUMNS_PATH,\n **kwargs,","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.SortUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.SortUserListTask#L1433-L1451","kind":"class","name":"SortUserListTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1433,"end_line":1451,"context_start_line":1413,"context_end_line":1471,"code":" config_path = SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sc_cat_item\"][\"url\"],\n forbidden_fields=LISTS[\"sc_cat_item\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass SortUserListTask(SortListTask):\n config_path = SORT_USER_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sys_user\"][\"url\"],\n forbidden_fields=LISTS[\"sys_user\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_USER_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass ExtractUserListInfoTask(ExtractListInfoTask, CompositionalBuildingBlockTask):\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n config_path=EXTRACT_USER_LIST_INFO_CONFIG,\n list_name=\"User\",\n unique_field_name=\"user_name\",\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n config_path=config_path,\n list_name=list_name,\n unique_field_name=unique_field_name,","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.ExtractUserListInfoTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.list.ExtractUserListInfoTask#L1454-L1474","kind":"class","name":"ExtractUserListInfoTask","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1454,"end_line":1474,"context_start_line":1434,"context_end_line":1494,"code":" config_path = SORT_USER_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sys_user\"][\"url\"],\n forbidden_fields=LISTS[\"sys_user\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_USER_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass ExtractUserListInfoTask(ExtractListInfoTask, CompositionalBuildingBlockTask):\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n config_path=EXTRACT_USER_LIST_INFO_CONFIG,\n list_name=\"User\",\n unique_field_name=\"user_name\",\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n config_path=config_path,\n list_name=list_name,\n unique_field_name=unique_field_name,\n table_name=\"sys_user\",\n **kwargs,\n )\n\n\n# Register all tasks\n__TASKS__ = (\n [\n value\n for name, value in locals().items()\n if re.compile(r\"^Filter\\w+ListTask$\").match(name)\n and not issubclass(value, CompositionalBuildingBlockTask)\n ]\n + [\n value\n for name, value in locals().items()\n if re.compile(r\"^Sort\\w+ListTask$\").match(name)\n and not issubclass(value, CompositionalBuildingBlockTask)\n ]\n + [\n value\n for name, value in locals().items()\n if re.compile(r\"^Extract\\w+ListInfoTask$\").match(name)","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.all_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.all_configs#L111-L113","kind":"function","name":"all_configs","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":111,"end_line":113,"context_start_line":91,"context_end_line":133,"code":" \"expected_values\": [\n {\n \"user_name\": \"lucius.bagnoli\",\n \"email\": \"lucius.bagnoli@example.com\",\n \"first_name\": \"Lucius\",\n \"last_name\": \"Bagnoli\",\n }\n ],\n }\n]\n\n\nclass ServiceNowListTask(AbstractServiceNowTask):\n OPERATOR_EQUALS = \"=\"\n OPERATOR_NOT_EQUALS = \"!=\"\n OPERATOR_STARTSWITH = \"STARTSWITH\"\n OPERATOR_ISEMPTY = \"ISEMPTY\"\n OPERATOR_EMPTYSTRING = \"EMPTYSTRING\"\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def _get_visible_list(self, page: Page):\n self._wait_for_ready(page)\n\n iframe = page.frame(\"gsft_main\")\n lst = iframe.locator(\"table.data_list_table\")\n lst.wait_for()\n\n # Validate the number of lists on the page\n if lst.count() > 1:\n warn(\n \"More than one list found on page. Using the first one.\",\n category=RuntimeWarning,\n )\n elif lst.count() == 0:\n raise RuntimeError(\"No list found on page.\")\n lst = lst.nth(0)","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.get_init_scripts","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.get_init_scripts#L115-L116","kind":"function","name":"get_init_scripts","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":115,"end_line":116,"context_start_line":95,"context_end_line":136,"code":" \"first_name\": \"Lucius\",\n \"last_name\": \"Bagnoli\",\n }\n ],\n }\n]\n\n\nclass ServiceNowListTask(AbstractServiceNowTask):\n OPERATOR_EQUALS = \"=\"\n OPERATOR_NOT_EQUALS = \"!=\"\n OPERATOR_STARTSWITH = \"STARTSWITH\"\n OPERATOR_ISEMPTY = \"ISEMPTY\"\n OPERATOR_EMPTYSTRING = \"EMPTYSTRING\"\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def _get_visible_list(self, page: Page):\n self._wait_for_ready(page)\n\n iframe = page.frame(\"gsft_main\")\n lst = iframe.locator(\"table.data_list_table\")\n lst.wait_for()\n\n # Validate the number of lists on the page\n if lst.count() > 1:\n warn(\n \"More than one list found on page. Using the first one.\",\n category=RuntimeWarning,\n )\n elif lst.count() == 0:\n raise RuntimeError(\"No list found on page.\")\n lst = lst.nth(0)\n\n # A javascript command that gets the list object\n javascript_selector = f\"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')\"","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list._get_visible_list","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list._get_visible_list#L118-L138","kind":"function","name":"_get_visible_list","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":118,"end_line":138,"context_start_line":98,"context_end_line":158,"code":" ],\n }\n]\n\n\nclass ServiceNowListTask(AbstractServiceNowTask):\n OPERATOR_EQUALS = \"=\"\n OPERATOR_NOT_EQUALS = \"!=\"\n OPERATOR_STARTSWITH = \"STARTSWITH\"\n OPERATOR_ISEMPTY = \"ISEMPTY\"\n OPERATOR_EMPTYSTRING = \"EMPTYSTRING\"\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def _get_visible_list(self, page: Page):\n self._wait_for_ready(page)\n\n iframe = page.frame(\"gsft_main\")\n lst = iframe.locator(\"table.data_list_table\")\n lst.wait_for()\n\n # Validate the number of lists on the page\n if lst.count() > 1:\n warn(\n \"More than one list found on page. Using the first one.\",\n category=RuntimeWarning,\n )\n elif lst.count() == 0:\n raise RuntimeError(\"No list found on page.\")\n lst = lst.nth(0)\n\n # A javascript command that gets the list object\n javascript_selector = f\"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')\"\n\n return iframe, lst, javascript_selector\n\n @retry(\n stop=stop_after_delay(SNOW_BROWSER_TIMEOUT / 1000),\n retry=retry_if_exception_type(playwright.sync_api.Error),\n reraise=True,\n before_sleep=lambda _: logging.debug(\"Retrying due to a Playwright Error...\"),\n )\n def _extract_list_info(self, page: Page, with_data=False):\n \"\"\"\n Extract useful information about the list visible on the page\n\n \"\"\"\n self._wait_for_ready(page)\n\n # Grab the list component\n _, _, js_selector = self._get_visible_list(page)\n\n # Load some basic info\n list_info = {\n \"title\": page.evaluate(f\"{js_selector}.getTitle()\").lower(),","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list._extract_list_info","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list._extract_list_info#L146-L186","kind":"function","name":"_extract_list_info","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":146,"end_line":186,"context_start_line":126,"context_end_line":206,"code":" if lst.count() > 1:\n warn(\n \"More than one list found on page. Using the first one.\",\n category=RuntimeWarning,\n )\n elif lst.count() == 0:\n raise RuntimeError(\"No list found on page.\")\n lst = lst.nth(0)\n\n # A javascript command that gets the list object\n javascript_selector = f\"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')\"\n\n return iframe, lst, javascript_selector\n\n @retry(\n stop=stop_after_delay(SNOW_BROWSER_TIMEOUT / 1000),\n retry=retry_if_exception_type(playwright.sync_api.Error),\n reraise=True,\n before_sleep=lambda _: logging.debug(\"Retrying due to a Playwright Error...\"),\n )\n def _extract_list_info(self, page: Page, with_data=False):\n \"\"\"\n Extract useful information about the list visible on the page\n\n \"\"\"\n self._wait_for_ready(page)\n\n # Grab the list component\n _, _, js_selector = self._get_visible_list(page)\n\n # Load some basic info\n list_info = {\n \"title\": page.evaluate(f\"{js_selector}.getTitle()\").lower(),\n \"glide_table\": page.evaluate(f\"{js_selector}.getTableName()\").lower(),\n \"query\": page.evaluate(f\"{js_selector}.getQuery()\"),\n \"fields\": page.evaluate(f\"{js_selector}.fields\"),\n \"js_selector\": js_selector,\n }\n\n # Get column info\n list_info[\"columns\"] = table_column_info(\n instance=self.instance,\n table=list_info[\"glide_table\"],\n )\n\n # Get the list data\n if with_data:\n data = table_api_call(\n instance=self.instance,\n table=list_info[\"glide_table\"],\n params={\n \"sysparm_query\": list_info[\"query\"],\n \"sysparm_fields\": list_info[\"fields\"],\n \"sysparm_display_value\": \"all\",\n },\n )[\"result\"]\n # Extract all display values (not raw values)\n data = [{k: v[\"display_value\"] for k, v in x.items()} for x in data]\n list_info[\"data\"] = data\n\n return list_info\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Waits for the main iframe to be fully loaded\n\n \"\"\"\n logging.debug(f\"Waiting for gsft_main to be fully loaded\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n logging.debug(\"Detected gsft_main ready\")\n\n logging.debug(\"Waiting for Glide list API to be available\")\n page.wait_for_function(\"window.gsft_main.GlideList2 !== undefined\")\n logging.debug(\"Detected Glide list API ready\")\n\n\nclass SortListTask(ServiceNowListTask):\n \"\"\"\n Sort a list according to a column. Works with any list.","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list._wait_for_ready","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list._wait_for_ready#L1040-L1070","kind":"function","name":"_wait_for_ready","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1040,"end_line":1070,"context_start_line":1020,"context_end_line":1090,"code":" \"\"\"\n print_field_names = list(self.fields.values())\n print_field_names.remove(\n self.fields[self.unique_field_name]\n ) # the unique fields are the keys in the dict\n if len(print_field_names) > 1:\n fields_str = (\n '\"' + '\", \"'.join(print_field_names[:-1]) + f'\" and \"{print_field_names[-1]}\"'\n )\n printed_unique_field_name = self.fields[self.unique_field_name]\n task_description = (\n f\"- Extract information of field(s) {fields_str} \"\n + f'from the \"{self.list_name}\" list. Return the result as a json where keys are the values of the \"{printed_unique_field_name}\" field and values are mappings between the fields and the extracted information. Please provide this information in the chat.'\n )\n else:\n fields_str = print_field_names[0]\n task_description = f'- Extract information of field \"{fields_str}\" from the \"{self.list_name}\" list. Please provide this information in the chat.'\n\n return task_description\n\n def _wait_for_ready(self, page: Page) -> bool:\n \"\"\"\n Waits for the main iframe to be fully loaded; over-rides the parent method as the cheat\n can be called on a filtered list on which there is no gsft_main.\n\n Returns True if the gsft_main is present, False otherwise.\n \"\"\"\n gsft_main_present = False\n logging.debug(f\"Waiting up to 3 seconds for gsft_main to be ready\")\n try:\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\",\n timeout=3000,\n )\n logging.debug(\"Detected gsft_main ready\")\n gsft_main_present = True\n except TimeoutError:\n logging.debug(\n \"Timed out waiting for gsft_main to be ready; searching for GlideList API directly\"\n )\n pass\n\n logging.debug(\"Waiting for Glide list API to be available\")\n if gsft_main_present:\n page.wait_for_function(\"window.gsft_main.GlideList2 !== undefined\")\n else:\n page.wait_for_function(\"window.GlideList2 !== undefined\")\n\n logging.debug(\"Detected Glide list API ready\")\n\n return gsft_main_present\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n right_url = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n if not right_url:\n return\n gft_main_present = self._wait_for_ready(page)\n if gft_main_present:\n main_element = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n else:\n main_element = page\n\n main_element.wait_for_selector(\n f\"#hdr_{self.table_name}\"\n ) # Selector for the name of the columns\n # system name mapped to their order in the table\n all_column_elements = main_element.query_selector_all(f\"#hdr_{self.table_name} th\")\n required_fields_order = {}\n for i, element in enumerate(all_column_elements):\n if element.get_attribute(\"name\") in self.fields:","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.__init__#L1455-L1474","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1455,"end_line":1474,"context_start_line":1435,"context_end_line":1494,"code":"\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sys_user\"][\"url\"],\n forbidden_fields=LISTS[\"sys_user\"][\"forbidden_fields\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_USER_COLUMNS_PATH,\n **kwargs,\n )\n\n\nclass ExtractUserListInfoTask(ExtractListInfoTask, CompositionalBuildingBlockTask):\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n config_path=EXTRACT_USER_LIST_INFO_CONFIG,\n list_name=\"User\",\n unique_field_name=\"user_name\",\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n config_path=config_path,\n list_name=list_name,\n unique_field_name=unique_field_name,\n table_name=\"sys_user\",\n **kwargs,\n )\n\n\n# Register all tasks\n__TASKS__ = (\n [\n value\n for name, value in locals().items()\n if re.compile(r\"^Filter\\w+ListTask$\").match(name)\n and not issubclass(value, CompositionalBuildingBlockTask)\n ]\n + [\n value\n for name, value in locals().items()\n if re.compile(r\"^Sort\\w+ListTask$\").match(name)\n and not issubclass(value, CompositionalBuildingBlockTask)\n ]\n + [\n value\n for name, value in locals().items()\n if re.compile(r\"^Extract\\w+ListInfoTask$\").match(name)","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.setup_goal#L980-L1010","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":980,"end_line":1010,"context_start_line":960,"context_end_line":1030,"code":" seed: int = None,\n instance=None,\n fixed_config: dict = None,\n configs: str = \"\",\n list_name: str = \"\",\n list_url: str = \"\",\n unique_field_name: str = \"\",\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed, instance=instance, start_rel_url=list_url\n ) # For these tasks, the start URL is defined in the setup method, as the URL depends on the configuration\n self.fixed_config = fixed_config\n self.config = None\n self.all_configs = configs\n self.list_name = list_name\n self.table_name = \"\"\n self.unique_field_name = unique_field_name\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get the task configuration\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n self.fields = config[\"fields\"] # mapping between fields and their display names\n self.printed_field_names = {\n v: k for k, v in self.fields.items()\n } # mapping between fields and their system names\n self.expected_values = config[\n \"expected_values\"\n ] # mapping between fields and their expected values\n # This is setup here because the start_url depends on the config\n assert (\n self.unique_field_name in self.fields.keys()\n ), f\"Unique field name {self.unique_field_name} not in fields.\"\n assert all(\n [self.unique_field_name in expected_value for expected_value in self.expected_values]\n ), f\"Unique field name {self.unique_field_name} not in expected values.\"\n\n if not self.start_url or self.start_url == self.instance.snow_url:\n self.start_rel_url = config[\"start_rel_url\"]\n self.start_url = self.instance.snow_url + self.start_rel_url\n # table_name can be passed in the constructor or extracted from the start_rel_url, located in the config\n if self.table_name is None:\n self.table_name = self.start_rel_url.split(\"/\")[-1].split(\"_list.do\")[0]\n\n goal = self.get_pretty_printed_description()\n info = {}\n\n return goal, info\n\n def start(self, page: Page) -> None:\n super().start(page)\n # TODO: We should add a check to make sure the required columns are present in the list\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks and used as goal in L1 tasks.\n called by subclasses\n \"\"\"\n print_field_names = list(self.fields.values())\n print_field_names.remove(\n self.fields[self.unique_field_name]\n ) # the unique fields are the keys in the dict\n if len(print_field_names) > 1:\n fields_str = (\n '\"' + '\", \"'.join(print_field_names[:-1]) + f'\" and \"{print_field_names[-1]}\"'\n )\n printed_unique_field_name = self.fields[self.unique_field_name]\n task_description = (","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.start","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.start#L1012-L1013","kind":"function","name":"start","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1012,"end_line":1013,"context_start_line":992,"context_end_line":1033,"code":" # This is setup here because the start_url depends on the config\n assert (\n self.unique_field_name in self.fields.keys()\n ), f\"Unique field name {self.unique_field_name} not in fields.\"\n assert all(\n [self.unique_field_name in expected_value for expected_value in self.expected_values]\n ), f\"Unique field name {self.unique_field_name} not in expected values.\"\n\n if not self.start_url or self.start_url == self.instance.snow_url:\n self.start_rel_url = config[\"start_rel_url\"]\n self.start_url = self.instance.snow_url + self.start_rel_url\n # table_name can be passed in the constructor or extracted from the start_rel_url, located in the config\n if self.table_name is None:\n self.table_name = self.start_rel_url.split(\"/\")[-1].split(\"_list.do\")[0]\n\n goal = self.get_pretty_printed_description()\n info = {}\n\n return goal, info\n\n def start(self, page: Page) -> None:\n super().start(page)\n # TODO: We should add a check to make sure the required columns are present in the list\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks and used as goal in L1 tasks.\n called by subclasses\n \"\"\"\n print_field_names = list(self.fields.values())\n print_field_names.remove(\n self.fields[self.unique_field_name]\n ) # the unique fields are the keys in the dict\n if len(print_field_names) > 1:\n fields_str = (\n '\"' + '\", \"'.join(print_field_names[:-1]) + f'\" and \"{print_field_names[-1]}\"'\n )\n printed_unique_field_name = self.fields[self.unique_field_name]\n task_description = (\n f\"- Extract information of field(s) {fields_str} \"\n + f'from the \"{self.list_name}\" list. Return the result as a json where keys are the values of the \"{printed_unique_field_name}\" field and values are mappings between the fields and the extracted information. Please provide this information in the chat.'\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.get_pretty_printed_description#L1282-L1285","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1282,"end_line":1285,"context_start_line":1262,"context_end_line":1305,"code":" )\n\n\nclass FilterProblemListForWorkLoadBalancingTask(FilterListTask, CompositionalBuildingBlockTask):\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=\"/now/nav/ui/classic/params/target/problem_list.do\",\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_PROBLEM_COLUMNS_PATH,\n **kwargs,\n )\n\n def get_pretty_printed_description(self, goal=False) -> str:\n \"\"\"Override the parent method to provide a more detailed description of the task\"\"\"\n\n return self.goal\n\n\nclass FilterServiceCatalogItemListTask(FilterListTask):\n config_path = FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"sc_cat_item\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_SERVICE_CATALOG_COLUMNS_PATH,\n **kwargs,\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list._generate_all_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list._generate_all_configs#L282-L318","kind":"function","name":"_generate_all_configs","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":282,"end_line":318,"context_start_line":262,"context_end_line":338,"code":" # Get the task goal\n goal = self.config[\"goal\"]\n info = {}\n\n return goal, info\n\n def start(self, page: Page) -> None:\n super().start(page)\n self._wait_for_ready(page)\n\n # Ensure that the fields that need to be sorted are visible (task feasibility check)\n self.list_info = self._extract_list_info(page)\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n return self.config[\"goal\"] + \"\\n\"\n\n def _generate_all_configs(self, seed: int, page: Page, n_fields_to_sort: int):\n self.setup(seed=seed, page=page)\n self._wait_for_ready(page)\n list_info = self._extract_list_info(page)\n\n # Get available fields\n available_fields = list(list_info[\"columns\"].keys())\n # ... remove forbidden fields\n available_fields = [f for f in available_fields if f not in self.forbidden_fields]\n\n field_txt = {k: x[\"label\"] for k, x in list_info[\"columns\"].items()}\n dir_txt = {\"asc\": \"ascending\", \"desc\": \"descending\"}\n\n # compute all field combinations\n all_sort_fields = list(itertools.combinations(available_fields, n_fields_to_sort))\n # compute all direction combinations\n all_sort_dirs = list(itertools.product(*[[\"asc\", \"desc\"] for _ in range(n_fields_to_sort)]))\n\n # product of field combinations x direction combinations\n all_configs = list(itertools.product(all_sort_fields, all_sort_dirs))\n\n all_configs = [\n {\n \"sort_fields\": sort_fields,\n \"sort_dirs\": sort_dirs,\n \"goal\": f'Sort the \"{list_info[\"title\"]}\" list by the following fields:\\n'\n + \"\\n\".join(\n [\n f\" - {field_txt[field]} ({dir_txt[dir]})\"\n for field, dir in zip(sort_fields, sort_dirs)\n ]\n ),\n }\n for sort_fields, sort_dirs in all_configs\n ]\n\n return all_configs\n\n def _generate_random_config(self, page: Page):\n self.setup(page=page)\n self._wait_for_ready(page)\n self.list_info = self._extract_list_info(page)\n # Get available fields\n available_fields = list(self.list_info[\"columns\"].keys())\n # ... remove forbidden fields\n available_fields = [f for f in available_fields if f not in self.forbidden_fields]\n\n sort_len = self.random.randint(\n self.min_sort_len, min(self.max_sort_len, len(available_fields)) + 1\n )\n\n # Pick random fields and directions to sort\n # Retry until the task is not initially solved\n try_again = True\n while try_again:\n try_again = False\n","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list._generate_random_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list._generate_random_config#L588-L668","kind":"function","name":"_generate_random_config","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":588,"end_line":668,"context_start_line":568,"context_end_line":688,"code":"\n args:\n goal: bool\n If True, return as the goal of the task (without the starting dash)\n \"\"\"\n task_info = \"\" if goal else \"- \"\n task_info += (\n f\"Create a filter for the list to extract all entries where:\"\n + f\" {'and' if self.filter_kind == 'AND' else 'or'} \".join(\n [\n f'\\n - \"{self.list_info[\"columns\"][col][\"label\"]}\" {filter_operator} \"{val}\"'\n for col, filter_operator, val in zip(\n self.filter_columns, self.filter_operators, self.filter_values\n )\n ]\n )\n )\n\n return task_info\n\n def _generate_random_config(self, page: Page):\n self.setup(page=page)\n self._wait_for_ready(page)\n\n # Extract the list from the page\n self.list_info = self._extract_list_info(page)\n\n # Choose the columns to filter on\n allowed_types = [\"string\", \"choice\", \"reference\", \"translated_text\", \"boolean\"]\n valid_filter_columns = [\n k for k, v in self.list_info[\"columns\"].items() if v[\"type\"] in allowed_types\n ]\n assert len(valid_filter_columns) > 0, \"Not enough columns to filter on.\"\n self.filter_len = self.random.randint(\n self.min_filter_len, min(self.max_filter_len, len(valid_filter_columns)) + 1\n )\n self.filter_columns = list(\n self.random.choice(valid_filter_columns, self.filter_len, replace=False)\n )\n\n # Choose the filter kind\n if self.filter_len == 1:\n # If there is only one column to filter on, then the kind is always AND\n self.filter_kind = \"AND\"\n else:\n self.filter_kind = self.random.choice([\"AND\", \"OR\"])\n\n # Choose the values to filter on\n # We do this by loading a single record at random and using its values\n # This is significantly faster than loading all records and then filtering\n offset = self.random.randint(\n 0, page.evaluate(f'{self.list_info[\"js_selector\"]}.grandTotalRows')\n )\n data = table_api_call(\n instance=self.instance,\n table=self.list_info[\"glide_table\"],\n params={\n \"sysparm_query\": self.list_info[\"query\"],\n \"sysparm_fields\": \",\".join(self.filter_columns),\n \"sysparm_display_value\": \"all\",\n \"sysparm_limit\": \"1\",\n \"sysparm_offset\": f\"{offset}\",\n },\n )[\"result\"][0]\n # XXX: The use of \"\" as default display value is a hack, but it seems to work for now.\n self.filter_values = [\n data.get(c, {\"display_value\": \"\"})[\"display_value\"] for c in self.filter_columns\n ]\n\n # Make sure we expand empty strings to their expected display value (the API fails to do this)\n for i, (col, val) in enumerate(zip(self.filter_columns, self.filter_values)):\n if self.list_info[\"columns\"][col][\"type\"] == \"choice\" and val in [None, \"\"]:\n self.filter_values[i] = self.list_info[\"columns\"][col][\"choices\"].get(\n \"\", \"-- None --\"\n )\n # XXX: The use of -- None -- as default is a hack, but it seems to work for now.\n\n # Make sure there are no trailing spaces in the values\n self.filter_values = [v.strip() for v in self.filter_values]\n\n # Make sure we use only values that are available in the UI\n # (some database entries have old values that are no longer available)\n for i, (c, v) in enumerate(zip(self.filter_columns, self.filter_values)):\n if \"choices\" in self.list_info[\"columns\"][c]:\n if v not in self.list_info[\"columns\"][c][\"choices\"]:\n # replace with a random choice\n self.filter_values[i] = self.random.choice(\n list(self.list_info[\"columns\"][c][\"choices\"].values())\n )\n goal = (\n f\"Create a filter for the list to extract all entries where \"\n + f\" {'and' if self.filter_kind == 'AND' else 'or'} \".join(\n [\n f'\"{self.list_info[\"columns\"][col][\"label\"]}\" is \"{val}\"'\n for col, val in zip(self.filter_columns, self.filter_values)\n ]\n )\n + \".\"\n )\n\n return goal, {}\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page)\n\n iframe, _, _ = self._get_visible_list(page)\n\n iframe.locator(\".list_filter_toggle\").click()\n\n # Wait for the filter to be visible\n iframe.wait_for_function(\n \"typeof document.querySelectorAll('.list_filter')[0] !== 'undefined' && document.querySelectorAll('.list_filter')[0].offsetParent !== null\"\n )\n\n # Clear any existing filters\n # Use a while loop and click the first button until there are no more buttons\n while iframe.locator(\".filerTableAction.deleteButton:visible\").count() > 0:\n logging.debug(\"Clearing existing filter condition\")\n iframe.locator(\".filerTableAction.deleteButton:visible\").nth(0).click()\n","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.cheat#L1072-L1126","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1072,"end_line":1126,"context_start_line":1052,"context_end_line":1146,"code":" timeout=3000,\n )\n logging.debug(\"Detected gsft_main ready\")\n gsft_main_present = True\n except TimeoutError:\n logging.debug(\n \"Timed out waiting for gsft_main to be ready; searching for GlideList API directly\"\n )\n pass\n\n logging.debug(\"Waiting for Glide list API to be available\")\n if gsft_main_present:\n page.wait_for_function(\"window.gsft_main.GlideList2 !== undefined\")\n else:\n page.wait_for_function(\"window.GlideList2 !== undefined\")\n\n logging.debug(\"Detected Glide list API ready\")\n\n return gsft_main_present\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n right_url = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n if not right_url:\n return\n gft_main_present = self._wait_for_ready(page)\n if gft_main_present:\n main_element = page.wait_for_selector(\"iframe#gsft_main\").content_frame()\n else:\n main_element = page\n\n main_element.wait_for_selector(\n f\"#hdr_{self.table_name}\"\n ) # Selector for the name of the columns\n # system name mapped to their order in the table\n all_column_elements = main_element.query_selector_all(f\"#hdr_{self.table_name} th\")\n required_fields_order = {}\n for i, element in enumerate(all_column_elements):\n if element.get_attribute(\"name\") in self.fields:\n required_fields_order[element.get_attribute(\"name\")] = i\n\n # Lines of the table\n table_lines = main_element.query_selector_all(\n f\".list2_body [record_class={self.table_name}]\"\n )\n\n # will hold the values to extract\n table_values = {}\n\n # Extract the values of the required fields\n for line_element in table_lines:\n line_fields = line_element.query_selector_all(\"td\")\n line_values = {}\n for field, order in required_fields_order.items():\n printed_field_name = self.fields[field]\n line_values[printed_field_name] = line_fields[order].inner_text()\n printed_unique_value_name = self.fields[self.unique_field_name]\n unique_field_value = line_values[printed_unique_value_name]\n line_values.pop(printed_unique_value_name)\n table_values[unique_field_value] = line_values\n\n # Add the \"extracted\" answer to the chat messages\n if len(self.fields) > 2:\n chat_messages.append({\"role\": \"assistant\", \"message\": json.dumps(table_values)})\n # In this case, we expect only one field to be extracted\n else:\n expected_field = list(self.fields.keys() - {self.unique_field_name})[0]\n pretty_field_name = self.fields[expected_field]\n # Here we assume that unique_field_value is unique in the table_values\n chat_messages.append(\n {\n \"role\": \"assistant\",\n \"message\": str(table_values[unique_field_value][pretty_field_name]),\n }\n )\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n\n Note: current implementation is limited to AND and OR filters (single type per filter) with equality operators\n\n \"\"\"\n if (\n len(chat_messages) == 0\n or chat_messages[-1][\"role\"] != \"assistant\"\n or not chat_messages[-1][\"message\"]\n ):\n return 0, False, \"\", {\"message\": \"No extracted values found.\"}\n\n # When 2 or more fields (unique field is always present so at least 2 fields are present), we expect a dict\n # Otherwise, we only look for the presence of the expected value in the message sent by the agent\n if len(self.fields) > 2:","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.validate#L1128-L1182","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1128,"end_line":1182,"context_start_line":1108,"context_end_line":1202,"code":" printed_unique_value_name = self.fields[self.unique_field_name]\n unique_field_value = line_values[printed_unique_value_name]\n line_values.pop(printed_unique_value_name)\n table_values[unique_field_value] = line_values\n\n # Add the \"extracted\" answer to the chat messages\n if len(self.fields) > 2:\n chat_messages.append({\"role\": \"assistant\", \"message\": json.dumps(table_values)})\n # In this case, we expect only one field to be extracted\n else:\n expected_field = list(self.fields.keys() - {self.unique_field_name})[0]\n pretty_field_name = self.fields[expected_field]\n # Here we assume that unique_field_value is unique in the table_values\n chat_messages.append(\n {\n \"role\": \"assistant\",\n \"message\": str(table_values[unique_field_value][pretty_field_name]),\n }\n )\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n\n Note: current implementation is limited to AND and OR filters (single type per filter) with equality operators\n\n \"\"\"\n if (\n len(chat_messages) == 0\n or chat_messages[-1][\"role\"] != \"assistant\"\n or not chat_messages[-1][\"message\"]\n ):\n return 0, False, \"\", {\"message\": \"No extracted values found.\"}\n\n # When 2 or more fields (unique field is always present so at least 2 fields are present), we expect a dict\n # Otherwise, we only look for the presence of the expected value in the message sent by the agent\n if len(self.fields) > 2:\n answer = json.loads(chat_messages[-1][\"message\"])\n for expected_line in self.expected_values:\n # Check if the line is in the visible lines\n if expected_line[self.unique_field_name] not in answer:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Value {expected_line[self.unique_field_name]} for unique field {self.unique_field_name} not found in the list.\"\n },\n )\n # Check if the values are correct\n unique_value = expected_line[self.unique_field_name]\n # This checks all fields inside the dict for the unique value\n for field, value in expected_line.items():\n # The unique field's presence is implicitly validated by the above check\n if field == self.unique_field_name:\n continue\n printed_field_name = self.fields[field]\n if answer[unique_value][printed_field_name] != value:\n return 0, False, \"\", {\"message\": \"Incorrect value.\"}\n # In this case, we expect only one field to be extracted\n else:\n # get the field that is not the unique field\n field = list(self.fields.keys() - {self.unique_field_name})[0]\n expected_value = str(self.expected_values[0][field])\n if expected_value not in chat_messages[-1][\"message\"]:\n return 0, False, \"\", {\"message\": \"Incorrect value.\"}\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct information extracted.\"},\n )\n\n\nclass FilterAssetListTask(FilterListTask):\n config_path = FILTER_ASSET_LIST_CONFIG_PATH\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n fixed_config: dict = None,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n list_url=LISTS[\"alm_asset\"][\"url\"],\n fixed_config=fixed_config,\n expected_fields_path=EXPECTED_ASSET_LIST_COLUMNS_PATH,\n **kwargs,\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.list.n_events_passed","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.list.n_events_passed#L420-L423","kind":"function","name":"n_events_passed","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":420,"end_line":423,"context_start_line":400,"context_end_line":443,"code":" # newly added row should be the last one\n row_index = filter.locator(\".filter_row\").count() - 1\n\n # Refresh since new rows are added at each iteration\n row = iframe.locator(\".filter_row\").nth(row_index)\n row_selectors = row.locator(\"select.filerTableSelect\")\n field_selector = row_selectors.nth(0)\n dir_selector = row_selectors.nth(1)\n\n # Choose field\n logging.debug(f\"Choosing sorting field {field_txt}\")\n field_selector.select_option(field_txt)\n\n # Choose sort order\n logging.debug(f\"Choosing sorting direction {dir_txt}\")\n dir_selector.select_option(dir_txt)\n\n # hack to wait for two events\n n_events_to_wait = 2\n\n def n_events_passed(event_info):\n nonlocal n_events_to_wait\n n_events_to_wait -= 1\n return n_events_to_wait == 0\n\n # click and wait for two navigations to happen (the iframe will navigate first, the page after)\n with page.expect_event(\"framenavigated\", predicate=n_events_passed):\n filter.get_by_label(\"Run filter\").click()\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n right_url = check_url_suffix_match(\n page, expected_url=self.start_url[: self.start_url.find(\"%3F\")], task=self\n )\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.mark_duplicate_problem","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.mark_duplicate_problem#L1-L171","kind":"module","name":"src.browsergym.workarena.tasks.mark_duplicate_problem","path":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","language":"python","start_line":1,"end_line":171,"context_start_line":1,"context_end_line":171,"code":"import json\n\nfrom playwright.sync_api import Page\nfrom typing import Tuple\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..api.utils import table_api_call\n\n\nclass SetProblemAsDuplicateTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Set a problem as duplicate, assuming we start on the problems list view.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the task list.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n respect_problem_ordering: bool\n Whether to respect the ordering of the problems in the list. If True, the task will pick the first problem in the\n list as the target problem. If False, the task validation will check if any problem is a duplicate of the other.\n add_comment: bool\n Whether or not to add comment to the duplicated task. If set to True, will add \"Duplicate\" as the problem description\n goal_version: str\n choice of \"base\", \"priority\", \"high_priority\". Adjusts the goal to the task setting for L2\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n start_rel_url=\"/now/nav/ui/classic/params/target/problem_list.do\",\n fixed_config: dict = None,\n respect_problem_ordering: bool = False,\n add_comment: bool = False,\n goal_version: str = \"base\",\n level: int = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n\n self.problem_sys_id = None\n self.respect_problem_ordering = respect_problem_ordering\n self.add_comment = add_comment\n self.goal_version = goal_version\n self.level = level\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.target_problem = self.fixed_config[\"target_problem\"]\n self.source_problem = self.fixed_config[\"source_problem\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L2 compositional tasks.\n called by subclasses\n \"\"\"\n\n if self.level == 3:\n task_info = \" \"\n elif self.goal_version == \"base\":\n task_info = \"Mark problems with duplicated problem statements as such. You can mark any as duplicate of the other.\"\n elif self.goal_version == \"priority\":\n task_info = \"Among the problems with duplicated problem statements, mark the lower priority one as duplicate of the higher priority one\"\n elif self.goal_version == \"high priority\":\n task_info = \"Among the problems with duplicated problem statements, mark any as duplicate of the other. Change the description of the problem marked as duplicate to 'duplicate'.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n target_problem_number = self.target_problem[\"number\"]\n\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.wait_for_selector(f\"[aria-label='Preview record: {target_problem_number}']\").click()\n page.wait_for_timeout(1500)\n # Click on the private task to open it\n frame.get_by_text(\"Open Record\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Open the duplicate mode\n frame.get_by_text(\"Mark Duplicate\").first.click()\n page.wait_for_timeout(1000)\n # Close the pop-up to edit the duplicate problem in the same window\n frame.get_by_text(\"Close\").last.click()\n frame.locator('[aria-labelledby=\"label.problem.duplicate_of\"]').fill(\n self.source_problem[\"number\"]\n )\n page.keyboard.press(\"Enter\")\n page.wait_for_timeout(1000)\n if self.add_comment:\n frame.locator('[id=\"problem.description\"]').fill(\"Duplicate\")\n\n frame.get_by_text(\"update\").first.click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n target_problem_record = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"number={self.target_problem['number']}\"},\n )[\"result\"]\n source_problem_record = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"number={self.source_problem['number']}\"},\n )[\"result\"]\n # If the ordering can be anything, we check both problems\n problem_found = source_problem_record and target_problem_record\n\n if not problem_found:\n return 0, False, \"\", {\"message\": \"Problem not found in DB.\"}\n\n # if the duplicate value is not set, the field will be an empty string; otherwise it will be a dict\n target_duplicate_value = target_problem_record[0][\"duplicate_of\"]\n if target_duplicate_value:\n target_duplicate_value = target_duplicate_value[\"value\"]\n\n target_is_duplicate = target_duplicate_value == source_problem_record[0][\"sys_id\"]\n if self.respect_problem_ordering:\n problem_marked_as_duplicate = target_is_duplicate\n else:\n source_duplicate_value = source_problem_record[0][\"duplicate_of\"]\n if source_duplicate_value:\n source_duplicate_value = source_duplicate_value[\"value\"]\n source_is_duplicate = source_duplicate_value == target_problem_record[0][\"sys_id\"]\n problem_marked_as_duplicate = target_is_duplicate or source_is_duplicate\n\n if self.add_comment:\n comment_added = (\n target_problem_record[0][\"description\"].lower() == \"duplicate\"\n and target_is_duplicate\n )\n if not self.respect_problem_ordering:\n comment_added = comment_added or (\n source_problem_record[0][\"description\"].lower() == \"duplicate\"\n and source_is_duplicate\n )\n if not comment_added:\n return 0, False, \"\", {\"message\": \"Comment not added.\"}\n\n if not problem_marked_as_duplicate:\n return 0, False, \"\", {\"message\": \"Problem not marked as duplicate.\"}\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Problem task was closed as duplicate.\"},\n )\n\n\n__TASKS__ = [SetProblemAsDuplicateTask]","source_hash":"db39cfa32b82e3b864204cf9f63591f8a076a3818a27dcf92bf0be9a906a05f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.mark_duplicate_problem.SetProblemAsDuplicateTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.mark_duplicate_problem.SetProblemAsDuplicateTask#L12-L168","kind":"class","name":"SetProblemAsDuplicateTask","path":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","language":"python","start_line":12,"end_line":168,"context_start_line":1,"context_end_line":171,"code":"import json\n\nfrom playwright.sync_api import Page\nfrom typing import Tuple\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..api.utils import table_api_call\n\n\nclass SetProblemAsDuplicateTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Set a problem as duplicate, assuming we start on the problems list view.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the task list.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n respect_problem_ordering: bool\n Whether to respect the ordering of the problems in the list. If True, the task will pick the first problem in the\n list as the target problem. If False, the task validation will check if any problem is a duplicate of the other.\n add_comment: bool\n Whether or not to add comment to the duplicated task. If set to True, will add \"Duplicate\" as the problem description\n goal_version: str\n choice of \"base\", \"priority\", \"high_priority\". Adjusts the goal to the task setting for L2\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n start_rel_url=\"/now/nav/ui/classic/params/target/problem_list.do\",\n fixed_config: dict = None,\n respect_problem_ordering: bool = False,\n add_comment: bool = False,\n goal_version: str = \"base\",\n level: int = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n\n self.problem_sys_id = None\n self.respect_problem_ordering = respect_problem_ordering\n self.add_comment = add_comment\n self.goal_version = goal_version\n self.level = level\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.target_problem = self.fixed_config[\"target_problem\"]\n self.source_problem = self.fixed_config[\"source_problem\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L2 compositional tasks.\n called by subclasses\n \"\"\"\n\n if self.level == 3:\n task_info = \" \"\n elif self.goal_version == \"base\":\n task_info = \"Mark problems with duplicated problem statements as such. You can mark any as duplicate of the other.\"\n elif self.goal_version == \"priority\":\n task_info = \"Among the problems with duplicated problem statements, mark the lower priority one as duplicate of the higher priority one\"\n elif self.goal_version == \"high priority\":\n task_info = \"Among the problems with duplicated problem statements, mark any as duplicate of the other. Change the description of the problem marked as duplicate to 'duplicate'.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n target_problem_number = self.target_problem[\"number\"]\n\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.wait_for_selector(f\"[aria-label='Preview record: {target_problem_number}']\").click()\n page.wait_for_timeout(1500)\n # Click on the private task to open it\n frame.get_by_text(\"Open Record\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Open the duplicate mode\n frame.get_by_text(\"Mark Duplicate\").first.click()\n page.wait_for_timeout(1000)\n # Close the pop-up to edit the duplicate problem in the same window\n frame.get_by_text(\"Close\").last.click()\n frame.locator('[aria-labelledby=\"label.problem.duplicate_of\"]').fill(\n self.source_problem[\"number\"]\n )\n page.keyboard.press(\"Enter\")\n page.wait_for_timeout(1000)\n if self.add_comment:\n frame.locator('[id=\"problem.description\"]').fill(\"Duplicate\")\n\n frame.get_by_text(\"update\").first.click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n target_problem_record = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"number={self.target_problem['number']}\"},\n )[\"result\"]\n source_problem_record = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"number={self.source_problem['number']}\"},\n )[\"result\"]\n # If the ordering can be anything, we check both problems\n problem_found = source_problem_record and target_problem_record\n\n if not problem_found:\n return 0, False, \"\", {\"message\": \"Problem not found in DB.\"}\n\n # if the duplicate value is not set, the field will be an empty string; otherwise it will be a dict\n target_duplicate_value = target_problem_record[0][\"duplicate_of\"]\n if target_duplicate_value:\n target_duplicate_value = target_duplicate_value[\"value\"]\n\n target_is_duplicate = target_duplicate_value == source_problem_record[0][\"sys_id\"]\n if self.respect_problem_ordering:\n problem_marked_as_duplicate = target_is_duplicate\n else:\n source_duplicate_value = source_problem_record[0][\"duplicate_of\"]\n if source_duplicate_value:\n source_duplicate_value = source_duplicate_value[\"value\"]\n source_is_duplicate = source_duplicate_value == target_problem_record[0][\"sys_id\"]\n problem_marked_as_duplicate = target_is_duplicate or source_is_duplicate\n\n if self.add_comment:\n comment_added = (\n target_problem_record[0][\"description\"].lower() == \"duplicate\"\n and target_is_duplicate\n )\n if not self.respect_problem_ordering:\n comment_added = comment_added or (\n source_problem_record[0][\"description\"].lower() == \"duplicate\"\n and source_is_duplicate\n )\n if not comment_added:\n return 0, False, \"\", {\"message\": \"Comment not added.\"}\n\n if not problem_marked_as_duplicate:\n return 0, False, \"\", {\"message\": \"Problem not marked as duplicate.\"}\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Problem task was closed as duplicate.\"},\n )\n\n\n__TASKS__ = [SetProblemAsDuplicateTask]","source_hash":"db39cfa32b82e3b864204cf9f63591f8a076a3818a27dcf92bf0be9a906a05f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.mark_duplicate_problem.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.mark_duplicate_problem.__init__#L35-L56","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","language":"python","start_line":35,"end_line":56,"context_start_line":15,"context_end_line":76,"code":"\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the task list.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n respect_problem_ordering: bool\n Whether to respect the ordering of the problems in the list. If True, the task will pick the first problem in the\n list as the target problem. If False, the task validation will check if any problem is a duplicate of the other.\n add_comment: bool\n Whether or not to add comment to the duplicated task. If set to True, will add \"Duplicate\" as the problem description\n goal_version: str\n choice of \"base\", \"priority\", \"high_priority\". Adjusts the goal to the task setting for L2\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n start_rel_url=\"/now/nav/ui/classic/params/target/problem_list.do\",\n fixed_config: dict = None,\n respect_problem_ordering: bool = False,\n add_comment: bool = False,\n goal_version: str = \"base\",\n level: int = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n\n self.problem_sys_id = None\n self.respect_problem_ordering = respect_problem_ordering\n self.add_comment = add_comment\n self.goal_version = goal_version\n self.level = level\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.target_problem = self.fixed_config[\"target_problem\"]\n self.source_problem = self.fixed_config[\"source_problem\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L2 compositional tasks.\n called by subclasses\n \"\"\"\n\n if self.level == 3:\n task_info = \" \"\n elif self.goal_version == \"base\":\n task_info = \"Mark problems with duplicated problem statements as such. You can mark any as duplicate of the other.\"\n elif self.goal_version == \"priority\":","source_hash":"db39cfa32b82e3b864204cf9f63591f8a076a3818a27dcf92bf0be9a906a05f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.mark_duplicate_problem.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.mark_duplicate_problem.setup_goal#L58-L64","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","language":"python","start_line":58,"end_line":64,"context_start_line":38,"context_end_line":84,"code":" instance=None,\n start_rel_url=\"/now/nav/ui/classic/params/target/problem_list.do\",\n fixed_config: dict = None,\n respect_problem_ordering: bool = False,\n add_comment: bool = False,\n goal_version: str = \"base\",\n level: int = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n\n self.problem_sys_id = None\n self.respect_problem_ordering = respect_problem_ordering\n self.add_comment = add_comment\n self.goal_version = goal_version\n self.level = level\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.target_problem = self.fixed_config[\"target_problem\"]\n self.source_problem = self.fixed_config[\"source_problem\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L2 compositional tasks.\n called by subclasses\n \"\"\"\n\n if self.level == 3:\n task_info = \" \"\n elif self.goal_version == \"base\":\n task_info = \"Mark problems with duplicated problem statements as such. You can mark any as duplicate of the other.\"\n elif self.goal_version == \"priority\":\n task_info = \"Among the problems with duplicated problem statements, mark the lower priority one as duplicate of the higher priority one\"\n elif self.goal_version == \"high priority\":\n task_info = \"Among the problems with duplicated problem statements, mark any as duplicate of the other. Change the description of the problem marked as duplicate to 'duplicate'.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)","source_hash":"db39cfa32b82e3b864204cf9f63591f8a076a3818a27dcf92bf0be9a906a05f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.mark_duplicate_problem.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.mark_duplicate_problem.get_pretty_printed_description#L66-L81","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","language":"python","start_line":66,"end_line":81,"context_start_line":46,"context_end_line":101,"code":" ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n\n self.problem_sys_id = None\n self.respect_problem_ordering = respect_problem_ordering\n self.add_comment = add_comment\n self.goal_version = goal_version\n self.level = level\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.target_problem = self.fixed_config[\"target_problem\"]\n self.source_problem = self.fixed_config[\"source_problem\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L2 compositional tasks.\n called by subclasses\n \"\"\"\n\n if self.level == 3:\n task_info = \" \"\n elif self.goal_version == \"base\":\n task_info = \"Mark problems with duplicated problem statements as such. You can mark any as duplicate of the other.\"\n elif self.goal_version == \"priority\":\n task_info = \"Among the problems with duplicated problem statements, mark the lower priority one as duplicate of the higher priority one\"\n elif self.goal_version == \"high priority\":\n task_info = \"Among the problems with duplicated problem statements, mark any as duplicate of the other. Change the description of the problem marked as duplicate to 'duplicate'.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n target_problem_number = self.target_problem[\"number\"]\n\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.wait_for_selector(f\"[aria-label='Preview record: {target_problem_number}']\").click()\n page.wait_for_timeout(1500)\n # Click on the private task to open it\n frame.get_by_text(\"Open Record\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Open the duplicate mode\n frame.get_by_text(\"Mark Duplicate\").first.click()\n page.wait_for_timeout(1000)\n # Close the pop-up to edit the duplicate problem in the same window\n frame.get_by_text(\"Close\").last.click()","source_hash":"db39cfa32b82e3b864204cf9f63591f8a076a3818a27dcf92bf0be9a906a05f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.mark_duplicate_problem.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.mark_duplicate_problem.cheat#L83-L110","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","language":"python","start_line":83,"end_line":110,"context_start_line":63,"context_end_line":130,"code":"\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L2 compositional tasks.\n called by subclasses\n \"\"\"\n\n if self.level == 3:\n task_info = \" \"\n elif self.goal_version == \"base\":\n task_info = \"Mark problems with duplicated problem statements as such. You can mark any as duplicate of the other.\"\n elif self.goal_version == \"priority\":\n task_info = \"Among the problems with duplicated problem statements, mark the lower priority one as duplicate of the higher priority one\"\n elif self.goal_version == \"high priority\":\n task_info = \"Among the problems with duplicated problem statements, mark any as duplicate of the other. Change the description of the problem marked as duplicate to 'duplicate'.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n target_problem_number = self.target_problem[\"number\"]\n\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.wait_for_selector(f\"[aria-label='Preview record: {target_problem_number}']\").click()\n page.wait_for_timeout(1500)\n # Click on the private task to open it\n frame.get_by_text(\"Open Record\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Open the duplicate mode\n frame.get_by_text(\"Mark Duplicate\").first.click()\n page.wait_for_timeout(1000)\n # Close the pop-up to edit the duplicate problem in the same window\n frame.get_by_text(\"Close\").last.click()\n frame.locator('[aria-labelledby=\"label.problem.duplicate_of\"]').fill(\n self.source_problem[\"number\"]\n )\n page.keyboard.press(\"Enter\")\n page.wait_for_timeout(1000)\n if self.add_comment:\n frame.locator('[id=\"problem.description\"]').fill(\"Duplicate\")\n\n frame.get_by_text(\"update\").first.click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n target_problem_record = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"number={self.target_problem['number']}\"},\n )[\"result\"]\n source_problem_record = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"number={self.source_problem['number']}\"},\n )[\"result\"]\n # If the ordering can be anything, we check both problems\n problem_found = source_problem_record and target_problem_record\n\n if not problem_found:\n return 0, False, \"\", {\"message\": \"Problem not found in DB.\"}","source_hash":"db39cfa32b82e3b864204cf9f63591f8a076a3818a27dcf92bf0be9a906a05f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.mark_duplicate_problem.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.mark_duplicate_problem.validate#L112-L168","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","language":"python","start_line":112,"end_line":168,"context_start_line":92,"context_end_line":171,"code":" frame.get_by_text(\"Open Record\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Open the duplicate mode\n frame.get_by_text(\"Mark Duplicate\").first.click()\n page.wait_for_timeout(1000)\n # Close the pop-up to edit the duplicate problem in the same window\n frame.get_by_text(\"Close\").last.click()\n frame.locator('[aria-labelledby=\"label.problem.duplicate_of\"]').fill(\n self.source_problem[\"number\"]\n )\n page.keyboard.press(\"Enter\")\n page.wait_for_timeout(1000)\n if self.add_comment:\n frame.locator('[id=\"problem.description\"]').fill(\"Duplicate\")\n\n frame.get_by_text(\"update\").first.click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n target_problem_record = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"number={self.target_problem['number']}\"},\n )[\"result\"]\n source_problem_record = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"number={self.source_problem['number']}\"},\n )[\"result\"]\n # If the ordering can be anything, we check both problems\n problem_found = source_problem_record and target_problem_record\n\n if not problem_found:\n return 0, False, \"\", {\"message\": \"Problem not found in DB.\"}\n\n # if the duplicate value is not set, the field will be an empty string; otherwise it will be a dict\n target_duplicate_value = target_problem_record[0][\"duplicate_of\"]\n if target_duplicate_value:\n target_duplicate_value = target_duplicate_value[\"value\"]\n\n target_is_duplicate = target_duplicate_value == source_problem_record[0][\"sys_id\"]\n if self.respect_problem_ordering:\n problem_marked_as_duplicate = target_is_duplicate\n else:\n source_duplicate_value = source_problem_record[0][\"duplicate_of\"]\n if source_duplicate_value:\n source_duplicate_value = source_duplicate_value[\"value\"]\n source_is_duplicate = source_duplicate_value == target_problem_record[0][\"sys_id\"]\n problem_marked_as_duplicate = target_is_duplicate or source_is_duplicate\n\n if self.add_comment:\n comment_added = (\n target_problem_record[0][\"description\"].lower() == \"duplicate\"\n and target_is_duplicate\n )\n if not self.respect_problem_ordering:\n comment_added = comment_added or (\n source_problem_record[0][\"description\"].lower() == \"duplicate\"\n and source_is_duplicate\n )\n if not comment_added:\n return 0, False, \"\", {\"message\": \"Comment not added.\"}\n\n if not problem_marked_as_duplicate:\n return 0, False, \"\", {\"message\": \"Problem not marked as duplicate.\"}\n\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Problem task was closed as duplicate.\"},\n )\n\n\n__TASKS__ = [SetProblemAsDuplicateTask]","source_hash":"db39cfa32b82e3b864204cf9f63591f8a076a3818a27dcf92bf0be9a906a05f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.navigation#L1-L239","kind":"module","name":"src.browsergym.workarena.tasks.navigation","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":1,"end_line":239,"context_start_line":1,"context_end_line":239,"code":"\"\"\"\nTasks related to basic menu navigation.\n\n\"\"\"\n\nimport json\nimport playwright.sync_api\nimport re\n\nfrom importlib import resources\nfrom playwright.sync_api import Page\nfrom urllib import parse\nfrom typing import List, Tuple\n\nfrom ..api.utils import table_api_call\nfrom .base import AbstractServiceNowTask\nfrom ..config import ALL_MENU_PATH, IMPERSONATION_CONFIG_PATH\nfrom ..instance import SNowInstance\nfrom ..utils import impersonate_user\n\n\nclass AllMenuTask(AbstractServiceNowTask):\n \"\"\"\n Navigate to some application module using the All menu.\n\n Parameters:\n -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/all_menu.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance: SNowInstance = None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"/now/nav/ui/home\")\n self.fixed_config = fixed_config\n with open(ALL_MENU_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n self.module = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n\n # When menu tasks do not need to be validated, the URL can be omitted from their config\n self.final_url = self.instance.snow_url + self.module.get(\"url\", \"\")\n\n # Generate goal\n goal = f'Navigate to the \"{self.module[\"module\"]}\" module of the \"{self.module[\"application\"]}\" application.'\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f'- Navigate to the \"{self.module[\"module\"]}\" module of the \"{self.module[\"application\"]}\" application.'\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n # gsft_main remains undefined on the landing page; we have to wait for the network to be idle instead.\n page.wait_for_load_state(\"networkidle\")\n menu_button = page.locator('div[aria-label=\"All\"]')\n if menu_button.get_attribute(\"aria-expanded\").lower() != \"true\":\n menu_button.click()\n\n # Select the menu's main div\n menu = page.locator('div[aria-label=\"All menu\"]')\n\n # Filter the menu using the application's name\n menu.get_by_placeholder(\"Filter\").fill(self.module[\"application\"])\n\n # Avoids issues due to list not being fully filtered yet\n # We could certainly do something more fancy, but it's not\n # worth spending time on right now.\n page.wait_for_timeout(1000)\n\n path = [m.strip() for m in self.module[\"module\"].split(\">\")]\n # Navigate to the application's location in the menu and select its parent\n locator = menu.get_by_label(self.module[\"application\"], exact=True).and_(\n menu.get_by_role(\"button\")\n )\n locator = locator.locator(\"xpath=ancestor::div[contains(@class, 'snf-collapsible-list')]\")\n for module in path[:-1]:\n # Expand menu if necessary (this is mostly for visual satisfaction, cheat func would still work without it)\n # XXX: Double selector here is due to discrepancies in the UI for various ServiceNow releases\n button = locator.locator(\n f'button[aria-label=\"{module}\"], div[role=\"button\"][aria-label=\"{module}\"]'\n ).first\n button.scroll_into_view_if_needed()\n if button.get_attribute(\"aria-expanded\").lower() != \"true\":\n button.click()\n\n # Get the button's parent \"collapsible list\" container\n parent_div_locator = button.locator(\n \"xpath=ancestor::div[contains(@class, 'snf-collapsible-list')]\"\n )\n locator = parent_div_locator\n\n # Click the final menu item\n menu_item = locator.get_by_label(path[-1], exact=True)\n # In some cases, like System Scheduler > Scheduled Jobs > Scheduled Jobs, modules are repeated in the path\n # This causes problems when clicking. Therefore, we pick the last item\n if menu_item.count() > 1:\n menu_item = menu_item.first\n with page.expect_navigation():\n menu_item.click()\n page.wait_for_timeout(2000)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n page.wait_for_load_state(\"domcontentloaded\")\n\n # Get the current URL and the final URL\n current_url = parse.urlunparse(\n parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n )\n final_url = parse.urlunparse(parse.urlparse(parse.unquote(self.final_url)))\n\n if final_url == current_url:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct module reached.\"},\n )\n\n return 0, False, \"\", {\"message\": \"Not at expected URL.\"}\n\n def teardown(self) -> None:\n pass\n\n\nclass ImpersonationTask(AbstractServiceNowTask):\n \"\"\"\n Task to impersonate a user.\n\n Parameters:\n -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/impersonation_users.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"/now/nav/ui/home\")\n self.fixed_config = fixed_config\n with open(IMPERSONATION_CONFIG_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n self.user_full_name = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n assert self.user_full_name in self.all_configs\n\n # Generate goal\n goal = f\"Impersonate the user {self.user_full_name}.\"\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Impersonate the user {self.user_full_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n impersonate_user(self.user_full_name, page)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n page.wait_for_function(\"window.NOW && window.NOW.user\")\n\n user_info = page.evaluate(\"window.NOW\")[\"user\"]\n\n # If the current user is not being impersonated, fail.\n if not user_info[\"isImpersonating\"]:\n return 0, False, \"\", {\"message\": \"Not currently impersonating a user.\"}\n\n # Fetch user's full name from database\n user_fullname = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={user_info['userID']}\",\n \"sysparm_fields\": \"name\",\n },\n )[\"result\"][0][\"name\"]\n\n # If the name matches, success.\n if user_fullname == self.user_full_name:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct user impersonated.\"},\n )\n\n # Otherwise, fail.\n return 0, False, \"\", {\"message\": \"Currently impersonating the wrong user.\"}\n\n def teardown(self) -> None:\n pass\n\n\n__TASKS__ = [AllMenuTask, ImpersonationTask]","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation.AllMenuTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.navigation.AllMenuTask#L22-L146","kind":"class","name":"AllMenuTask","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":22,"end_line":146,"context_start_line":2,"context_end_line":166,"code":"Tasks related to basic menu navigation.\n\n\"\"\"\n\nimport json\nimport playwright.sync_api\nimport re\n\nfrom importlib import resources\nfrom playwright.sync_api import Page\nfrom urllib import parse\nfrom typing import List, Tuple\n\nfrom ..api.utils import table_api_call\nfrom .base import AbstractServiceNowTask\nfrom ..config import ALL_MENU_PATH, IMPERSONATION_CONFIG_PATH\nfrom ..instance import SNowInstance\nfrom ..utils import impersonate_user\n\n\nclass AllMenuTask(AbstractServiceNowTask):\n \"\"\"\n Navigate to some application module using the All menu.\n\n Parameters:\n -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/all_menu.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance: SNowInstance = None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"/now/nav/ui/home\")\n self.fixed_config = fixed_config\n with open(ALL_MENU_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n self.module = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n\n # When menu tasks do not need to be validated, the URL can be omitted from their config\n self.final_url = self.instance.snow_url + self.module.get(\"url\", \"\")\n\n # Generate goal\n goal = f'Navigate to the \"{self.module[\"module\"]}\" module of the \"{self.module[\"application\"]}\" application.'\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f'- Navigate to the \"{self.module[\"module\"]}\" module of the \"{self.module[\"application\"]}\" application.'\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n # gsft_main remains undefined on the landing page; we have to wait for the network to be idle instead.\n page.wait_for_load_state(\"networkidle\")\n menu_button = page.locator('div[aria-label=\"All\"]')\n if menu_button.get_attribute(\"aria-expanded\").lower() != \"true\":\n menu_button.click()\n\n # Select the menu's main div\n menu = page.locator('div[aria-label=\"All menu\"]')\n\n # Filter the menu using the application's name\n menu.get_by_placeholder(\"Filter\").fill(self.module[\"application\"])\n\n # Avoids issues due to list not being fully filtered yet\n # We could certainly do something more fancy, but it's not\n # worth spending time on right now.\n page.wait_for_timeout(1000)\n\n path = [m.strip() for m in self.module[\"module\"].split(\">\")]\n # Navigate to the application's location in the menu and select its parent\n locator = menu.get_by_label(self.module[\"application\"], exact=True).and_(\n menu.get_by_role(\"button\")\n )\n locator = locator.locator(\"xpath=ancestor::div[contains(@class, 'snf-collapsible-list')]\")\n for module in path[:-1]:\n # Expand menu if necessary (this is mostly for visual satisfaction, cheat func would still work without it)\n # XXX: Double selector here is due to discrepancies in the UI for various ServiceNow releases\n button = locator.locator(\n f'button[aria-label=\"{module}\"], div[role=\"button\"][aria-label=\"{module}\"]'\n ).first\n button.scroll_into_view_if_needed()\n if button.get_attribute(\"aria-expanded\").lower() != \"true\":\n button.click()\n\n # Get the button's parent \"collapsible list\" container\n parent_div_locator = button.locator(\n \"xpath=ancestor::div[contains(@class, 'snf-collapsible-list')]\"\n )\n locator = parent_div_locator\n\n # Click the final menu item\n menu_item = locator.get_by_label(path[-1], exact=True)\n # In some cases, like System Scheduler > Scheduled Jobs > Scheduled Jobs, modules are repeated in the path\n # This causes problems when clicking. Therefore, we pick the last item\n if menu_item.count() > 1:\n menu_item = menu_item.first\n with page.expect_navigation():\n menu_item.click()\n page.wait_for_timeout(2000)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n page.wait_for_load_state(\"domcontentloaded\")\n\n # Get the current URL and the final URL\n current_url = parse.urlunparse(\n parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n )\n final_url = parse.urlunparse(parse.urlparse(parse.unquote(self.final_url)))\n\n if final_url == current_url:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct module reached.\"},\n )\n\n return 0, False, \"\", {\"message\": \"Not at expected URL.\"}\n\n def teardown(self) -> None:\n pass\n\n\nclass ImpersonationTask(AbstractServiceNowTask):\n \"\"\"\n Task to impersonate a user.\n\n Parameters:\n -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/impersonation_users.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation.ImpersonationTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.navigation.ImpersonationTask#L149-L236","kind":"class","name":"ImpersonationTask","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":149,"end_line":236,"context_start_line":129,"context_end_line":239,"code":" # Get the current URL and the final URL\n current_url = parse.urlunparse(\n parse.urlparse(parse.unquote(page.evaluate(\"() => window.location.href\")))\n )\n final_url = parse.urlunparse(parse.urlparse(parse.unquote(self.final_url)))\n\n if final_url == current_url:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct module reached.\"},\n )\n\n return 0, False, \"\", {\"message\": \"Not at expected URL.\"}\n\n def teardown(self) -> None:\n pass\n\n\nclass ImpersonationTask(AbstractServiceNowTask):\n \"\"\"\n Task to impersonate a user.\n\n Parameters:\n -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/impersonation_users.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"/now/nav/ui/home\")\n self.fixed_config = fixed_config\n with open(IMPERSONATION_CONFIG_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n self.user_full_name = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n assert self.user_full_name in self.all_configs\n\n # Generate goal\n goal = f\"Impersonate the user {self.user_full_name}.\"\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Impersonate the user {self.user_full_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n impersonate_user(self.user_full_name, page)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n page.wait_for_function(\"window.NOW && window.NOW.user\")\n\n user_info = page.evaluate(\"window.NOW\")[\"user\"]\n\n # If the current user is not being impersonated, fail.\n if not user_info[\"isImpersonating\"]:\n return 0, False, \"\", {\"message\": \"Not currently impersonating a user.\"}\n\n # Fetch user's full name from database\n user_fullname = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={user_info['userID']}\",\n \"sysparm_fields\": \"name\",\n },\n )[\"result\"][0][\"name\"]\n\n # If the name matches, success.\n if user_fullname == self.user_full_name:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct user impersonated.\"},\n )\n\n # Otherwise, fail.\n return 0, False, \"\", {\"message\": \"Currently impersonating the wrong user.\"}\n\n def teardown(self) -> None:\n pass\n\n\n__TASKS__ = [AllMenuTask, ImpersonationTask]","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.navigation.__init__#L165-L172","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":165,"end_line":172,"context_start_line":145,"context_end_line":192,"code":" def teardown(self) -> None:\n pass\n\n\nclass ImpersonationTask(AbstractServiceNowTask):\n \"\"\"\n Task to impersonate a user.\n\n Parameters:\n -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/impersonation_users.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"/now/nav/ui/home\")\n self.fixed_config = fixed_config\n with open(IMPERSONATION_CONFIG_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n self.user_full_name = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n assert self.user_full_name in self.all_configs\n\n # Generate goal\n goal = f\"Impersonate the user {self.user_full_name}.\"\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.navigation.setup_goal#L174-L187","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":174,"end_line":187,"context_start_line":154,"context_end_line":207,"code":" -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/impersonation_users.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"/now/nav/ui/home\")\n self.fixed_config = fixed_config\n with open(IMPERSONATION_CONFIG_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n self.user_full_name = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n assert self.user_full_name in self.all_configs\n\n # Generate goal\n goal = f\"Impersonate the user {self.user_full_name}.\"\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Impersonate the user {self.user_full_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n impersonate_user(self.user_full_name, page)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n page.wait_for_function(\"window.NOW && window.NOW.user\")\n\n user_info = page.evaluate(\"window.NOW\")[\"user\"]","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.navigation.get_pretty_printed_description#L189-L196","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":189,"end_line":196,"context_start_line":169,"context_end_line":216,"code":" self.fixed_config = fixed_config\n with open(IMPERSONATION_CONFIG_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n self.user_full_name = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n assert self.user_full_name in self.all_configs\n\n # Generate goal\n goal = f\"Impersonate the user {self.user_full_name}.\"\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Impersonate the user {self.user_full_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n impersonate_user(self.user_full_name, page)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n page.wait_for_function(\"window.NOW && window.NOW.user\")\n\n user_info = page.evaluate(\"window.NOW\")[\"user\"]\n\n # If the current user is not being impersonated, fail.\n if not user_info[\"isImpersonating\"]:\n return 0, False, \"\", {\"message\": \"Not currently impersonating a user.\"}\n\n # Fetch user's full name from database\n user_fullname = table_api_call(\n instance=self.instance,\n table=\"sys_user\",","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.navigation.cheat#L198-L200","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":198,"end_line":200,"context_start_line":178,"context_end_line":220,"code":" self.user_full_name = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n assert self.user_full_name in self.all_configs\n\n # Generate goal\n goal = f\"Impersonate the user {self.user_full_name}.\"\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Impersonate the user {self.user_full_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n impersonate_user(self.user_full_name, page)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n page.wait_for_function(\"window.NOW && window.NOW.user\")\n\n user_info = page.evaluate(\"window.NOW\")[\"user\"]\n\n # If the current user is not being impersonated, fail.\n if not user_info[\"isImpersonating\"]:\n return 0, False, \"\", {\"message\": \"Not currently impersonating a user.\"}\n\n # Fetch user's full name from database\n user_fullname = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={user_info['userID']}\",\n \"sysparm_fields\": \"name\",\n },","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.navigation.validate#L202-L233","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":202,"end_line":233,"context_start_line":182,"context_end_line":239,"code":"\n # Generate goal\n goal = f\"Impersonate the user {self.user_full_name}.\"\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Impersonate the user {self.user_full_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n impersonate_user(self.user_full_name, page)\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n page.wait_for_function(\"window.NOW && window.NOW.user\")\n\n user_info = page.evaluate(\"window.NOW\")[\"user\"]\n\n # If the current user is not being impersonated, fail.\n if not user_info[\"isImpersonating\"]:\n return 0, False, \"\", {\"message\": \"Not currently impersonating a user.\"}\n\n # Fetch user's full name from database\n user_fullname = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={user_info['userID']}\",\n \"sysparm_fields\": \"name\",\n },\n )[\"result\"][0][\"name\"]\n\n # If the name matches, success.\n if user_fullname == self.user_full_name:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct user impersonated.\"},\n )\n\n # Otherwise, fail.\n return 0, False, \"\", {\"message\": \"Currently impersonating the wrong user.\"}\n\n def teardown(self) -> None:\n pass\n\n\n__TASKS__ = [AllMenuTask, ImpersonationTask]","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.navigation.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.navigation.teardown#L235-L236","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":235,"end_line":236,"context_start_line":215,"context_end_line":239,"code":" instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={user_info['userID']}\",\n \"sysparm_fields\": \"name\",\n },\n )[\"result\"][0][\"name\"]\n\n # If the name matches, success.\n if user_fullname == self.user_full_name:\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Correct user impersonated.\"},\n )\n\n # Otherwise, fail.\n return 0, False, \"\", {\"message\": \"Currently impersonating the wrong user.\"}\n\n def teardown(self) -> None:\n pass\n\n\n__TASKS__ = [AllMenuTask, ImpersonationTask]","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.knowledge#L1-L359","kind":"module","name":"src.browsergym.workarena.tasks.knowledge","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":1,"end_line":359,"context_start_line":1,"context_end_line":359,"code":"\"\"\"\nTasks related to knowledge bases.\n\n\"\"\"\n\nimport json\nimport logging\nimport re\n\nfrom playwright.sync_api import Page\nfrom typing import Tuple\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\nfrom .utils.utils import check_url_suffix_match\n\nfrom ..api.utils import table_api_call\nfrom ..config import KB_FILEPATH, KB_CONFIG_PATH, KB_NAME, SNOW_BROWSER_TIMEOUT\nfrom ..install import check_knowledge_base\nfrom ..instance import SNowInstance\n\n\nclass KnowledgeBaseSearchTask(AbstractServiceNowTask):\n \"\"\"\n Generic task to create a search for information in the knowledge base.\n\n Parameters:\n -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/knowledge_base_configs.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self,\n instance=None,\n fixed_config: dict = None,\n is_correct: bool = True,\n is_only_navigating: bool = False,\n search_by_title: bool = False,\n seed: int = None,\n **kwargs,\n ) -> None:\n \"\"\"\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config:\n A fixed configuration for the task, if required.\n is_correct: bool\n Used for the compositional task.\n If false, the answer is highlighted in 'red' instead of 'yellow' when using cheat.\n is_only_navigating: bool\n Used for the compositional task.\n If we only are navigating and not searching, change the goal for the agent.\n search_by_title: bool\n Used for the compositional task.\n If true, clicks on the article title using the article name, else opens the first article.\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/kb?id=kb_home\",\n )\n\n # Load the knowledge base and check its integrity\n with open(KB_FILEPATH, \"r\") as f:\n self.kb_entries = json.load(f)\n if hasattr(self, \"_base_initial_instance\"):\n _, requires_install, requires_delete = check_knowledge_base(\n self._base_initial_instance, # if user does not have permission to view the kb then this breaks\n kb_name=KB_NAME,\n kb_data=self.kb_entries, # Need admin permissions to check\n )\n else:\n _, requires_install, requires_delete = check_knowledge_base(\n SNowInstance(), # instance would be the non-admin instance here and this might break in case user does not have required permissions\n kb_name=KB_NAME,\n kb_data=self.kb_entries, # Need admin permissions to check\n )\n with open(KB_CONFIG_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n if any([requires_install, requires_delete]):\n raise RuntimeError(\n f\"The knowledge base in instance {self.instance.snow_url} is missing or corrupted. \"\n \"See README for setup instructions.\"\n )\n self.fixed_config = fixed_config\n self.config = None\n\n # Attributes for compositional task\n self.is_correct = is_correct\n self.is_only_navigating = is_only_navigating\n self.search_by_title = search_by_title\n\n self.__dict__.update(kwargs)\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Checks that the main iframe is fully loaded\n\n \"\"\"\n # TODO: We don't use the flag-based method used in other tasks\n # because gsft_main doesn't have the event we register\n # on this page. Not sure why.\n logging.debug(f\"Waiting for page to be fully loaded\")\n page.wait_for_load_state(\"networkidle\")\n page.wait_for_selector('iframe[name=\"gsft_main\"]')\n logging.debug(f\"Detected page ready\")\n\n # Get main iframe\n # XXX: We use a loop because sometimes the iframe evaluates to None\n # even though we wait for it to be ready. This seems like a\n # playwright bug.\n timeout = SNOW_BROWSER_TIMEOUT\n while timeout > 0:\n iframe = page.frame(name=\"gsft_main\")\n if iframe:\n break\n page.wait_for_timeout(100)\n timeout -= 100\n else:\n raise TimeoutError(\n f\"Timed out waiting for iframe to be ready in {self.instance.snow_url}\"\n )\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n self.item = config[\"item\"]\n self.answer = config[\"value\"]\n self.alternative_answers = config[\"alternative_answers\"]\n self.question = config[\"question\"]\n if self.search_by_title:\n self.kb_article_title = config[\"kb_article_title\"]\n\n # Generate goal\n if self.is_only_navigating:\n goal = f'Navigate to a relevant article in the knowledge base by searching for: \"{self.item}\" and open the article: \"{self.kb_article_title}\"'\n else:\n goal = f'Answer the following question using the knowledge base: \"{self.question}\"'\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n\n task_info = f\"- {class_name_formatted}: {self.item} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page)\n\n iframe = page.frame(name=\"gsft_main\")\n search = iframe.locator('input[aria-label=\"Search\"][role=\"textbox\"]')\n search.fill(f'\"{self.item}\"')\n\n with page.expect_navigation():\n self.page.keyboard.press(\"Enter\")\n\n # Click on the article\n with page.expect_navigation():\n if self.search_by_title:\n iframe.locator(f'a.kb-title:has-text(\"{self.kb_article_title}\")').click()\n else:\n iframe.locator(\"a.kb-title\").first.click()\n\n # Color the query and answer (this is just for visualization, it changes nothing to the validation)\n paragraphs = iframe.locator(\"p\")\n for i in range(paragraphs.count()):\n paragraph = paragraphs.nth(i)\n inner_html = paragraph.inner_html()\n if self.item in inner_html:\n # Edit the inner html to change the background color of the answer\n inner_html = inner_html.replace(\n self.item,\n f'{self.item}',\n )\n if self.is_correct:\n inner_html = inner_html.replace(\n str(self.answer),\n f'{self.answer}',\n )\n else:\n inner_html = inner_html.replace(\n str(self.answer),\n f'{self.answer}',\n )\n paragraph.evaluate(f\"element => element.innerHTML = `{inner_html}`\")\n break\n\n # Add the \"extracted\" answer to the chat messages\n # TODO: this is a hack, the message will not be displayed in the html\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.answer)})\n\n def validate(self, page: Page, chat_messages: list[str]) -> tuple[float, bool, str, dict]:\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n\n accepted_answers = [a.lower() for a in [self.answer] + self.alternative_answers]\n answer = answer.lower()\n if any(a in answer for a in accepted_answers):\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct answer.\"},\n )\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect answer provided by the assistant.\"},\n )\n\n\nclass AddCommentToKnowledgeArticleTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Task to add a comment to a knowledge base article. Only used as a part of the compositional task for edit knowledge base\n Parameters:\n -----------\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task.\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/kb?id=kb_home\",\n user_roles=[],\n )\n self.fixed_config = fixed_config\n if self.fixed_config is None:\n raise Exception(\"Please provide a config for the add comment task.\")\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n config = self.fixed_config\n\n if \"kb_article_title\" not in config.keys():\n raise Exception(\"Need title in config file...\")\n self.article_name = config[\"kb_article_title\"]\n adhoc_kb_response = table_api_call(\n instance=self.instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"short_description={self.article_name}\",\n },\n )[\"result\"]\n if len(adhoc_kb_response) != 1:\n raise Exception(\"Required article not found, please fix config...\")\n\n self.kb_article_sys_id = adhoc_kb_response[0][\"sys_id\"]\n self.comment = config[\"comment\"]\n\n goal = f'Add the following comment to the knowledge base: \"{self.comment}\"'\n info = {}\n\n return goal, info\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Checks that the main iframe is fully loaded\n\n \"\"\"\n # TODO: We don't use the flag-based method used in other tasks\n # because gsft_main doesn't have the event we register\n # on this page. Not sure why.\n logging.debug(f\"Waiting for page to be fully loaded\")\n page.wait_for_load_state(\"networkidle\")\n page.wait_for_selector('iframe[name=\"gsft_main\"]')\n logging.debug(f\"Detected page ready\")\n\n # Get main iframe\n # XXX: We use a loop because sometimes the iframe evaluates to None\n # even though we wait for it to be ready. This seems like a\n # playwright bug.\n timeout = SNOW_BROWSER_TIMEOUT\n while timeout > 0:\n iframe = page.frame(name=\"gsft_main\")\n if iframe:\n break\n page.wait_for_timeout(100)\n timeout -= 100\n else:\n raise TimeoutError(\n f\"Timed out waiting for iframe to be ready in {self.instance.snow_url}\"\n )\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n\n task_info = f\"- {class_name_formatted}: Add the comment '{self.comment}' for the article with title {self.article_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n\n # Check if we need to do something else, gsft_main is not loading, it seems to load when navigating from the search, so might need for compositional tasks\n self._wait_for_ready(page)\n frame = page.frame(\"gsft_main\")\n frame.locator(\"button.comment-text\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').locator(\"html\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').get_by_label(\"Comments\").fill(\n self.comment\n )\n frame.get_by_role(\"button\", name=\"Submit\").click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n return super().validate(page, chat_messages)\n\n\n__TASKS__ = [\n KnowledgeBaseSearchTask,\n]","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge.KnowledgeBaseSearchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.knowledge.KnowledgeBaseSearchTask#L24-L242","kind":"class","name":"KnowledgeBaseSearchTask","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":24,"end_line":242,"context_start_line":4,"context_end_line":262,"code":"\"\"\"\n\nimport json\nimport logging\nimport re\n\nfrom playwright.sync_api import Page\nfrom typing import Tuple\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\nfrom .utils.utils import check_url_suffix_match\n\nfrom ..api.utils import table_api_call\nfrom ..config import KB_FILEPATH, KB_CONFIG_PATH, KB_NAME, SNOW_BROWSER_TIMEOUT\nfrom ..install import check_knowledge_base\nfrom ..instance import SNowInstance\n\n\nclass KnowledgeBaseSearchTask(AbstractServiceNowTask):\n \"\"\"\n Generic task to create a search for information in the knowledge base.\n\n Parameters:\n -----------\n\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/knowledge_base_configs.json\n for an example of a configuration file.\n\n \"\"\"\n\n def __init__(\n self,\n instance=None,\n fixed_config: dict = None,\n is_correct: bool = True,\n is_only_navigating: bool = False,\n search_by_title: bool = False,\n seed: int = None,\n **kwargs,\n ) -> None:\n \"\"\"\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config:\n A fixed configuration for the task, if required.\n is_correct: bool\n Used for the compositional task.\n If false, the answer is highlighted in 'red' instead of 'yellow' when using cheat.\n is_only_navigating: bool\n Used for the compositional task.\n If we only are navigating and not searching, change the goal for the agent.\n search_by_title: bool\n Used for the compositional task.\n If true, clicks on the article title using the article name, else opens the first article.\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/kb?id=kb_home\",\n )\n\n # Load the knowledge base and check its integrity\n with open(KB_FILEPATH, \"r\") as f:\n self.kb_entries = json.load(f)\n if hasattr(self, \"_base_initial_instance\"):\n _, requires_install, requires_delete = check_knowledge_base(\n self._base_initial_instance, # if user does not have permission to view the kb then this breaks\n kb_name=KB_NAME,\n kb_data=self.kb_entries, # Need admin permissions to check\n )\n else:\n _, requires_install, requires_delete = check_knowledge_base(\n SNowInstance(), # instance would be the non-admin instance here and this might break in case user does not have required permissions\n kb_name=KB_NAME,\n kb_data=self.kb_entries, # Need admin permissions to check\n )\n with open(KB_CONFIG_PATH, \"r\") as f:\n self.all_configs = json.load(f)\n if any([requires_install, requires_delete]):\n raise RuntimeError(\n f\"The knowledge base in instance {self.instance.snow_url} is missing or corrupted. \"\n \"See README for setup instructions.\"\n )\n self.fixed_config = fixed_config\n self.config = None\n\n # Attributes for compositional task\n self.is_correct = is_correct\n self.is_only_navigating = is_only_navigating\n self.search_by_title = search_by_title\n\n self.__dict__.update(kwargs)\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Checks that the main iframe is fully loaded\n\n \"\"\"\n # TODO: We don't use the flag-based method used in other tasks\n # because gsft_main doesn't have the event we register\n # on this page. Not sure why.\n logging.debug(f\"Waiting for page to be fully loaded\")\n page.wait_for_load_state(\"networkidle\")\n page.wait_for_selector('iframe[name=\"gsft_main\"]')\n logging.debug(f\"Detected page ready\")\n\n # Get main iframe\n # XXX: We use a loop because sometimes the iframe evaluates to None\n # even though we wait for it to be ready. This seems like a\n # playwright bug.\n timeout = SNOW_BROWSER_TIMEOUT\n while timeout > 0:\n iframe = page.frame(name=\"gsft_main\")\n if iframe:\n break\n page.wait_for_timeout(100)\n timeout -= 100\n else:\n raise TimeoutError(\n f\"Timed out waiting for iframe to be ready in {self.instance.snow_url}\"\n )\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n\n # Get task configuration\n config = self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n self.item = config[\"item\"]\n self.answer = config[\"value\"]\n self.alternative_answers = config[\"alternative_answers\"]\n self.question = config[\"question\"]\n if self.search_by_title:\n self.kb_article_title = config[\"kb_article_title\"]\n\n # Generate goal\n if self.is_only_navigating:\n goal = f'Navigate to a relevant article in the knowledge base by searching for: \"{self.item}\" and open the article: \"{self.kb_article_title}\"'\n else:\n goal = f'Answer the following question using the knowledge base: \"{self.question}\"'\n info = {}\n\n return goal, info\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n\n task_info = f\"- {class_name_formatted}: {self.item} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n self._wait_for_ready(page)\n\n iframe = page.frame(name=\"gsft_main\")\n search = iframe.locator('input[aria-label=\"Search\"][role=\"textbox\"]')\n search.fill(f'\"{self.item}\"')\n\n with page.expect_navigation():\n self.page.keyboard.press(\"Enter\")\n\n # Click on the article\n with page.expect_navigation():\n if self.search_by_title:\n iframe.locator(f'a.kb-title:has-text(\"{self.kb_article_title}\")').click()\n else:\n iframe.locator(\"a.kb-title\").first.click()\n\n # Color the query and answer (this is just for visualization, it changes nothing to the validation)\n paragraphs = iframe.locator(\"p\")\n for i in range(paragraphs.count()):\n paragraph = paragraphs.nth(i)\n inner_html = paragraph.inner_html()\n if self.item in inner_html:\n # Edit the inner html to change the background color of the answer\n inner_html = inner_html.replace(\n self.item,\n f'{self.item}',\n )\n if self.is_correct:\n inner_html = inner_html.replace(\n str(self.answer),\n f'{self.answer}',\n )\n else:\n inner_html = inner_html.replace(\n str(self.answer),\n f'{self.answer}',\n )\n paragraph.evaluate(f\"element => element.innerHTML = `{inner_html}`\")\n break\n\n # Add the \"extracted\" answer to the chat messages\n # TODO: this is a hack, the message will not be displayed in the html\n chat_messages.append({\"role\": \"assistant\", \"message\": str(self.answer)})\n\n def validate(self, page: Page, chat_messages: list[str]) -> tuple[float, bool, str, dict]:\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n\n accepted_answers = [a.lower() for a in [self.answer] + self.alternative_answers]\n answer = answer.lower()\n if any(a in answer for a in accepted_answers):\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct answer.\"},\n )\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect answer provided by the assistant.\"},\n )\n\n\nclass AddCommentToKnowledgeArticleTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Task to add a comment to a knowledge base article. Only used as a part of the compositional task for edit knowledge base\n Parameters:\n -----------\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task.\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/kb?id=kb_home\",","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge.AddCommentToKnowledgeArticleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.knowledge.AddCommentToKnowledgeArticleTask#L245-L354","kind":"class","name":"AddCommentToKnowledgeArticleTask","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":245,"end_line":354,"context_start_line":225,"context_end_line":359,"code":" )\n\n accepted_answers = [a.lower() for a in [self.answer] + self.alternative_answers]\n answer = answer.lower()\n if any(a in answer for a in accepted_answers):\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct answer.\"},\n )\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect answer provided by the assistant.\"},\n )\n\n\nclass AddCommentToKnowledgeArticleTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Task to add a comment to a knowledge base article. Only used as a part of the compositional task for edit knowledge base\n Parameters:\n -----------\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task.\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/kb?id=kb_home\",\n user_roles=[],\n )\n self.fixed_config = fixed_config\n if self.fixed_config is None:\n raise Exception(\"Please provide a config for the add comment task.\")\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n config = self.fixed_config\n\n if \"kb_article_title\" not in config.keys():\n raise Exception(\"Need title in config file...\")\n self.article_name = config[\"kb_article_title\"]\n adhoc_kb_response = table_api_call(\n instance=self.instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"short_description={self.article_name}\",\n },\n )[\"result\"]\n if len(adhoc_kb_response) != 1:\n raise Exception(\"Required article not found, please fix config...\")\n\n self.kb_article_sys_id = adhoc_kb_response[0][\"sys_id\"]\n self.comment = config[\"comment\"]\n\n goal = f'Add the following comment to the knowledge base: \"{self.comment}\"'\n info = {}\n\n return goal, info\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Checks that the main iframe is fully loaded\n\n \"\"\"\n # TODO: We don't use the flag-based method used in other tasks\n # because gsft_main doesn't have the event we register\n # on this page. Not sure why.\n logging.debug(f\"Waiting for page to be fully loaded\")\n page.wait_for_load_state(\"networkidle\")\n page.wait_for_selector('iframe[name=\"gsft_main\"]')\n logging.debug(f\"Detected page ready\")\n\n # Get main iframe\n # XXX: We use a loop because sometimes the iframe evaluates to None\n # even though we wait for it to be ready. This seems like a\n # playwright bug.\n timeout = SNOW_BROWSER_TIMEOUT\n while timeout > 0:\n iframe = page.frame(name=\"gsft_main\")\n if iframe:\n break\n page.wait_for_timeout(100)\n timeout -= 100\n else:\n raise TimeoutError(\n f\"Timed out waiting for iframe to be ready in {self.instance.snow_url}\"\n )\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n\n task_info = f\"- {class_name_formatted}: Add the comment '{self.comment}' for the article with title {self.article_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n\n # Check if we need to do something else, gsft_main is not loading, it seems to load when navigating from the search, so might need for compositional tasks\n self._wait_for_ready(page)\n frame = page.frame(\"gsft_main\")\n frame.locator(\"button.comment-text\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').locator(\"html\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').get_by_label(\"Comments\").fill(\n self.comment\n )\n frame.get_by_role(\"button\", name=\"Submit\").click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n return super().validate(page, chat_messages)\n\n\n__TASKS__ = [\n KnowledgeBaseSearchTask,\n]","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.knowledge.__init__#L256-L268","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":256,"end_line":268,"context_start_line":236,"context_end_line":288,"code":" else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect answer provided by the assistant.\"},\n )\n\n\nclass AddCommentToKnowledgeArticleTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Task to add a comment to a knowledge base article. Only used as a part of the compositional task for edit knowledge base\n Parameters:\n -----------\n instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task.\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/kb?id=kb_home\",\n user_roles=[],\n )\n self.fixed_config = fixed_config\n if self.fixed_config is None:\n raise Exception(\"Please provide a config for the add comment task.\")\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n config = self.fixed_config\n\n if \"kb_article_title\" not in config.keys():\n raise Exception(\"Need title in config file...\")\n self.article_name = config[\"kb_article_title\"]\n adhoc_kb_response = table_api_call(\n instance=self.instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"short_description={self.article_name}\",\n },\n )[\"result\"]\n if len(adhoc_kb_response) != 1:\n raise Exception(\"Required article not found, please fix config...\")\n\n self.kb_article_sys_id = adhoc_kb_response[0][\"sys_id\"]","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge._wait_for_ready","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.knowledge._wait_for_ready#L296-L323","kind":"function","name":"_wait_for_ready","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":296,"end_line":323,"context_start_line":276,"context_end_line":343,"code":" self.article_name = config[\"kb_article_title\"]\n adhoc_kb_response = table_api_call(\n instance=self.instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"short_description={self.article_name}\",\n },\n )[\"result\"]\n if len(adhoc_kb_response) != 1:\n raise Exception(\"Required article not found, please fix config...\")\n\n self.kb_article_sys_id = adhoc_kb_response[0][\"sys_id\"]\n self.comment = config[\"comment\"]\n\n goal = f'Add the following comment to the knowledge base: \"{self.comment}\"'\n info = {}\n\n return goal, info\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Checks that the main iframe is fully loaded\n\n \"\"\"\n # TODO: We don't use the flag-based method used in other tasks\n # because gsft_main doesn't have the event we register\n # on this page. Not sure why.\n logging.debug(f\"Waiting for page to be fully loaded\")\n page.wait_for_load_state(\"networkidle\")\n page.wait_for_selector('iframe[name=\"gsft_main\"]')\n logging.debug(f\"Detected page ready\")\n\n # Get main iframe\n # XXX: We use a loop because sometimes the iframe evaluates to None\n # even though we wait for it to be ready. This seems like a\n # playwright bug.\n timeout = SNOW_BROWSER_TIMEOUT\n while timeout > 0:\n iframe = page.frame(name=\"gsft_main\")\n if iframe:\n break\n page.wait_for_timeout(100)\n timeout -= 100\n else:\n raise TimeoutError(\n f\"Timed out waiting for iframe to be ready in {self.instance.snow_url}\"\n )\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n\n task_info = f\"- {class_name_formatted}: Add the comment '{self.comment}' for the article with title {self.article_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n\n # Check if we need to do something else, gsft_main is not loading, it seems to load when navigating from the search, so might need for compositional tasks","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.knowledge.setup_goal#L270-L294","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":270,"end_line":294,"context_start_line":250,"context_end_line":314,"code":" instance: SNowInstance\n The instance on which to create the record.\n fixed_config: dict\n Configuration to use for the task.\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance=None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/kb?id=kb_home\",\n user_roles=[],\n )\n self.fixed_config = fixed_config\n if self.fixed_config is None:\n raise Exception(\"Please provide a config for the add comment task.\")\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n super().setup_goal(page=page)\n config = self.fixed_config\n\n if \"kb_article_title\" not in config.keys():\n raise Exception(\"Need title in config file...\")\n self.article_name = config[\"kb_article_title\"]\n adhoc_kb_response = table_api_call(\n instance=self.instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"short_description={self.article_name}\",\n },\n )[\"result\"]\n if len(adhoc_kb_response) != 1:\n raise Exception(\"Required article not found, please fix config...\")\n\n self.kb_article_sys_id = adhoc_kb_response[0][\"sys_id\"]\n self.comment = config[\"comment\"]\n\n goal = f'Add the following comment to the knowledge base: \"{self.comment}\"'\n info = {}\n\n return goal, info\n\n def _wait_for_ready(self, page: Page) -> None:\n \"\"\"\n Checks that the main iframe is fully loaded\n\n \"\"\"\n # TODO: We don't use the flag-based method used in other tasks\n # because gsft_main doesn't have the event we register\n # on this page. Not sure why.\n logging.debug(f\"Waiting for page to be fully loaded\")\n page.wait_for_load_state(\"networkidle\")\n page.wait_for_selector('iframe[name=\"gsft_main\"]')\n logging.debug(f\"Detected page ready\")\n\n # Get main iframe\n # XXX: We use a loop because sometimes the iframe evaluates to None\n # even though we wait for it to be ready. This seems like a\n # playwright bug.\n timeout = SNOW_BROWSER_TIMEOUT\n while timeout > 0:","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.knowledge.get_pretty_printed_description#L325-L338","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":325,"end_line":338,"context_start_line":305,"context_end_line":358,"code":" page.wait_for_load_state(\"networkidle\")\n page.wait_for_selector('iframe[name=\"gsft_main\"]')\n logging.debug(f\"Detected page ready\")\n\n # Get main iframe\n # XXX: We use a loop because sometimes the iframe evaluates to None\n # even though we wait for it to be ready. This seems like a\n # playwright bug.\n timeout = SNOW_BROWSER_TIMEOUT\n while timeout > 0:\n iframe = page.frame(name=\"gsft_main\")\n if iframe:\n break\n page.wait_for_timeout(100)\n timeout -= 100\n else:\n raise TimeoutError(\n f\"Timed out waiting for iframe to be ready in {self.instance.snow_url}\"\n )\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n\n task_info = f\"- {class_name_formatted}: Add the comment '{self.comment}' for the article with title {self.article_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n\n # Check if we need to do something else, gsft_main is not loading, it seems to load when navigating from the search, so might need for compositional tasks\n self._wait_for_ready(page)\n frame = page.frame(\"gsft_main\")\n frame.locator(\"button.comment-text\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').locator(\"html\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').get_by_label(\"Comments\").fill(\n self.comment\n )\n frame.get_by_role(\"button\", name=\"Submit\").click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n return super().validate(page, chat_messages)\n\n\n__TASKS__ = [\n KnowledgeBaseSearchTask,","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.knowledge.cheat#L340-L351","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":340,"end_line":351,"context_start_line":320,"context_end_line":359,"code":" else:\n raise TimeoutError(\n f\"Timed out waiting for iframe to be ready in {self.instance.snow_url}\"\n )\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n class_name = self.__class__.__name__\n class_name = class_name.replace(\"Task\", \"\")\n # Split the words\n words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n\n task_info = f\"- {class_name_formatted}: Add the comment '{self.comment}' for the article with title {self.article_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n\n # Check if we need to do something else, gsft_main is not loading, it seems to load when navigating from the search, so might need for compositional tasks\n self._wait_for_ready(page)\n frame = page.frame(\"gsft_main\")\n frame.locator(\"button.comment-text\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').locator(\"html\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').get_by_label(\"Comments\").fill(\n self.comment\n )\n frame.get_by_role(\"button\", name=\"Submit\").click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n return super().validate(page, chat_messages)\n\n\n__TASKS__ = [\n KnowledgeBaseSearchTask,\n]","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.knowledge.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.knowledge.validate#L353-L354","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":353,"end_line":354,"context_start_line":333,"context_end_line":359,"code":" words = re.findall(r\"[A-Z][^A-Z]*\", class_name)\n class_name_formatted = \" \".join(words)\n\n task_info = f\"- {class_name_formatted}: Add the comment '{self.comment}' for the article with title {self.article_name} \\n\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page=page, chat_messages=chat_messages)\n\n # Check if we need to do something else, gsft_main is not loading, it seems to load when navigating from the search, so might need for compositional tasks\n self._wait_for_ready(page)\n frame = page.frame(\"gsft_main\")\n frame.locator(\"button.comment-text\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').locator(\"html\").click()\n frame.frame_locator('iframe[title=\"Rich Text Area\"]').get_by_label(\"Comments\").fill(\n self.comment\n )\n frame.get_by_role(\"button\", name=\"Submit\").click()\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n return super().validate(page, chat_messages)\n\n\n__TASKS__ = [\n KnowledgeBaseSearchTask,\n]","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.comp_building_block","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.comp_building_block#L1-L4","kind":"module","name":"src.browsergym.workarena.tasks.comp_building_block","path":"src/browsergym/workarena/tasks/comp_building_block.py","language":"python","start_line":1,"end_line":4,"context_start_line":1,"context_end_line":4,"code":"class CompositionalBuildingBlockTask:\n \"\"\"Base class for compositional building block tasks. Used to exclude these tasks from the list of tasks that are tested like atomic tasks\"\"\"\n\n pass","source_hash":"2e0dca6c05abc730077b95db3cde8bf1bbddbbb99f269981bc8ee35de483c0a1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.comp_building_block.CompositionalBuildingBlockTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.comp_building_block.CompositionalBuildingBlockTask#L1-L4","kind":"class","name":"CompositionalBuildingBlockTask","path":"src/browsergym/workarena/tasks/comp_building_block.py","language":"python","start_line":1,"end_line":4,"context_start_line":1,"context_end_line":4,"code":"class CompositionalBuildingBlockTask:\n \"\"\"Base class for compositional building block tasks. Used to exclude these tasks from the list of tasks that are tested like atomic tasks\"\"\"\n\n pass","source_hash":"2e0dca6c05abc730077b95db3cde8bf1bbddbbb99f269981bc8ee35de483c0a1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.dashboard#L1-L830","kind":"module","name":"src.browsergym.workarena.tasks.dashboard","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":1,"end_line":830,"context_start_line":1,"context_end_line":830,"code":"import json\nimport logging\nimport numpy as np\nimport playwright.sync_api\nimport re\n\nfrom abc import ABC, abstractmethod\nfrom tenacity import retry, stop_after_attempt, wait_fixed\nfrom typing import List, Tuple\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\nfrom .utils.utils import check_url_suffix_match\n\nfrom ..api.utils import table_api_call, table_column_info\nfrom ..config import (\n DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH,\n DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH,\n REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,\n REPORT_RETRIEVAL_VALUE_CONFIG_PATH,\n REPORT_PATCH_FLAG,\n)\nfrom ..instance import SNowInstance\nfrom .utils.string import share_tri_gram\nfrom .utils.utils import check_url_suffix_match\n\n# XXX: Some notes on plot types\n# - We currently don't support maps because they are clickable and would require a more evolved cheat function\nSUPPORTED_PLOT_TYPES = [\"area\", \"bar\", \"column\", \"line\", \"pie\", \"spline\"]\n\n# Get report filter config\nconfig = SNowInstance().report_filter_config\nif config is None:\n REPORT_DATE_FILTER = REPORT_TIME_FILTER = None\nelse:\n REPORT_DATE_FILTER = config[\"report_date_filter\"]\n REPORT_TIME_FILTER = config[\"report_time_filter\"]\ndel config\n\n\nclass DashboardRetrievalTask(AbstractServiceNowTask, ABC):\n \"\"\"\n A task to retrieve information from a ServiceNow dashboard\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance: SNowInstance = None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"\")\n self.iframe_id = \"gsft_main\"\n self.fixed_config = fixed_config\n self.__dict__.update(kwargs)\n\n @abstractmethod\n def all_configs(self) -> List[dict]:\n pass\n\n @abstractmethod\n def all_configs(self) -> List[dict]:\n pass\n\n def _get_charts(self, page: playwright.sync_api.Page) -> None:\n \"\"\"\n Extract all charts on the page\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n\n Returns:\n --------\n charts: list\n A list of charts where the chart is represented as a tuple of the chart title and the id of the\n element that contains the chart.\n\n \"\"\"\n iframe = page.frame(name=self.iframe_id)\n\n charts = page.evaluate(\n f\"{self.iframe_id}.Highcharts.charts.map((x) => {{if(x){{return [x.renderTo.ariaLabel, x.renderTo.id];}}}})\"\n )\n charts = [\n (title.replace(\"Highcharts interactive chart.\", \"\").replace(\".\", \"\").strip(), id)\n for title, id in charts\n if title\n and iframe.locator(f\"#{id}\").count()\n > 0 # Check if the element is actually on page (sometime rendering breaks)\n ]\n\n return charts\n\n def _read_chart(self, page: playwright.sync_api.Page, element_id: str) -> str:\n \"\"\"\n Read the chart at the specified index\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n element_id: str\n The ID of the element that contains the chart\n\n Returns:\n --------\n chart_type: str\n The type of the chart\n chart_data: dict\n The data of the chart\n\n \"\"\"\n self._wait_for_ready(page)\n\n # Validate plot type\n types = page.evaluate(\n f\"{self.iframe_id}.Highcharts.charts.find(chart => chart && chart.renderTo.id === '{element_id}').types\"\n )\n if len(set(types)) > 1:\n raise NotImplementedError(\"Multiple chart types in the same chart not supported\")\n type = types[0]\n if type not in SUPPORTED_PLOT_TYPES:\n raise NotImplementedError(f\"Chart type {type} not supported\")\n\n # Get data\n data = page.evaluate(\n f\"\"\"\n {self.iframe_id}.Highcharts.charts.find(chart => chart && chart.renderTo.id === \"{element_id}\")\n .series.map(series => ({{\n name: series.name,\n data: series.data.map(\n point => ({{\n label_cat: point.category,\n label_name: point.name,\n label_origx: point.origXValue,\n count: point.y,\n percent: point.percent\n }}))\n }}));\n \"\"\"\n )\n\n # Post-process each series\n for i in range(len(data)):\n # For each data point in the series\n for j in range(len(data[i][\"data\"])):\n data_point = data[i][\"data\"][j]\n\n # Remove None percent values when count is 0\n if data_point[\"count\"] == 0:\n data_point[\"percent\"] = 0\n\n # Strip trailing spaces from labels\n data_point[\"label_cat\"] = (\n data_point[\"label_cat\"].strip() if data_point[\"label_cat\"] else \"\"\n )\n data_point[\"label_name\"] = (\n data_point[\"label_name\"].strip() if data_point[\"label_name\"] else \"\"\n )\n data_point[\"label_origx\"] = (\n data_point[\"label_origx\"].strip() if data_point[\"label_origx\"] else \"\"\n )\n\n # Determine which label to use (this is a heuristic)\n # Usually, when the origx value is present, it is more detailed than the other labels.\n # However, in some rare cases, it corresponds to some strange value that doesn't get rendered.\n # As a heuristic for the last point, let's just make sure that origx has at least a one trigram\n # overlap with any of the other labels.\n if data_point[\"label_origx\"] != \"\" and any(\n share_tri_gram(data_point[\"label_origx\"], data_point[x])\n for x in [\"label_cat\", \"label_name\"]\n ):\n data_point[\"label\"] = data_point[\"label_origx\"]\n else:\n if type in [\"bar\", \"column\", \"spline\"]:\n data_point[\"label\"] = data_point[\"label_cat\"]\n else:\n data_point[\"label\"] = data_point[\"label_name\"]\n del data_point[\"label_cat\"]\n del data_point[\"label_name\"]\n del data_point[\"label_origx\"]\n\n assert len(set([dp[\"label\"] for dp in data[i][\"data\"]])) == len(\n data[i][\"data\"]\n ), \"Detected duplicate labels in the same series\"\n\n return type, data\n\n # retry because sometimes the page is not fully loaded\n @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))\n def _get_chart_by_title(\n self, page: playwright.sync_api.Page, title: str = None\n ) -> Tuple[str, dict]:\n \"\"\"\n Get the chart data by title\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n title: str\n The title of the chart to be read. If None, returns the first chart.\n\n Returns:\n --------\n chart_type: str\n The type of the chart\n chart_data: dict\n The data of the chart\n element_id: str\n The ID of the element that contains the chart\n\n \"\"\"\n # Get chart titles and element IDs\n charts = self._get_charts(page)\n\n if not title:\n title = charts[0][0]\n\n # Find chart index by title\n chart_idx = [title.lower() for title, _ in charts].index(title.lower())\n\n # Load chart data\n return *self._read_chart(page, element_id=charts[chart_idx][1]), charts[chart_idx][1]\n\n def _wait_for_ready(self, page: playwright.sync_api.Page) -> None:\n \"\"\"\n Wait for the page to be ready for task execution\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The page to wait on\n\n \"\"\"\n logging.debug(f\"Waiting for {self.iframe_id} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.iframe_id} !== 'undefined' && window.{self.iframe_id}.WORKARENA_LOAD_COMPLETE\",\n )\n logging.debug(f\"Detected {self.iframe_id} ready\")\n\n logging.debug(\"Waiting for Highcharts API to be available\")\n page.wait_for_function(f\"window.{self.iframe_id}.Highcharts\")\n logging.debug(\"Detected Highcharts API ready\")\n\n logging.debug(\"Waiting for all plots to be loaded available\")\n page.wait_for_function(f\"window.{self.iframe_id}.WORKARENA_HIGHCHARTS_ALL_LOADED\")\n logging.debug(\"All plots loaded\")\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded();\",\n f\"\"\"\n async function renderAllCharts() {{\n waLog('Forcing load of all charts', 'loadAllCharts');\n\n await waitForCondition(() => window.WORKARENA_LOAD_COMPLETE, 100);\n\n const canvas = window.SNC.canvas;\n if (canvas) {{\n waLog('This is a dashboard page.', 'loadAllCharts');\n // Trigger the rendering of each widget\n canvas.layoutJson.panes.forEach((p) => canvas.canvasUtils.renderSlowWidget(canvas.canvasUtils.getWidgetContainer(p.uuid)));\n // Wait for all widgets to be rendered\n await waitForCondition(() => window.SNC.canvas.layoutJson.panes.map((p) => p.isRendered).every(value => value == true), 100);\n }}\n else {{\n waLog('This is a report page.', 'loadAllCharts');\n // Wait for axes to be visible (we need to use this approach since there is no canvas to help us)\n await waitForCondition(() => document.body.innerText.toLowerCase().includes(\"no data to display\") || document.querySelectorAll(\".highcharts-point\").length > 0, 100);\n }}\n\n // Wait for Highcharts to say that the charts are rendered\n waitForCondition(() => Highcharts.charts.all((c) => c.hasLoaded), 100)\n .then(() => {{\n window.WORKARENA_HIGHCHARTS_ALL_LOADED = true;\n waLog('All charts loaded', 'loadAllCharts');\n }});\n }}\n // Run on both dashboard and reports pages\n runInGsftMainOnlyAndProtectByURL(renderAllCharts, 'pa_dashboard.do');\n runInGsftMainOnlyAndProtectByURL(renderAllCharts, 'sys_report_template.do');\n \"\"\",\n f\"\"\"\n function purifyReportUIButtons() {{\n // Delete a lot of UI features that were causing issues due to the report refreshing without\n // reloading the page. This makes the task easier, but it doesn't matter because we really\n // want to evaluate retrieval and this doesn't prevent that.\n document.querySelectorAll('[ng-click*=\"main.runReport\"], #sidebar, #nlq-over-cb, #open-tree-navigation-button, .data-filtering-wrap').forEach(element => {{\n if (element && element.parentNode) {{\n element.parentNode.removeChild(element);\n }}\n }});\n document.addEventListener('click', function(event) {{\n event.stopPropagation();\n event.preventDefault();\n }}, true);\n waLog('Purified report UI.', 'purifyReportUIButtons');\n }}\n // Run it only on the reports page\n runInGsftMainOnlyAndProtectByURL(purifyReportUIButtons, 'sys_report_template.do');\n \"\"\",\n ]\n\n def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:\n super().setup_goal(page=page)\n\n # Check that the report filters are properly setup\n if REPORT_DATE_FILTER is None or REPORT_TIME_FILTER is None:\n raise RuntimeError(\n \"The report date and time filters are not set. Please run the install script to set them.\"\n )\n\n # Configure task\n # ... sample a configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs())\n )\n # ... set start URL based on config\n # ...... some of the reports have need a date filter to be applied so we do this by patching a placeholder in the URL\n self.start_url = self.instance.snow_url + self.config[\"url\"].replace(\n \"REPORT_DATE_FILTER\", REPORT_DATE_FILTER\n ).replace(\"REPORT_TIME_FILTER\", REPORT_TIME_FILTER)\n\n # Produce goal string based on question type\n chart_locator = (\n f\"the \\\"{self.config['chart_series']}\\\" series of \"\n if self.config[\"chart_series\"]\n else \"\"\n ) + (\n f\"the \\\"{self.config['chart_title']}\\\" chart\"\n if self.config[\"chart_title\"]\n else \"the chart\"\n )\n if self.config[\"question\"].startswith(\"value\"):\n q_info = [x.strip() for x in self.config[\"question\"].split(\";\")]\n goal = f'What is the value of \"{q_info[2]}\" in {chart_locator} (in {q_info[1]})?'\n elif self.config[\"question\"] == \"max\":\n goal = f\"What is the maximum value in {chart_locator}? Give me both the label and the count. If there are many, pick one.\"\n elif self.config[\"question\"] == \"min\":\n goal = f\"What is the minimum value in {chart_locator}? Give me both the label and the count. If there are many, pick one.\"\n elif self.config[\"question\"] == \"mean\":\n goal = f\"What is the average value in {chart_locator}? Round off to the next highest integer.\"\n elif self.config[\"question\"] == \"median\":\n goal = f\"What is the median value in {chart_locator}?\"\n elif self.config[\"question\"] == \"mode\":\n goal = f\"What is the mode value in {chart_locator}?\"\n else:\n raise NotImplementedError(f\"Question type {self.config['question']} not supported\")\n\n return goal, {}\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n # Check if the page is the report list view. If so, open the report\n page_is_report_list_view = check_url_suffix_match(\n page, \"/now/nav/ui/classic/params/target/sys_report_list.do\", self\n )\n chart_title = self.config[\"chart_title\"]\n if page_is_report_list_view:\n # Open the report\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the report by title\n frame.get_by_label(\"Search a specific field of the Reports list\").select_option(\"Title\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(chart_title)\n search_input.press(\"Enter\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n # Click on the chart preview to open it\n frame.wait_for_selector(f'a[aria-label=\"Preview record: {chart_title}\"]').click()\n page.wait_for_timeout(1000)\n page.keyboard.press(\"Enter\")\n # Now in the form view, wait for the page to load and click to view the report\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n frame.get_by_text(\"View Report\").first.click()\n\n self._wait_for_ready(page)\n\n # Get the chart data\n chart_type, chart_data, chart_element_id = self._get_chart_by_title(\n page, self.config[\"chart_title\"]\n )\n\n # Extract the series\n if len(chart_data) == 1:\n chart_data = chart_data[0][\"data\"]\n else:\n chart_data = [\n series[\"data\"]\n for series in chart_data\n if series[\"name\"] == self.config[\"chart_series\"]\n ][0]\n\n # Scroll to the chart\n iframe = page.frame(name=self.iframe_id)\n iframe.evaluate_handle(\n f\"findElementInShadowDOM('#{chart_element_id}')\"\n ).scroll_into_view_if_needed()\n\n # Extract the value and add it to the chat\n if self.config[\"question\"].startswith(\"value\"):\n format = self.config[\"question\"].split(\";\")[1].strip()\n label = self.config[\"question\"].split(\";\")[2].strip()\n value = [\n point[\"count\" if format == \"count\" else \"percent\"]\n for point in chart_data\n if point[\"label\"] == label\n ][0]\n chat_messages.append({\"message\": str(value), \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"max\":\n max_point = max(chart_data, key=lambda x: x[\"count\"])\n chat_messages.append(\n {\"message\": f\"{max_point['label']}, {max_point['count']}\", \"role\": \"assistant\"}\n )\n elif self.config[\"question\"] == \"min\":\n min_point = min(chart_data, key=lambda x: x[\"count\"])\n chat_messages.append(\n {\"message\": f\"{min_point['label']}, {min_point['count']}\", \"role\": \"assistant\"}\n )\n elif self.config[\"question\"] == \"mean\":\n counts = [data[\"count\"] for data in chart_data]\n target_count = np.mean(counts)\n chat_messages.append({\"message\": f\"Mean / Average {target_count}\", \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"median\":\n counts = [data[\"count\"] for data in chart_data]\n target_count = np.median(counts)\n chat_messages.append({\"message\": f\"Median {target_count}\", \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"mode\":\n counts = [data[\"count\"] for data in chart_data]\n # We select the maximum value if there are two or more modes\n frequencies = {}\n for count in counts:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n target_count = max(max_frequencies)\n chat_messages.append({\"message\": f\"Mode {target_count}\", \"role\": \"assistant\"})\n else:\n raise NotImplementedError(f\"Question type \\\"{self.config['question']}\\\" not supported\")\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n # Check if the page is in the right URL\n logging.debug(\"Checking if the page is in the right URL to validate the task\")\n right_url = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n if not right_url:\n return (\n# ... truncated ...","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.DashboardRetrievalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.dashboard.DashboardRetrievalTask#L42-L770","kind":"class","name":"DashboardRetrievalTask","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":42,"end_line":770,"context_start_line":22,"context_end_line":790,"code":" REPORT_PATCH_FLAG,\n)\nfrom ..instance import SNowInstance\nfrom .utils.string import share_tri_gram\nfrom .utils.utils import check_url_suffix_match\n\n# XXX: Some notes on plot types\n# - We currently don't support maps because they are clickable and would require a more evolved cheat function\nSUPPORTED_PLOT_TYPES = [\"area\", \"bar\", \"column\", \"line\", \"pie\", \"spline\"]\n\n# Get report filter config\nconfig = SNowInstance().report_filter_config\nif config is None:\n REPORT_DATE_FILTER = REPORT_TIME_FILTER = None\nelse:\n REPORT_DATE_FILTER = config[\"report_date_filter\"]\n REPORT_TIME_FILTER = config[\"report_time_filter\"]\ndel config\n\n\nclass DashboardRetrievalTask(AbstractServiceNowTask, ABC):\n \"\"\"\n A task to retrieve information from a ServiceNow dashboard\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance: SNowInstance = None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"\")\n self.iframe_id = \"gsft_main\"\n self.fixed_config = fixed_config\n self.__dict__.update(kwargs)\n\n @abstractmethod\n def all_configs(self) -> List[dict]:\n pass\n\n @abstractmethod\n def all_configs(self) -> List[dict]:\n pass\n\n def _get_charts(self, page: playwright.sync_api.Page) -> None:\n \"\"\"\n Extract all charts on the page\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n\n Returns:\n --------\n charts: list\n A list of charts where the chart is represented as a tuple of the chart title and the id of the\n element that contains the chart.\n\n \"\"\"\n iframe = page.frame(name=self.iframe_id)\n\n charts = page.evaluate(\n f\"{self.iframe_id}.Highcharts.charts.map((x) => {{if(x){{return [x.renderTo.ariaLabel, x.renderTo.id];}}}})\"\n )\n charts = [\n (title.replace(\"Highcharts interactive chart.\", \"\").replace(\".\", \"\").strip(), id)\n for title, id in charts\n if title\n and iframe.locator(f\"#{id}\").count()\n > 0 # Check if the element is actually on page (sometime rendering breaks)\n ]\n\n return charts\n\n def _read_chart(self, page: playwright.sync_api.Page, element_id: str) -> str:\n \"\"\"\n Read the chart at the specified index\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n element_id: str\n The ID of the element that contains the chart\n\n Returns:\n --------\n chart_type: str\n The type of the chart\n chart_data: dict\n The data of the chart\n\n \"\"\"\n self._wait_for_ready(page)\n\n # Validate plot type\n types = page.evaluate(\n f\"{self.iframe_id}.Highcharts.charts.find(chart => chart && chart.renderTo.id === '{element_id}').types\"\n )\n if len(set(types)) > 1:\n raise NotImplementedError(\"Multiple chart types in the same chart not supported\")\n type = types[0]\n if type not in SUPPORTED_PLOT_TYPES:\n raise NotImplementedError(f\"Chart type {type} not supported\")\n\n # Get data\n data = page.evaluate(\n f\"\"\"\n {self.iframe_id}.Highcharts.charts.find(chart => chart && chart.renderTo.id === \"{element_id}\")\n .series.map(series => ({{\n name: series.name,\n data: series.data.map(\n point => ({{\n label_cat: point.category,\n label_name: point.name,\n label_origx: point.origXValue,\n count: point.y,\n percent: point.percent\n }}))\n }}));\n \"\"\"\n )\n\n # Post-process each series\n for i in range(len(data)):\n # For each data point in the series\n for j in range(len(data[i][\"data\"])):\n data_point = data[i][\"data\"][j]\n\n # Remove None percent values when count is 0\n if data_point[\"count\"] == 0:\n data_point[\"percent\"] = 0\n\n # Strip trailing spaces from labels\n data_point[\"label_cat\"] = (\n data_point[\"label_cat\"].strip() if data_point[\"label_cat\"] else \"\"\n )\n data_point[\"label_name\"] = (\n data_point[\"label_name\"].strip() if data_point[\"label_name\"] else \"\"\n )\n data_point[\"label_origx\"] = (\n data_point[\"label_origx\"].strip() if data_point[\"label_origx\"] else \"\"\n )\n\n # Determine which label to use (this is a heuristic)\n # Usually, when the origx value is present, it is more detailed than the other labels.\n # However, in some rare cases, it corresponds to some strange value that doesn't get rendered.\n # As a heuristic for the last point, let's just make sure that origx has at least a one trigram\n # overlap with any of the other labels.\n if data_point[\"label_origx\"] != \"\" and any(\n share_tri_gram(data_point[\"label_origx\"], data_point[x])\n for x in [\"label_cat\", \"label_name\"]\n ):\n data_point[\"label\"] = data_point[\"label_origx\"]\n else:\n if type in [\"bar\", \"column\", \"spline\"]:\n data_point[\"label\"] = data_point[\"label_cat\"]\n else:\n data_point[\"label\"] = data_point[\"label_name\"]\n del data_point[\"label_cat\"]\n del data_point[\"label_name\"]\n del data_point[\"label_origx\"]\n\n assert len(set([dp[\"label\"] for dp in data[i][\"data\"]])) == len(\n data[i][\"data\"]\n ), \"Detected duplicate labels in the same series\"\n\n return type, data\n\n # retry because sometimes the page is not fully loaded\n @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))\n def _get_chart_by_title(\n self, page: playwright.sync_api.Page, title: str = None\n ) -> Tuple[str, dict]:\n \"\"\"\n Get the chart data by title\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n title: str\n The title of the chart to be read. If None, returns the first chart.\n\n Returns:\n --------\n chart_type: str\n The type of the chart\n chart_data: dict\n The data of the chart\n element_id: str\n The ID of the element that contains the chart\n\n \"\"\"\n # Get chart titles and element IDs\n charts = self._get_charts(page)\n\n if not title:\n title = charts[0][0]\n\n # Find chart index by title\n chart_idx = [title.lower() for title, _ in charts].index(title.lower())\n\n # Load chart data\n return *self._read_chart(page, element_id=charts[chart_idx][1]), charts[chart_idx][1]\n\n def _wait_for_ready(self, page: playwright.sync_api.Page) -> None:\n \"\"\"\n Wait for the page to be ready for task execution\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The page to wait on\n\n \"\"\"\n logging.debug(f\"Waiting for {self.iframe_id} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.iframe_id} !== 'undefined' && window.{self.iframe_id}.WORKARENA_LOAD_COMPLETE\",\n )\n logging.debug(f\"Detected {self.iframe_id} ready\")\n\n logging.debug(\"Waiting for Highcharts API to be available\")\n page.wait_for_function(f\"window.{self.iframe_id}.Highcharts\")\n logging.debug(\"Detected Highcharts API ready\")\n\n logging.debug(\"Waiting for all plots to be loaded available\")\n page.wait_for_function(f\"window.{self.iframe_id}.WORKARENA_HIGHCHARTS_ALL_LOADED\")\n logging.debug(\"All plots loaded\")\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded();\",\n f\"\"\"\n async function renderAllCharts() {{\n waLog('Forcing load of all charts', 'loadAllCharts');\n\n await waitForCondition(() => window.WORKARENA_LOAD_COMPLETE, 100);\n\n const canvas = window.SNC.canvas;\n if (canvas) {{\n waLog('This is a dashboard page.', 'loadAllCharts');\n // Trigger the rendering of each widget\n canvas.layoutJson.panes.forEach((p) => canvas.canvasUtils.renderSlowWidget(canvas.canvasUtils.getWidgetContainer(p.uuid)));\n // Wait for all widgets to be rendered\n await waitForCondition(() => window.SNC.canvas.layoutJson.panes.map((p) => p.isRendered).every(value => value == true), 100);\n }}\n else {{\n waLog('This is a report page.', 'loadAllCharts');\n // Wait for axes to be visible (we need to use this approach since there is no canvas to help us)\n await waitForCondition(() => document.body.innerText.toLowerCase().includes(\"no data to display\") || document.querySelectorAll(\".highcharts-point\").length > 0, 100);\n }}\n\n // Wait for Highcharts to say that the charts are rendered\n waitForCondition(() => Highcharts.charts.all((c) => c.hasLoaded), 100)\n .then(() => {{\n window.WORKARENA_HIGHCHARTS_ALL_LOADED = true;\n waLog('All charts loaded', 'loadAllCharts');\n }});\n }}\n // Run on both dashboard and reports pages\n runInGsftMainOnlyAndProtectByURL(renderAllCharts, 'pa_dashboard.do');\n runInGsftMainOnlyAndProtectByURL(renderAllCharts, 'sys_report_template.do');\n \"\"\",\n f\"\"\"\n function purifyReportUIButtons() {{\n // Delete a lot of UI features that were causing issues due to the report refreshing without\n // reloading the page. This makes the task easier, but it doesn't matter because we really\n // want to evaluate retrieval and this doesn't prevent that.\n document.querySelectorAll('[ng-click*=\"main.runReport\"], #sidebar, #nlq-over-cb, #open-tree-navigation-button, .data-filtering-wrap').forEach(element => {{\n if (element && element.parentNode) {{\n element.parentNode.removeChild(element);\n }}\n }});\n document.addEventListener('click', function(event) {{\n event.stopPropagation();\n event.preventDefault();\n }}, true);\n waLog('Purified report UI.', 'purifyReportUIButtons');\n }}\n // Run it only on the reports page\n runInGsftMainOnlyAndProtectByURL(purifyReportUIButtons, 'sys_report_template.do');\n \"\"\",\n ]\n\n def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:\n super().setup_goal(page=page)\n\n # Check that the report filters are properly setup\n if REPORT_DATE_FILTER is None or REPORT_TIME_FILTER is None:\n raise RuntimeError(\n \"The report date and time filters are not set. Please run the install script to set them.\"\n )\n\n # Configure task\n # ... sample a configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs())\n )\n # ... set start URL based on config\n # ...... some of the reports have need a date filter to be applied so we do this by patching a placeholder in the URL\n self.start_url = self.instance.snow_url + self.config[\"url\"].replace(\n \"REPORT_DATE_FILTER\", REPORT_DATE_FILTER\n ).replace(\"REPORT_TIME_FILTER\", REPORT_TIME_FILTER)\n\n # Produce goal string based on question type\n chart_locator = (\n f\"the \\\"{self.config['chart_series']}\\\" series of \"\n if self.config[\"chart_series\"]\n else \"\"\n ) + (\n f\"the \\\"{self.config['chart_title']}\\\" chart\"\n if self.config[\"chart_title\"]\n else \"the chart\"\n )\n if self.config[\"question\"].startswith(\"value\"):\n q_info = [x.strip() for x in self.config[\"question\"].split(\";\")]\n goal = f'What is the value of \"{q_info[2]}\" in {chart_locator} (in {q_info[1]})?'\n elif self.config[\"question\"] == \"max\":\n goal = f\"What is the maximum value in {chart_locator}? Give me both the label and the count. If there are many, pick one.\"\n elif self.config[\"question\"] == \"min\":\n goal = f\"What is the minimum value in {chart_locator}? Give me both the label and the count. If there are many, pick one.\"\n elif self.config[\"question\"] == \"mean\":\n goal = f\"What is the average value in {chart_locator}? Round off to the next highest integer.\"\n elif self.config[\"question\"] == \"median\":\n goal = f\"What is the median value in {chart_locator}?\"\n elif self.config[\"question\"] == \"mode\":\n goal = f\"What is the mode value in {chart_locator}?\"\n else:\n raise NotImplementedError(f\"Question type {self.config['question']} not supported\")\n\n return goal, {}\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n # Check if the page is the report list view. If so, open the report\n page_is_report_list_view = check_url_suffix_match(\n page, \"/now/nav/ui/classic/params/target/sys_report_list.do\", self\n )\n chart_title = self.config[\"chart_title\"]\n if page_is_report_list_view:\n # Open the report\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the report by title\n frame.get_by_label(\"Search a specific field of the Reports list\").select_option(\"Title\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(chart_title)\n search_input.press(\"Enter\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n # Click on the chart preview to open it\n frame.wait_for_selector(f'a[aria-label=\"Preview record: {chart_title}\"]').click()\n page.wait_for_timeout(1000)\n page.keyboard.press(\"Enter\")\n # Now in the form view, wait for the page to load and click to view the report\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n frame.get_by_text(\"View Report\").first.click()\n\n self._wait_for_ready(page)\n\n # Get the chart data\n chart_type, chart_data, chart_element_id = self._get_chart_by_title(\n page, self.config[\"chart_title\"]\n )\n\n # Extract the series\n if len(chart_data) == 1:\n chart_data = chart_data[0][\"data\"]\n else:\n chart_data = [\n series[\"data\"]\n for series in chart_data\n if series[\"name\"] == self.config[\"chart_series\"]\n ][0]\n\n # Scroll to the chart\n iframe = page.frame(name=self.iframe_id)\n iframe.evaluate_handle(\n f\"findElementInShadowDOM('#{chart_element_id}')\"\n ).scroll_into_view_if_needed()\n\n # Extract the value and add it to the chat\n if self.config[\"question\"].startswith(\"value\"):\n format = self.config[\"question\"].split(\";\")[1].strip()\n label = self.config[\"question\"].split(\";\")[2].strip()\n value = [\n point[\"count\" if format == \"count\" else \"percent\"]\n for point in chart_data\n if point[\"label\"] == label\n ][0]\n chat_messages.append({\"message\": str(value), \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"max\":\n max_point = max(chart_data, key=lambda x: x[\"count\"])\n chat_messages.append(\n {\"message\": f\"{max_point['label']}, {max_point['count']}\", \"role\": \"assistant\"}\n )\n elif self.config[\"question\"] == \"min\":\n min_point = min(chart_data, key=lambda x: x[\"count\"])\n chat_messages.append(\n {\"message\": f\"{min_point['label']}, {min_point['count']}\", \"role\": \"assistant\"}\n )\n elif self.config[\"question\"] == \"mean\":\n counts = [data[\"count\"] for data in chart_data]\n target_count = np.mean(counts)\n chat_messages.append({\"message\": f\"Mean / Average {target_count}\", \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"median\":\n counts = [data[\"count\"] for data in chart_data]\n target_count = np.median(counts)\n chat_messages.append({\"message\": f\"Median {target_count}\", \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"mode\":\n counts = [data[\"count\"] for data in chart_data]\n # We select the maximum value if there are two or more modes\n frequencies = {}\n for count in counts:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n target_count = max(max_frequencies)\n chat_messages.append({\"message\": f\"Mode {target_count}\", \"role\": \"assistant\"})\n else:\n raise NotImplementedError(f\"Question type \\\"{self.config['question']}\\\" not supported\")\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n # Check if the page is in the right URL\n logging.debug(\"Checking if the page is in the right URL to validate the task\")\n right_url = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n\n self._wait_for_ready(page)\n\n # Get the chart data\n logging.debug(\"Extracting chart data\")\n _, chart_data, _ = self._get_chart_by_title(page, self.config[\"chart_title\"])\n\n # Extract the series\n logging.debug(\"Extracting the series\")\n if len(chart_data) == 1:\n chart_data = chart_data[0][\"data\"]\n else:\n chart_data = [\n series[\"data\"\n# ... truncated ...","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.MultiChartValueRetrievalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.dashboard.MultiChartValueRetrievalTask#L773-L775","kind":"class","name":"MultiChartValueRetrievalTask","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":773,"end_line":775,"context_start_line":753,"context_end_line":795,"code":" format = self.random.choice([\"count\", \"percent\"])\n\n # Select a random label from the chart data\n label = self.random.choice(labels)\n\n return {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": chart_series,\n \"question\": f\"{question}; {format}; {label}\",\n }\n else:\n return {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": chart_series,\n \"question\": question,\n }\n\n\nclass MultiChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass MultiChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMeanMedianModeRetrievalTask(\n DashboardRetrievalTask, CompositionalBuildingBlockTask\n):","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.MultiChartMinMaxRetrievalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.dashboard.MultiChartMinMaxRetrievalTask#L778-L780","kind":"class","name":"MultiChartMinMaxRetrievalTask","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":778,"end_line":780,"context_start_line":758,"context_end_line":800,"code":" return {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": chart_series,\n \"question\": f\"{question}; {format}; {label}\",\n }\n else:\n return {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": chart_series,\n \"question\": question,\n }\n\n\nclass MultiChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass MultiChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMeanMedianModeRetrievalTask(\n DashboardRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass WorkLoadBalancingMinMaxRetrievalTask(","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.SingleChartValueRetrievalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.dashboard.SingleChartValueRetrievalTask#L783-L785","kind":"class","name":"SingleChartValueRetrievalTask","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":783,"end_line":785,"context_start_line":763,"context_end_line":805,"code":" }\n else:\n return {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": chart_series,\n \"question\": question,\n }\n\n\nclass MultiChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass MultiChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMeanMedianModeRetrievalTask(\n DashboardRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass WorkLoadBalancingMinMaxRetrievalTask(\n SingleChartMinMaxRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.SingleChartMinMaxRetrievalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.dashboard.SingleChartMinMaxRetrievalTask#L788-L790","kind":"class","name":"SingleChartMinMaxRetrievalTask","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":788,"end_line":790,"context_start_line":768,"context_end_line":810,"code":" \"chart_series\": chart_series,\n \"question\": question,\n }\n\n\nclass MultiChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass MultiChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMeanMedianModeRetrievalTask(\n DashboardRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass WorkLoadBalancingMinMaxRetrievalTask(\n SingleChartMinMaxRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:\n super().setup_goal(page=page)\n\n # Configure task\n # ... sample a configuration","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.SingleChartMeanMedianModeRetrievalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.dashboard.SingleChartMeanMedianModeRetrievalTask#L793-L797","kind":"class","name":"SingleChartMeanMedianModeRetrievalTask","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":793,"end_line":797,"context_start_line":773,"context_end_line":817,"code":"class MultiChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass MultiChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMeanMedianModeRetrievalTask(\n DashboardRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass WorkLoadBalancingMinMaxRetrievalTask(\n SingleChartMinMaxRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:\n super().setup_goal(page=page)\n\n # Configure task\n # ... sample a configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs())\n )\n # ... set start URL based on config\n self.start_url = self.instance.snow_url + self.config[\"url\"]\n\n goal = f\"Create a filter to find reports whose title contains hashtag {self.problem_hashtag} and open the report.\"","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.WorkLoadBalancingMinMaxRetrievalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.dashboard.WorkLoadBalancingMinMaxRetrievalTask#L800-L820","kind":"class","name":"WorkLoadBalancingMinMaxRetrievalTask","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":800,"end_line":820,"context_start_line":780,"context_end_line":830,"code":" return json.load(open(DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMeanMedianModeRetrievalTask(\n DashboardRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass WorkLoadBalancingMinMaxRetrievalTask(\n SingleChartMinMaxRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:\n super().setup_goal(page=page)\n\n # Configure task\n # ... sample a configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs())\n )\n # ... set start URL based on config\n self.start_url = self.instance.snow_url + self.config[\"url\"]\n\n goal = f\"Create a filter to find reports whose title contains hashtag {self.problem_hashtag} and open the report.\"\n goal += \" From the report, identify the user with the most assigned problems and the user with the least assigned problems.\"\n\n return goal, {}\n\n\n__TASKS__ = [\n var\n for var in locals().values()\n if isinstance(var, type)\n and issubclass(var, DashboardRetrievalTask)\n and not issubclass(var, CompositionalBuildingBlockTask)\n and var is not DashboardRetrievalTask\n]","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard.__init__#L48-L54","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":48,"end_line":54,"context_start_line":28,"context_end_line":74,"code":"# XXX: Some notes on plot types\n# - We currently don't support maps because they are clickable and would require a more evolved cheat function\nSUPPORTED_PLOT_TYPES = [\"area\", \"bar\", \"column\", \"line\", \"pie\", \"spline\"]\n\n# Get report filter config\nconfig = SNowInstance().report_filter_config\nif config is None:\n REPORT_DATE_FILTER = REPORT_TIME_FILTER = None\nelse:\n REPORT_DATE_FILTER = config[\"report_date_filter\"]\n REPORT_TIME_FILTER = config[\"report_time_filter\"]\ndel config\n\n\nclass DashboardRetrievalTask(AbstractServiceNowTask, ABC):\n \"\"\"\n A task to retrieve information from a ServiceNow dashboard\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance: SNowInstance = None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"\")\n self.iframe_id = \"gsft_main\"\n self.fixed_config = fixed_config\n self.__dict__.update(kwargs)\n\n @abstractmethod\n def all_configs(self) -> List[dict]:\n pass\n\n @abstractmethod\n def all_configs(self) -> List[dict]:\n pass\n\n def _get_charts(self, page: playwright.sync_api.Page) -> None:\n \"\"\"\n Extract all charts on the page\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n\n Returns:\n --------","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.all_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard.all_configs#L803-L804","kind":"function","name":"all_configs","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":803,"end_line":804,"context_start_line":783,"context_end_line":824,"code":"class SingleChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMeanMedianModeRetrievalTask(\n DashboardRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass WorkLoadBalancingMinMaxRetrievalTask(\n SingleChartMinMaxRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:\n super().setup_goal(page=page)\n\n # Configure task\n # ... sample a configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs())\n )\n # ... set start URL based on config\n self.start_url = self.instance.snow_url + self.config[\"url\"]\n\n goal = f\"Create a filter to find reports whose title contains hashtag {self.problem_hashtag} and open the report.\"\n goal += \" From the report, identify the user with the most assigned problems and the user with the least assigned problems.\"\n\n return goal, {}\n\n\n__TASKS__ = [\n var","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard._get_charts","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard._get_charts#L64-L93","kind":"function","name":"_get_charts","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":64,"end_line":93,"context_start_line":44,"context_end_line":113,"code":" A task to retrieve information from a ServiceNow dashboard\n\n \"\"\"\n\n def __init__(\n self, seed: int = None, instance: SNowInstance = None, fixed_config: dict = None, **kwargs\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=\"\")\n self.iframe_id = \"gsft_main\"\n self.fixed_config = fixed_config\n self.__dict__.update(kwargs)\n\n @abstractmethod\n def all_configs(self) -> List[dict]:\n pass\n\n @abstractmethod\n def all_configs(self) -> List[dict]:\n pass\n\n def _get_charts(self, page: playwright.sync_api.Page) -> None:\n \"\"\"\n Extract all charts on the page\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n\n Returns:\n --------\n charts: list\n A list of charts where the chart is represented as a tuple of the chart title and the id of the\n element that contains the chart.\n\n \"\"\"\n iframe = page.frame(name=self.iframe_id)\n\n charts = page.evaluate(\n f\"{self.iframe_id}.Highcharts.charts.map((x) => {{if(x){{return [x.renderTo.ariaLabel, x.renderTo.id];}}}})\"\n )\n charts = [\n (title.replace(\"Highcharts interactive chart.\", \"\").replace(\".\", \"\").strip(), id)\n for title, id in charts\n if title\n and iframe.locator(f\"#{id}\").count()\n > 0 # Check if the element is actually on page (sometime rendering breaks)\n ]\n\n return charts\n\n def _read_chart(self, page: playwright.sync_api.Page, element_id: str) -> str:\n \"\"\"\n Read the chart at the specified index\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n element_id: str\n The ID of the element that contains the chart\n\n Returns:\n --------\n chart_type: str\n The type of the chart\n chart_data: dict\n The data of the chart\n\n \"\"\"","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard._read_chart","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard._read_chart#L95-L188","kind":"function","name":"_read_chart","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":95,"end_line":188,"context_start_line":75,"context_end_line":208,"code":" charts: list\n A list of charts where the chart is represented as a tuple of the chart title and the id of the\n element that contains the chart.\n\n \"\"\"\n iframe = page.frame(name=self.iframe_id)\n\n charts = page.evaluate(\n f\"{self.iframe_id}.Highcharts.charts.map((x) => {{if(x){{return [x.renderTo.ariaLabel, x.renderTo.id];}}}})\"\n )\n charts = [\n (title.replace(\"Highcharts interactive chart.\", \"\").replace(\".\", \"\").strip(), id)\n for title, id in charts\n if title\n and iframe.locator(f\"#{id}\").count()\n > 0 # Check if the element is actually on page (sometime rendering breaks)\n ]\n\n return charts\n\n def _read_chart(self, page: playwright.sync_api.Page, element_id: str) -> str:\n \"\"\"\n Read the chart at the specified index\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n element_id: str\n The ID of the element that contains the chart\n\n Returns:\n --------\n chart_type: str\n The type of the chart\n chart_data: dict\n The data of the chart\n\n \"\"\"\n self._wait_for_ready(page)\n\n # Validate plot type\n types = page.evaluate(\n f\"{self.iframe_id}.Highcharts.charts.find(chart => chart && chart.renderTo.id === '{element_id}').types\"\n )\n if len(set(types)) > 1:\n raise NotImplementedError(\"Multiple chart types in the same chart not supported\")\n type = types[0]\n if type not in SUPPORTED_PLOT_TYPES:\n raise NotImplementedError(f\"Chart type {type} not supported\")\n\n # Get data\n data = page.evaluate(\n f\"\"\"\n {self.iframe_id}.Highcharts.charts.find(chart => chart && chart.renderTo.id === \"{element_id}\")\n .series.map(series => ({{\n name: series.name,\n data: series.data.map(\n point => ({{\n label_cat: point.category,\n label_name: point.name,\n label_origx: point.origXValue,\n count: point.y,\n percent: point.percent\n }}))\n }}));\n \"\"\"\n )\n\n # Post-process each series\n for i in range(len(data)):\n # For each data point in the series\n for j in range(len(data[i][\"data\"])):\n data_point = data[i][\"data\"][j]\n\n # Remove None percent values when count is 0\n if data_point[\"count\"] == 0:\n data_point[\"percent\"] = 0\n\n # Strip trailing spaces from labels\n data_point[\"label_cat\"] = (\n data_point[\"label_cat\"].strip() if data_point[\"label_cat\"] else \"\"\n )\n data_point[\"label_name\"] = (\n data_point[\"label_name\"].strip() if data_point[\"label_name\"] else \"\"\n )\n data_point[\"label_origx\"] = (\n data_point[\"label_origx\"].strip() if data_point[\"label_origx\"] else \"\"\n )\n\n # Determine which label to use (this is a heuristic)\n # Usually, when the origx value is present, it is more detailed than the other labels.\n # However, in some rare cases, it corresponds to some strange value that doesn't get rendered.\n # As a heuristic for the last point, let's just make sure that origx has at least a one trigram\n # overlap with any of the other labels.\n if data_point[\"label_origx\"] != \"\" and any(\n share_tri_gram(data_point[\"label_origx\"], data_point[x])\n for x in [\"label_cat\", \"label_name\"]\n ):\n data_point[\"label\"] = data_point[\"label_origx\"]\n else:\n if type in [\"bar\", \"column\", \"spline\"]:\n data_point[\"label\"] = data_point[\"label_cat\"]\n else:\n data_point[\"label\"] = data_point[\"label_name\"]\n del data_point[\"label_cat\"]\n del data_point[\"label_name\"]\n del data_point[\"label_origx\"]\n\n assert len(set([dp[\"label\"] for dp in data[i][\"data\"]])) == len(\n data[i][\"data\"]\n ), \"Detected duplicate labels in the same series\"\n\n return type, data\n\n # retry because sometimes the page is not fully loaded\n @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))\n def _get_chart_by_title(\n self, page: playwright.sync_api.Page, title: str = None\n ) -> Tuple[str, dict]:\n \"\"\"\n Get the chart data by title\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n title: str\n The title of the chart to be read. If None, returns the first chart.\n\n Returns:\n --------\n chart_type: str\n The type of the chart","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard._get_chart_by_title","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard._get_chart_by_title#L192-L225","kind":"function","name":"_get_chart_by_title","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":192,"end_line":225,"context_start_line":172,"context_end_line":245,"code":" for x in [\"label_cat\", \"label_name\"]\n ):\n data_point[\"label\"] = data_point[\"label_origx\"]\n else:\n if type in [\"bar\", \"column\", \"spline\"]:\n data_point[\"label\"] = data_point[\"label_cat\"]\n else:\n data_point[\"label\"] = data_point[\"label_name\"]\n del data_point[\"label_cat\"]\n del data_point[\"label_name\"]\n del data_point[\"label_origx\"]\n\n assert len(set([dp[\"label\"] for dp in data[i][\"data\"]])) == len(\n data[i][\"data\"]\n ), \"Detected duplicate labels in the same series\"\n\n return type, data\n\n # retry because sometimes the page is not fully loaded\n @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))\n def _get_chart_by_title(\n self, page: playwright.sync_api.Page, title: str = None\n ) -> Tuple[str, dict]:\n \"\"\"\n Get the chart data by title\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The playright page on which the charts are to be extracted\n title: str\n The title of the chart to be read. If None, returns the first chart.\n\n Returns:\n --------\n chart_type: str\n The type of the chart\n chart_data: dict\n The data of the chart\n element_id: str\n The ID of the element that contains the chart\n\n \"\"\"\n # Get chart titles and element IDs\n charts = self._get_charts(page)\n\n if not title:\n title = charts[0][0]\n\n # Find chart index by title\n chart_idx = [title.lower() for title, _ in charts].index(title.lower())\n\n # Load chart data\n return *self._read_chart(page, element_id=charts[chart_idx][1]), charts[chart_idx][1]\n\n def _wait_for_ready(self, page: playwright.sync_api.Page) -> None:\n \"\"\"\n Wait for the page to be ready for task execution\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The page to wait on\n\n \"\"\"\n logging.debug(f\"Waiting for {self.iframe_id} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.iframe_id} !== 'undefined' && window.{self.iframe_id}.WORKARENA_LOAD_COMPLETE\",\n )\n logging.debug(f\"Detected {self.iframe_id} ready\")\n\n logging.debug(\"Waiting for Highcharts API to be available\")\n page.wait_for_function(f\"window.{self.iframe_id}.Highcharts\")\n logging.debug(\"Detected Highcharts API ready\")","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard._wait_for_ready","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard._wait_for_ready#L227-L249","kind":"function","name":"_wait_for_ready","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":227,"end_line":249,"context_start_line":207,"context_end_line":269,"code":" chart_type: str\n The type of the chart\n chart_data: dict\n The data of the chart\n element_id: str\n The ID of the element that contains the chart\n\n \"\"\"\n # Get chart titles and element IDs\n charts = self._get_charts(page)\n\n if not title:\n title = charts[0][0]\n\n # Find chart index by title\n chart_idx = [title.lower() for title, _ in charts].index(title.lower())\n\n # Load chart data\n return *self._read_chart(page, element_id=charts[chart_idx][1]), charts[chart_idx][1]\n\n def _wait_for_ready(self, page: playwright.sync_api.Page) -> None:\n \"\"\"\n Wait for the page to be ready for task execution\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The page to wait on\n\n \"\"\"\n logging.debug(f\"Waiting for {self.iframe_id} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.iframe_id} !== 'undefined' && window.{self.iframe_id}.WORKARENA_LOAD_COMPLETE\",\n )\n logging.debug(f\"Detected {self.iframe_id} ready\")\n\n logging.debug(\"Waiting for Highcharts API to be available\")\n page.wait_for_function(f\"window.{self.iframe_id}.Highcharts\")\n logging.debug(\"Detected Highcharts API ready\")\n\n logging.debug(\"Waiting for all plots to be loaded available\")\n page.wait_for_function(f\"window.{self.iframe_id}.WORKARENA_HIGHCHARTS_ALL_LOADED\")\n logging.debug(\"All plots loaded\")\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded();\",\n f\"\"\"\n async function renderAllCharts() {{\n waLog('Forcing load of all charts', 'loadAllCharts');\n\n await waitForCondition(() => window.WORKARENA_LOAD_COMPLETE, 100);\n\n const canvas = window.SNC.canvas;\n if (canvas) {{\n waLog('This is a dashboard page.', 'loadAllCharts');\n // Trigger the rendering of each widget\n canvas.layoutJson.panes.forEach((p) => canvas.canvasUtils.renderSlowWidget(canvas.canvasUtils.getWidgetContainer(p.uuid)));\n // Wait for all widgets to be rendered\n await waitForCondition(() => window.SNC.canvas.layoutJson.panes.map((p) => p.isRendered).every(value => value == true), 100);\n }}\n else {{\n waLog('This is a report page.', 'loadAllCharts');","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.get_init_scripts","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard.get_init_scripts#L251-L304","kind":"function","name":"get_init_scripts","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":251,"end_line":304,"context_start_line":231,"context_end_line":324,"code":" Parameters:\n -----------\n page: playwright.sync_api.Page\n The page to wait on\n\n \"\"\"\n logging.debug(f\"Waiting for {self.iframe_id} to be fully loaded\")\n page.wait_for_function(\n f\"typeof window.{self.iframe_id} !== 'undefined' && window.{self.iframe_id}.WORKARENA_LOAD_COMPLETE\",\n )\n logging.debug(f\"Detected {self.iframe_id} ready\")\n\n logging.debug(\"Waiting for Highcharts API to be available\")\n page.wait_for_function(f\"window.{self.iframe_id}.Highcharts\")\n logging.debug(\"Detected Highcharts API ready\")\n\n logging.debug(\"Waiting for all plots to be loaded available\")\n page.wait_for_function(f\"window.{self.iframe_id}.WORKARENA_HIGHCHARTS_ALL_LOADED\")\n logging.debug(\"All plots loaded\")\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\n \"registerGsftMainLoaded();\",\n f\"\"\"\n async function renderAllCharts() {{\n waLog('Forcing load of all charts', 'loadAllCharts');\n\n await waitForCondition(() => window.WORKARENA_LOAD_COMPLETE, 100);\n\n const canvas = window.SNC.canvas;\n if (canvas) {{\n waLog('This is a dashboard page.', 'loadAllCharts');\n // Trigger the rendering of each widget\n canvas.layoutJson.panes.forEach((p) => canvas.canvasUtils.renderSlowWidget(canvas.canvasUtils.getWidgetContainer(p.uuid)));\n // Wait for all widgets to be rendered\n await waitForCondition(() => window.SNC.canvas.layoutJson.panes.map((p) => p.isRendered).every(value => value == true), 100);\n }}\n else {{\n waLog('This is a report page.', 'loadAllCharts');\n // Wait for axes to be visible (we need to use this approach since there is no canvas to help us)\n await waitForCondition(() => document.body.innerText.toLowerCase().includes(\"no data to display\") || document.querySelectorAll(\".highcharts-point\").length > 0, 100);\n }}\n\n // Wait for Highcharts to say that the charts are rendered\n waitForCondition(() => Highcharts.charts.all((c) => c.hasLoaded), 100)\n .then(() => {{\n window.WORKARENA_HIGHCHARTS_ALL_LOADED = true;\n waLog('All charts loaded', 'loadAllCharts');\n }});\n }}\n // Run on both dashboard and reports pages\n runInGsftMainOnlyAndProtectByURL(renderAllCharts, 'pa_dashboard.do');\n runInGsftMainOnlyAndProtectByURL(renderAllCharts, 'sys_report_template.do');\n \"\"\",\n f\"\"\"\n function purifyReportUIButtons() {{\n // Delete a lot of UI features that were causing issues due to the report refreshing without\n // reloading the page. This makes the task easier, but it doesn't matter because we really\n // want to evaluate retrieval and this doesn't prevent that.\n document.querySelectorAll('[ng-click*=\"main.runReport\"], #sidebar, #nlq-over-cb, #open-tree-navigation-button, .data-filtering-wrap').forEach(element => {{\n if (element && element.parentNode) {{\n element.parentNode.removeChild(element);\n }}\n }});\n document.addEventListener('click', function(event) {{\n event.stopPropagation();\n event.preventDefault();\n }}, true);\n waLog('Purified report UI.', 'purifyReportUIButtons');\n }}\n // Run it only on the reports page\n runInGsftMainOnlyAndProtectByURL(purifyReportUIButtons, 'sys_report_template.do');\n \"\"\",\n ]\n\n def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:\n super().setup_goal(page=page)\n\n # Check that the report filters are properly setup\n if REPORT_DATE_FILTER is None or REPORT_TIME_FILTER is None:\n raise RuntimeError(\n \"The report date and time filters are not set. Please run the install script to set them.\"\n )\n\n # Configure task\n # ... sample a configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs())\n )\n # ... set start URL based on config\n # ...... some of the reports have need a date filter to be applied so we do this by patching a placeholder in the URL\n self.start_url = self.instance.snow_url + self.config[\"url\"].replace(\n \"REPORT_DATE_FILTER\", REPORT_DATE_FILTER\n ).replace(\"REPORT_TIME_FILTER\", REPORT_TIME_FILTER)","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard.setup_goal#L806-L820","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":806,"end_line":820,"context_start_line":786,"context_end_line":830,"code":"\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMeanMedianModeRetrievalTask(\n DashboardRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass WorkLoadBalancingMinMaxRetrievalTask(\n SingleChartMinMaxRetrievalTask, CompositionalBuildingBlockTask\n):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:\n super().setup_goal(page=page)\n\n # Configure task\n # ... sample a configuration\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs())\n )\n # ... set start URL based on config\n self.start_url = self.instance.snow_url + self.config[\"url\"]\n\n goal = f\"Create a filter to find reports whose title contains hashtag {self.problem_hashtag} and open the report.\"\n goal += \" From the report, identify the user with the most assigned problems and the user with the least assigned problems.\"\n\n return goal, {}\n\n\n__TASKS__ = [\n var\n for var in locals().values()\n if isinstance(var, type)\n and issubclass(var, DashboardRetrievalTask)\n and not issubclass(var, CompositionalBuildingBlockTask)\n and var is not DashboardRetrievalTask\n]","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard.cheat#L354-L459","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":354,"end_line":459,"context_start_line":334,"context_end_line":479,"code":" else \"the chart\"\n )\n if self.config[\"question\"].startswith(\"value\"):\n q_info = [x.strip() for x in self.config[\"question\"].split(\";\")]\n goal = f'What is the value of \"{q_info[2]}\" in {chart_locator} (in {q_info[1]})?'\n elif self.config[\"question\"] == \"max\":\n goal = f\"What is the maximum value in {chart_locator}? Give me both the label and the count. If there are many, pick one.\"\n elif self.config[\"question\"] == \"min\":\n goal = f\"What is the minimum value in {chart_locator}? Give me both the label and the count. If there are many, pick one.\"\n elif self.config[\"question\"] == \"mean\":\n goal = f\"What is the average value in {chart_locator}? Round off to the next highest integer.\"\n elif self.config[\"question\"] == \"median\":\n goal = f\"What is the median value in {chart_locator}?\"\n elif self.config[\"question\"] == \"mode\":\n goal = f\"What is the mode value in {chart_locator}?\"\n else:\n raise NotImplementedError(f\"Question type {self.config['question']} not supported\")\n\n return goal, {}\n\n def cheat(self, page: playwright.sync_api.Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n # Check if the page is the report list view. If so, open the report\n page_is_report_list_view = check_url_suffix_match(\n page, \"/now/nav/ui/classic/params/target/sys_report_list.do\", self\n )\n chart_title = self.config[\"chart_title\"]\n if page_is_report_list_view:\n # Open the report\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the report by title\n frame.get_by_label(\"Search a specific field of the Reports list\").select_option(\"Title\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(chart_title)\n search_input.press(\"Enter\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n # Click on the chart preview to open it\n frame.wait_for_selector(f'a[aria-label=\"Preview record: {chart_title}\"]').click()\n page.wait_for_timeout(1000)\n page.keyboard.press(\"Enter\")\n # Now in the form view, wait for the page to load and click to view the report\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n frame.get_by_text(\"View Report\").first.click()\n\n self._wait_for_ready(page)\n\n # Get the chart data\n chart_type, chart_data, chart_element_id = self._get_chart_by_title(\n page, self.config[\"chart_title\"]\n )\n\n # Extract the series\n if len(chart_data) == 1:\n chart_data = chart_data[0][\"data\"]\n else:\n chart_data = [\n series[\"data\"]\n for series in chart_data\n if series[\"name\"] == self.config[\"chart_series\"]\n ][0]\n\n # Scroll to the chart\n iframe = page.frame(name=self.iframe_id)\n iframe.evaluate_handle(\n f\"findElementInShadowDOM('#{chart_element_id}')\"\n ).scroll_into_view_if_needed()\n\n # Extract the value and add it to the chat\n if self.config[\"question\"].startswith(\"value\"):\n format = self.config[\"question\"].split(\";\")[1].strip()\n label = self.config[\"question\"].split(\";\")[2].strip()\n value = [\n point[\"count\" if format == \"count\" else \"percent\"]\n for point in chart_data\n if point[\"label\"] == label\n ][0]\n chat_messages.append({\"message\": str(value), \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"max\":\n max_point = max(chart_data, key=lambda x: x[\"count\"])\n chat_messages.append(\n {\"message\": f\"{max_point['label']}, {max_point['count']}\", \"role\": \"assistant\"}\n )\n elif self.config[\"question\"] == \"min\":\n min_point = min(chart_data, key=lambda x: x[\"count\"])\n chat_messages.append(\n {\"message\": f\"{min_point['label']}, {min_point['count']}\", \"role\": \"assistant\"}\n )\n elif self.config[\"question\"] == \"mean\":\n counts = [data[\"count\"] for data in chart_data]\n target_count = np.mean(counts)\n chat_messages.append({\"message\": f\"Mean / Average {target_count}\", \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"median\":\n counts = [data[\"count\"] for data in chart_data]\n target_count = np.median(counts)\n chat_messages.append({\"message\": f\"Median {target_count}\", \"role\": \"assistant\"})\n elif self.config[\"question\"] == \"mode\":\n counts = [data[\"count\"] for data in chart_data]\n # We select the maximum value if there are two or more modes\n frequencies = {}\n for count in counts:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n target_count = max(max_frequencies)\n chat_messages.append({\"message\": f\"Mode {target_count}\", \"role\": \"assistant\"})\n else:\n raise NotImplementedError(f\"Question type \\\"{self.config['question']}\\\" not supported\")\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n # Check if the page is in the right URL\n logging.debug(\"Checking if the page is in the right URL to validate the task\")\n right_url = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n\n self._wait_for_ready(page)","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard.validate#L461-L612","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":461,"end_line":612,"context_start_line":441,"context_end_line":632,"code":" frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n target_count = max(max_frequencies)\n chat_messages.append({\"message\": f\"Mode {target_count}\", \"role\": \"assistant\"})\n else:\n raise NotImplementedError(f\"Question type \\\"{self.config['question']}\\\" not supported\")\n\n def validate(\n self, page: playwright.sync_api.Page, chat_messages: list[str]\n ) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n # Check if the page is in the right URL\n logging.debug(\"Checking if the page is in the right URL to validate the task\")\n right_url = check_url_suffix_match(page, expected_url=self.start_url, task=self)\n if not right_url:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The page is not in the right URL to validate task {self.__class__.__name__}.\"\n },\n )\n\n self._wait_for_ready(page)\n\n # Get the chart data\n logging.debug(\"Extracting chart data\")\n _, chart_data, _ = self._get_chart_by_title(page, self.config[\"chart_title\"])\n\n # Extract the series\n logging.debug(\"Extracting the series\")\n if len(chart_data) == 1:\n chart_data = chart_data[0][\"data\"]\n else:\n chart_data = [\n series[\"data\"]\n for series in chart_data\n if series[\"name\"] == self.config[\"chart_series\"]\n ][0]\n\n # Extract the agent's response\n logging.debug(\"Extracting the agent's response\")\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n response = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n\n # Extract all numbers mentioned by the agent\n logging.debug(\"Extracting all numbers mentioned by the agent\")\n # ... some value labels may contain numbers so we need to remove the labels from the response first\n labels = set([point[\"label\"] for point in chart_data])\n response_ = str(response)\n for label in labels:\n response_ = response_.replace(label, \"\")\n # ... then we extract numbers\n response_floats = np.unique(\n [float(x) for x in re.findall(r\"[\\d]+(?:[.,]\\d+)?\", response_.replace(\",\", \"\"))]\n )\n del response_\n\n if len(response_floats) == 0:\n return (\n 0.0,\n False,\n \"No number detected in the response.\",\n {\"message\": \"No number detected in the response.\"},\n )\n\n # Validate the response\n logging.debug(\"Validating the response based on the question type\")\n if self.config[\"question\"].startswith(\"value\"):\n logging.debug(\"The question is a value question\")\n # if more than one number is in the prompt, there is necessarily a false positive\n if len(response_floats) > 1:\n error_msg = \"Incorrect answer. More than one number detected in the response.\"\n return 0.0, True, error_msg, {\"message\": error_msg}\n\n logging.debug(\n f\"Extracting expected format and label from question for validation: {self.config['question']}\"\n )\n format = self.config[\"question\"].split(\";\")[1].strip()\n label = self.config[\"question\"].split(\";\")[2].strip()\n logging.debug(f\"Extracted format: {format}, label: {label}\")\n\n expected_value = float(\n [\n point[\"count\" if format == \"count\" else \"percent\"]\n for point in chart_data\n if point[\"label\"] == label\n ][0]\n )\n if np.isclose(expected_value, response_floats[0]):\n return 1.0, True, \"Nice work, thank you!\", {\"message\": \"Correct answer.\"}\n else:\n return 0.0, True, f\"Incorrect answer.\", {\"message\": \"Incorrect answer.\"}\n\n # ... validate max/min responses\n elif \"max\" in self.config[\"question\"] or \"min\" in self.config[\"question\"]:\n # Determine whether to find max or min based on configuration\n target_func = max if self.config[\"question\"] == \"max\" else min\n logging.debug(f\"The question is a {str(target_func)} question\")\n\n # Get the target count value (max or min)\n target_count = float(target_func(chart_data, key=lambda x: x[\"count\"])[\"count\"])\n\n # Find all points with the target count value\n target_points = [point for point in chart_data if point[\"count\"] == target_count]\n\n # if more than one number is in the prompt, there is necessarily a false positive\n if len(response_floats) > 1:\n error_msg = \"Incorrect answer. More than one number detected in the response.\"\n return 0.0, True, error_msg, {\"message\": error_msg}\n\n # Check if any of these points are mentioned in the response\n for point in target_points:\n if point[\"label\"].lower() in response.lower() and np.isclose(\n target_count, response_floats[0]\n ):\n return 1.0, True, \"Nice work, thank you!\", {\"message\": \"Correct answer.\"}\n\n # If no correct point is mentioned in the response\n return 0.0, True, \"Incorrect answer.\", {\"message\": \"Incorrect answer.\"}\n # ... validate mean/median/mode responses\n elif (\n \"mean\" in self.config[\"question\"]\n or \"median\" in self.config[\"question\"]\n or \"mode\" in self.config[\"question\"]\n ):\n counts = [data[\"count\"] for data in chart_data]\n if self.config[\"question\"] == \"mean\":\n target_count = np.mean(counts)\n elif self.config[\"question\"] == \"median\":\n target_count = np.median(counts)\n elif self.config[\"question\"] == \"mode\":\n _vals, _counts = np.unique(counts, return_counts=True)\n max_frequency_index = np.argmax(_counts)\n target_count = -_vals[max_frequency_index]\n\n # if more than one number is in the prompt, there is necessarily a false positive\n if len(response_floats) > 1:\n error_msg = \"Incorrect answer. More than one number detected in the response.\"\n return 0.0, True, error_msg, {\"message\": error_msg}\n\n # Check if any of these points are mentioned in the response\n if np.isclose(target_count, response_floats[0]):\n return 1.0, True, \"Nice work, thank you!\", {\"message\": \"Correct answer.\"}\n\n # If no correct point is mentioned in the response\n return 0.0, True, \"Incorrect answer.\", {\"message\": \"Incorrect answer.\"}\n\n else:\n raise NotImplementedError(f\"Question type \\\"{self.config['question']}\\\" not supported\")\n\n def teardown(self) -> None:\n return super().teardown()\n\n def _generate_random_config(\n self, page: playwright.sync_api.Page, is_report=True, question_types=[\"value\"]\n ) -> dict:\n \"\"\"\n Generate a random configuration for the task\n\n This can be used to regenerate configs that are valid under an updated date filter.\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The page on which the task is to be executed\n is_report: bool\n Whether to sample a report or a dashboard task configuration\n question_types: list\n The types of questions to sample from (uniformely)","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard.teardown#L614-L615","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":614,"end_line":615,"context_start_line":594,"context_end_line":635,"code":" elif self.config[\"question\"] == \"mode\":\n _vals, _counts = np.unique(counts, return_counts=True)\n max_frequency_index = np.argmax(_counts)\n target_count = -_vals[max_frequency_index]\n\n # if more than one number is in the prompt, there is necessarily a false positive\n if len(response_floats) > 1:\n error_msg = \"Incorrect answer. More than one number detected in the response.\"\n return 0.0, True, error_msg, {\"message\": error_msg}\n\n # Check if any of these points are mentioned in the response\n if np.isclose(target_count, response_floats[0]):\n return 1.0, True, \"Nice work, thank you!\", {\"message\": \"Correct answer.\"}\n\n # If no correct point is mentioned in the response\n return 0.0, True, \"Incorrect answer.\", {\"message\": \"Incorrect answer.\"}\n\n else:\n raise NotImplementedError(f\"Question type \\\"{self.config['question']}\\\" not supported\")\n\n def teardown(self) -> None:\n return super().teardown()\n\n def _generate_random_config(\n self, page: playwright.sync_api.Page, is_report=True, question_types=[\"value\"]\n ) -> dict:\n \"\"\"\n Generate a random configuration for the task\n\n This can be used to regenerate configs that are valid under an updated date filter.\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The page on which the task is to be executed\n is_report: bool\n Whether to sample a report or a dashboard task configuration\n question_types: list\n The types of questions to sample from (uniformely)\n\n \"\"\"\n # Check that the report filters are properly setup","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.dashboard._generate_random_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.dashboard._generate_random_config#L617-L770","kind":"function","name":"_generate_random_config","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":617,"end_line":770,"context_start_line":597,"context_end_line":790,"code":" target_count = -_vals[max_frequency_index]\n\n # if more than one number is in the prompt, there is necessarily a false positive\n if len(response_floats) > 1:\n error_msg = \"Incorrect answer. More than one number detected in the response.\"\n return 0.0, True, error_msg, {\"message\": error_msg}\n\n # Check if any of these points are mentioned in the response\n if np.isclose(target_count, response_floats[0]):\n return 1.0, True, \"Nice work, thank you!\", {\"message\": \"Correct answer.\"}\n\n # If no correct point is mentioned in the response\n return 0.0, True, \"Incorrect answer.\", {\"message\": \"Incorrect answer.\"}\n\n else:\n raise NotImplementedError(f\"Question type \\\"{self.config['question']}\\\" not supported\")\n\n def teardown(self) -> None:\n return super().teardown()\n\n def _generate_random_config(\n self, page: playwright.sync_api.Page, is_report=True, question_types=[\"value\"]\n ) -> dict:\n \"\"\"\n Generate a random configuration for the task\n\n This can be used to regenerate configs that are valid under an updated date filter.\n\n Parameters:\n -----------\n page: playwright.sync_api.Page\n The page on which the task is to be executed\n is_report: bool\n Whether to sample a report or a dashboard task configuration\n question_types: list\n The types of questions to sample from (uniformely)\n\n \"\"\"\n # Check that the report filters are properly setup\n if REPORT_DATE_FILTER is None or REPORT_TIME_FILTER is None:\n raise RuntimeError(\n \"The report date and time filters are not set. Please run the install script to set them.\"\n )\n\n # Generate a bunch of reports based on valid table fields\n ON_THE_FLY_REPORTS = []\n for table in [\n \"alm_asset\",\n \"alm_hardware\",\n \"asmt_assessment_instance_question\",\n \"asmt_m2m_stakeholder\",\n \"ast_contract\",\n \"change_request\",\n \"cmdb_ci_computer\",\n \"incident\",\n \"sc_cat_item\",\n \"sys_user\",\n ]:\n cols = [\n x\n for x, y in table_column_info(instance=self.instance, table=table).items()\n if y.get(\"cangroup\", False)\n and y.get(\"type\", None) == \"choice\"\n and \"upon\" not in x.lower()\n ]\n for col in cols:\n ON_THE_FLY_REPORTS.append({\"table\": table, \"field\": col, \"type\": \"pie\"})\n ON_THE_FLY_REPORTS.append({\"table\": table, \"field\": col, \"type\": \"bar\"})\n\n # Reports that are already in the instance\n system_report_tables = \"alm_asset,alm_hardware,asmt_assessment_instance_question,asmt_m2m_stakeholder,ast_contract,change_request,cmdb_ci_computer\"\n SYSTEM_REPORTS = table_api_call(\n instance=self.instance,\n table=\"sys_report\",\n params={\n \"sysparm_query\": f\"sys_class_name=sys_report^active=true^typeINtrend,donut,vertical_bar,line,horizontal_bar,pie,bar,spline,area^descriptionLIKE{REPORT_PATCH_FLAG}^tableIN{system_report_tables}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n\n REPORTS = ON_THE_FLY_REPORTS + SYSTEM_REPORTS\n\n # XXX: It's not ideal to use sys_ids but I couldn't find a better way\n DASHBOARDS = [\n \"812fa4400f1130101527008c07767e1a\", # Assessment overview\n \"fa5fe3e1773130107384c087cc5a99d5\", # Asset overview\n \"68ee1f30770230107384c087cc5a992e\", # Asset contract overview\n \"05b0a8b7c3123010a282a539e540dd69\", # Change overview\n \"18b1f472533130104c90ddeeff7b12a6\", # Incident overview\n \"287d07d1ff3130106c1ef9a7cddcbd5d\", # Request overview\n \"7ab78953eb32011008f2951ff15228e6\", # Service catalog overview\n \"2d297c880f1130101527008c07767e27\", # Survey overview\n \"6b706f448f231110953ddffc9071a4f3\", # Telemetry - Table growth\n \"15c5d2d377213010a435478c4f5a993c\", # Usage overview\n \"85a57f9677100110ba155631dc5a9905\", # Web api usage overview\n \"c38ca3a273031010ae8dd21efaf6a747\", # Data classification\n \"3d48f669538223008329ddeeff7b1253\", # Problem overview\n ]\n\n # Select between a full dashboard and a report\n if is_report:\n report = REPORTS[self.random.randint(0, len(REPORTS))]\n\n # On the fly generated report\n if not report.get(\"sys_id\", None):\n # ... these receive a filter that is added through the URL\n url = f\"/now/nav/ui/classic/params/target/sys_report_template.do%3Fsysparm_field%3D{report['field']}%26sysparm_type%3D{report['type']}%26sysparm_table%3D{report['table']}%26sysparm_from_list%3Dtrue%26sysparm_chart_size%3Dlarge%26sysparm_manual_labor%3Dtrue%26sysparm_query=sys_created_on 0, f\"No charts found on the page {self.instance.snow_url}{url}\"\n chart_idx = self.random.randint(0, len(charts))\n chart_title = charts[chart_idx][0] if not is_report else \"\" # No title for reports\n _, chart_data, _ = self._get_chart_by_title(page, chart_title)\n\n # Select a series randomly\n series_idx = self.random.randint(len(chart_data))\n chart_series = chart_data[series_idx][\"name\"] if len(chart_data) > 1 else \"\"\n chart_data = chart_data[series_idx][\"data\"]\n\n # Check if the data is interesting\n labels = [point[\"label\"] for point in chart_data]\n assert len(labels) > 1, f\"Not enough data in the chart (only {len(labels)} label)\"\n assert not any(\n l.isdigit() for l in labels\n ), \"Some chart labels are digits, which would cause errors in validation. Skipping.\"\n\n # Sample a type of question\n question = self.random.choice(question_types)\n\n if question == \"value\":\n # Sample a random type of value to ask for\n format = self.random.choice([\"count\", \"percent\"])\n\n # Select a random label from the chart data\n label = self.random.choice(labels)\n\n return {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": chart_series,\n \"question\": f\"{question}; {format}; {label}\",\n }\n else:\n return {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": chart_series,\n \"question\": question,\n }\n\n\nclass MultiChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass MultiChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartValueRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_VALUE_CONFIG_PATH, \"r\"))\n\n\nclass SingleChartMinMaxRetrievalTask(DashboardRetrievalTask):\n def all_configs(self):\n return json.load(open(REPORT_RETRIEVAL_MINMAX_CONFIG_PATH, \"r\"))","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.private_tasks","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.utils.private_tasks#L1-L63","kind":"module","name":"src.browsergym.workarena.tasks.utils.private_tasks","path":"src/browsergym/workarena/tasks/utils/private_tasks.py","language":"python","start_line":1,"end_line":63,"context_start_line":1,"context_end_line":63,"code":"import json\nimport time\nfrom ...api.utils import table_api_call\nfrom playwright.sync_api import Page\n\n\ndef create_private_task_and_get_sys_id(\n instance,\n page: Page,\n private_task_id: str,\n task_info: str,\n short_description: str,\n user_sys_id: str = None,\n) -> None:\n \"\"\"\n Create a private task in the ServiceNow instance to store the task information. Used for level 3 tasks.\n Sets the sys_id of the private task to the sys_id attribute of the task.\n Returns the sys_id of the private task.\n Parameters:\n ----------\n instance: SNowInstance\n The instance to use.\n page: Page\n playwright page\n private_task_id: str\n ID of the private task to be created.\n task_info: str\n The information needed to complete the task, written in the private task description.\n short_description: str\n A short description of the task, written in the private task short description.\n user_sys_id: str\n The sys_id of the user to assign the task to. If None, the task will be assigned to the admin user.\n \"\"\"\n page.wait_for_load_state(\"networkidle\")\n if user_sys_id is None:\n # Get the user sys_id; if the page is blank, use the admin user\n if page.url == \"about:blank\":\n user_sys_id = table_api_call(\n instance=instance,\n table=\"sys_user\",\n params={\"sysparm_query\": \"user_name=admin\"},\n )[\"result\"][0][\"sys_id\"]\n else:\n user_sys_id = page.evaluate(\"() => NOW.user.userID\")\n # Create private task containing the information needed to complete the task\n result = table_api_call(\n instance=instance,\n table=\"vtb_task\",\n data=json.dumps(\n {\n \"number\": f\"{private_task_id}\",\n \"description\": f\"{task_info}\",\n \"short_description\": f\"{short_description}\",\n \"assigned_to\": f\"{user_sys_id}\",\n }\n ),\n method=\"POST\",\n )[\"result\"]\n sys_id = result[\"sys_id\"]\n\n assert result, \"Failed to create private task\"\n\n return sys_id","source_hash":"afb67d4a704cb99759da2fad2ba7942e3d2af2172500d5c54b374b978f4a6072","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.private_tasks.create_private_task_and_get_sys_id","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.utils.private_tasks.create_private_task_and_get_sys_id#L7-L63","kind":"function","name":"create_private_task_and_get_sys_id","path":"src/browsergym/workarena/tasks/utils/private_tasks.py","language":"python","start_line":7,"end_line":63,"context_start_line":1,"context_end_line":63,"code":"import json\nimport time\nfrom ...api.utils import table_api_call\nfrom playwright.sync_api import Page\n\n\ndef create_private_task_and_get_sys_id(\n instance,\n page: Page,\n private_task_id: str,\n task_info: str,\n short_description: str,\n user_sys_id: str = None,\n) -> None:\n \"\"\"\n Create a private task in the ServiceNow instance to store the task information. Used for level 3 tasks.\n Sets the sys_id of the private task to the sys_id attribute of the task.\n Returns the sys_id of the private task.\n Parameters:\n ----------\n instance: SNowInstance\n The instance to use.\n page: Page\n playwright page\n private_task_id: str\n ID of the private task to be created.\n task_info: str\n The information needed to complete the task, written in the private task description.\n short_description: str\n A short description of the task, written in the private task short description.\n user_sys_id: str\n The sys_id of the user to assign the task to. If None, the task will be assigned to the admin user.\n \"\"\"\n page.wait_for_load_state(\"networkidle\")\n if user_sys_id is None:\n # Get the user sys_id; if the page is blank, use the admin user\n if page.url == \"about:blank\":\n user_sys_id = table_api_call(\n instance=instance,\n table=\"sys_user\",\n params={\"sysparm_query\": \"user_name=admin\"},\n )[\"result\"][0][\"sys_id\"]\n else:\n user_sys_id = page.evaluate(\"() => NOW.user.userID\")\n # Create private task containing the information needed to complete the task\n result = table_api_call(\n instance=instance,\n table=\"vtb_task\",\n data=json.dumps(\n {\n \"number\": f\"{private_task_id}\",\n \"description\": f\"{task_info}\",\n \"short_description\": f\"{short_description}\",\n \"assigned_to\": f\"{user_sys_id}\",\n }\n ),\n method=\"POST\",\n )[\"result\"]\n sys_id = result[\"sys_id\"]\n\n assert result, \"Failed to create private task\"\n\n return sys_id","source_hash":"afb67d4a704cb99759da2fad2ba7942e3d2af2172500d5c54b374b978f4a6072","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.debug","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.utils.debug#L1-L21","kind":"module","name":"src.browsergym.workarena.tasks.utils.debug","path":"src/browsergym/workarena/tasks/utils/debug.py","language":"python","start_line":1,"end_line":21,"context_start_line":1,"context_end_line":21,"code":"import playwright.sync_api\n\n\n# TODO: is this used?\ndef debug_task(task, random_seed=3):\n with playwright.sync_api.sync_playwright() as p:\n browser = p.chromium.launch_persistent_context(\n user_data_dir=\"/tmp/workarena_cromium_user_data\",\n headless=False, # Set headless=True for a non-GUI mode\n )\n (page,) = browser.pages\n\n try:\n task.setup(seed=random_seed, page=page)\n valid_res = task.validate(page, [])\n assert valid_res is False\n task.cheat()\n assert task.validate(page, []) is True\n finally:\n task.teardown()\n browser.close()","source_hash":"104cbb46dd844f0928acf9b4b3acbfbb4c2eb65e6b0e9fcf56e33b06f9ec6c80","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.debug.debug_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.utils.debug.debug_task#L5-L21","kind":"function","name":"debug_task","path":"src/browsergym/workarena/tasks/utils/debug.py","language":"python","start_line":5,"end_line":21,"context_start_line":1,"context_end_line":21,"code":"import playwright.sync_api\n\n\n# TODO: is this used?\ndef debug_task(task, random_seed=3):\n with playwright.sync_api.sync_playwright() as p:\n browser = p.chromium.launch_persistent_context(\n user_data_dir=\"/tmp/workarena_cromium_user_data\",\n headless=False, # Set headless=True for a non-GUI mode\n )\n (page,) = browser.pages\n\n try:\n task.setup(seed=random_seed, page=page)\n valid_res = task.validate(page, [])\n assert valid_res is False\n task.cheat()\n assert task.validate(page, []) is True\n finally:\n task.teardown()\n browser.close()","source_hash":"104cbb46dd844f0928acf9b4b3acbfbb4c2eb65e6b0e9fcf56e33b06f9ec6c80","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.form","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.utils.form#L1-L67","kind":"module","name":"src.browsergym.workarena.tasks.utils.form","path":"src/browsergym/workarena/tasks/utils/form.py","language":"python","start_line":1,"end_line":67,"context_start_line":1,"context_end_line":67,"code":"import time\nfrom ...config import SNOW_BROWSER_TIMEOUT\n\n\ndef fill_text(page, input_field, value, iframe=None):\n \"\"\"\n Fills the value of text field, while handling autocomplete menus.\n\n Parameters\n ----------\n page : playwright.sync_api.page.Page\n The page object\n input_field : playwright locator\n The locator of the input field\n value : str\n The value to fill in\n iframe : playwright locator, optional\n The locator of the iframe that contains the input field, by default None\n\n \"\"\"\n if iframe is None:\n iframe = page\n\n # Click into the field (this sometimes causes some aria autocompletion attributes to be set)\n input_field.click(force=True)\n\n # If the field uses autocomplete, we need to wait for Ajax to finish (and expand the menu)\n if input_field.get_attribute(\"aria-autocomplete\") == \"list\" and value != \"\":\n # Fill in the value using a procedure that triggers the autocomplete\n input_field.fill(value[:-1])\n page.keyboard.press(value[-1])\n time.sleep(0.5)\n\n # Wait for the autocomplete menu to open and be ready\n max_wait_time = SNOW_BROWSER_TIMEOUT # maximum time to wait in seconds\n start_time = time.time()\n while True:\n if input_field.get_attribute(\"aria-expanded\") == \"true\" and not input_field.evaluate(\n \"e => e.ac.isResolving()\"\n ):\n break\n if time.time() - start_time > (max_wait_time / 1000):\n raise TimeoutError(\"Timeout waiting for autocompletion menu to open\")\n time.sleep(0.5) # wait for a short period before checking again\n\n # Select the desired value\n options = iframe.locator(\"[id^='ac_option_']\")\n for i in range(options.count()):\n opt = options.nth(i)\n\n # Extract the value from the option element\n if opt.locator(\".ac_cell\").count() > 0:\n # ... element is multi part (use only the main info)\n opt_value = opt.locator(\".ac_cell\").first.text_content()\n else:\n # ... element is single part (use the whole text)\n opt_value = opt.text_content()\n\n if opt_value.lower() == value.lower():\n opt.click()\n break\n else:\n raise ValueError(f\"No match for value {value} found in autocomplete menu\")\n\n # All other normal text fields\n else:\n input_field.fill(value)","source_hash":"80274f4247c19de30aff1fb0e2dcbb46b32a40ad68df7b8ece581072f5f489c2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.form.fill_text","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.utils.form.fill_text#L5-L67","kind":"function","name":"fill_text","path":"src/browsergym/workarena/tasks/utils/form.py","language":"python","start_line":5,"end_line":67,"context_start_line":1,"context_end_line":67,"code":"import time\nfrom ...config import SNOW_BROWSER_TIMEOUT\n\n\ndef fill_text(page, input_field, value, iframe=None):\n \"\"\"\n Fills the value of text field, while handling autocomplete menus.\n\n Parameters\n ----------\n page : playwright.sync_api.page.Page\n The page object\n input_field : playwright locator\n The locator of the input field\n value : str\n The value to fill in\n iframe : playwright locator, optional\n The locator of the iframe that contains the input field, by default None\n\n \"\"\"\n if iframe is None:\n iframe = page\n\n # Click into the field (this sometimes causes some aria autocompletion attributes to be set)\n input_field.click(force=True)\n\n # If the field uses autocomplete, we need to wait for Ajax to finish (and expand the menu)\n if input_field.get_attribute(\"aria-autocomplete\") == \"list\" and value != \"\":\n # Fill in the value using a procedure that triggers the autocomplete\n input_field.fill(value[:-1])\n page.keyboard.press(value[-1])\n time.sleep(0.5)\n\n # Wait for the autocomplete menu to open and be ready\n max_wait_time = SNOW_BROWSER_TIMEOUT # maximum time to wait in seconds\n start_time = time.time()\n while True:\n if input_field.get_attribute(\"aria-expanded\") == \"true\" and not input_field.evaluate(\n \"e => e.ac.isResolving()\"\n ):\n break\n if time.time() - start_time > (max_wait_time / 1000):\n raise TimeoutError(\"Timeout waiting for autocompletion menu to open\")\n time.sleep(0.5) # wait for a short period before checking again\n\n # Select the desired value\n options = iframe.locator(\"[id^='ac_option_']\")\n for i in range(options.count()):\n opt = options.nth(i)\n\n # Extract the value from the option element\n if opt.locator(\".ac_cell\").count() > 0:\n # ... element is multi part (use only the main info)\n opt_value = opt.locator(\".ac_cell\").first.text_content()\n else:\n # ... element is single part (use the whole text)\n opt_value = opt.text_content()\n\n if opt_value.lower() == value.lower():\n opt.click()\n break\n else:\n raise ValueError(f\"No match for value {value} found in autocomplete menu\")\n\n # All other normal text fields\n else:\n input_field.fill(value)","source_hash":"80274f4247c19de30aff1fb0e2dcbb46b32a40ad68df7b8ece581072f5f489c2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.utils","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.utils.utils#L1-L33","kind":"module","name":"src.browsergym.workarena.tasks.utils.utils","path":"src/browsergym/workarena/tasks/utils/utils.py","language":"python","start_line":1,"end_line":33,"context_start_line":1,"context_end_line":33,"code":"import logging\nimport playwright.sync_api\n\nfrom urllib import parse\n\n\ndef check_url_suffix_match(page: playwright.sync_api.Page, expected_url: str, task) -> bool:\n \"\"\"\n Check if the current page URL matches the expected URL\n \"\"\"\n expected_url = parse.unquote(expected_url)\n expected_url_suffix = parse.urlparse(expected_url).path\n\n page_url = page.evaluate(\"window.location.href\")\n page_url = parse.unquote(page_url)\n page_suffix = parse.urlparse(page_url).path\n if expected_url_suffix not in page_suffix:\n logging.debug(f\"Not in the expected URL for {task.__class__.__name__}, but in {page.url}\")\n return False\n return True\n\n\ndef prettyprint_enum(items, conjunction=\"and\"):\n \"\"\"\n Pretty print a list of items with a conjunction\n\n \"\"\"\n if not items:\n return \"\"\n elif len(items) == 1:\n return items[0]\n else:\n return \", \".join(items[:-1]) + f\", {conjunction} \" + items[-1]","source_hash":"c500fe9e313080deeac5f9f574b04df0c61f777925dd3b957e9988d72c4c2fd9","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.utils.check_url_suffix_match","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.utils.utils.check_url_suffix_match#L7-L20","kind":"function","name":"check_url_suffix_match","path":"src/browsergym/workarena/tasks/utils/utils.py","language":"python","start_line":7,"end_line":20,"context_start_line":1,"context_end_line":33,"code":"import logging\nimport playwright.sync_api\n\nfrom urllib import parse\n\n\ndef check_url_suffix_match(page: playwright.sync_api.Page, expected_url: str, task) -> bool:\n \"\"\"\n Check if the current page URL matches the expected URL\n \"\"\"\n expected_url = parse.unquote(expected_url)\n expected_url_suffix = parse.urlparse(expected_url).path\n\n page_url = page.evaluate(\"window.location.href\")\n page_url = parse.unquote(page_url)\n page_suffix = parse.urlparse(page_url).path\n if expected_url_suffix not in page_suffix:\n logging.debug(f\"Not in the expected URL for {task.__class__.__name__}, but in {page.url}\")\n return False\n return True\n\n\ndef prettyprint_enum(items, conjunction=\"and\"):\n \"\"\"\n Pretty print a list of items with a conjunction\n\n \"\"\"\n if not items:\n return \"\"\n elif len(items) == 1:\n return items[0]\n else:\n return \", \".join(items[:-1]) + f\", {conjunction} \" + items[-1]","source_hash":"c500fe9e313080deeac5f9f574b04df0c61f777925dd3b957e9988d72c4c2fd9","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.utils.prettyprint_enum","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.utils.utils.prettyprint_enum#L23-L33","kind":"function","name":"prettyprint_enum","path":"src/browsergym/workarena/tasks/utils/utils.py","language":"python","start_line":23,"end_line":33,"context_start_line":3,"context_end_line":33,"code":"\nfrom urllib import parse\n\n\ndef check_url_suffix_match(page: playwright.sync_api.Page, expected_url: str, task) -> bool:\n \"\"\"\n Check if the current page URL matches the expected URL\n \"\"\"\n expected_url = parse.unquote(expected_url)\n expected_url_suffix = parse.urlparse(expected_url).path\n\n page_url = page.evaluate(\"window.location.href\")\n page_url = parse.unquote(page_url)\n page_suffix = parse.urlparse(page_url).path\n if expected_url_suffix not in page_suffix:\n logging.debug(f\"Not in the expected URL for {task.__class__.__name__}, but in {page.url}\")\n return False\n return True\n\n\ndef prettyprint_enum(items, conjunction=\"and\"):\n \"\"\"\n Pretty print a list of items with a conjunction\n\n \"\"\"\n if not items:\n return \"\"\n elif len(items) == 1:\n return items[0]\n else:\n return \", \".join(items[:-1]) + f\", {conjunction} \" + items[-1]","source_hash":"c500fe9e313080deeac5f9f574b04df0c61f777925dd3b957e9988d72c4c2fd9","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.string","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.utils.string#L1-L15","kind":"module","name":"src.browsergym.workarena.tasks.utils.string","path":"src/browsergym/workarena/tasks/utils/string.py","language":"python","start_line":1,"end_line":15,"context_start_line":1,"context_end_line":15,"code":"\"\"\"\nVarious utility functions for string manipulation.\n\n\"\"\"\n\n\ndef generate_trigrams(word):\n return [word[i : i + 3] for i in range(len(word) - 2)]\n\n\ndef share_tri_gram(str1, str2):\n tri_grams1 = set(generate_trigrams(str1))\n tri_grams2 = set(generate_trigrams(str2))\n\n return bool(tri_grams1.intersection(tri_grams2))","source_hash":"8abe7f0120fd41214c67d92e1e8dac9d25d1b927efff044e1fa9f104b3933f82","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.string.generate_trigrams","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.utils.string.generate_trigrams#L7-L8","kind":"function","name":"generate_trigrams","path":"src/browsergym/workarena/tasks/utils/string.py","language":"python","start_line":7,"end_line":8,"context_start_line":1,"context_end_line":15,"code":"\"\"\"\nVarious utility functions for string manipulation.\n\n\"\"\"\n\n\ndef generate_trigrams(word):\n return [word[i : i + 3] for i in range(len(word) - 2)]\n\n\ndef share_tri_gram(str1, str2):\n tri_grams1 = set(generate_trigrams(str1))\n tri_grams2 = set(generate_trigrams(str2))\n\n return bool(tri_grams1.intersection(tri_grams2))","source_hash":"8abe7f0120fd41214c67d92e1e8dac9d25d1b927efff044e1fa9f104b3933f82","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.utils.string.share_tri_gram","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.utils.string.share_tri_gram#L11-L15","kind":"function","name":"share_tri_gram","path":"src/browsergym/workarena/tasks/utils/string.py","language":"python","start_line":11,"end_line":15,"context_start_line":1,"context_end_line":15,"code":"\"\"\"\nVarious utility functions for string manipulation.\n\n\"\"\"\n\n\ndef generate_trigrams(word):\n return [word[i : i + 3] for i in range(len(word) - 2)]\n\n\ndef share_tri_gram(str1, str2):\n tri_grams1 = set(generate_trigrams(str1))\n tri_grams2 = set(generate_trigrams(str2))\n\n return bool(tri_grams1.intersection(tri_grams2))","source_hash":"8abe7f0120fd41214c67d92e1e8dac9d25d1b927efff044e1fa9f104b3933f82","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule#L1-L1417","kind":"module","name":"src.browsergym.workarena.tasks.compositional.manage_change_request_schedule","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1,"end_line":1417,"context_start_line":1,"context_end_line":1417,"code":"import re\n\nfrom datetime import datetime, timedelta\nfrom faker import Faker\nfrom typing import List, Tuple\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.form import (\n EditChangeRequestScheduleTask,\n)\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.change_request import create_change_request\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass ManageChangeRequestScheduleTask(FilterAndDoTask):\n \"\"\"Task to schedule change requests.\n Args:\n\n goal_type: str\n The type of goal to set. Choices are \"base\", \"priority\", \"tight\", \"tight priority\". Used for validation\n wide_schedule: bool\n Whether or not the change requests should be scheduled in a 'wide' schedule. If set to True, the change requests\n will have a period of 2 longer than the optimal schedule to be fitted in. Otherwise, they will have\n a period of 2 days longer than the optimal schedule.\n uniform_risk: bool\n whether to use uniform risk for the change requests. The risk is between 2 (high) and 4 (low) and sets the\n duration of the change request (high) risk=2 -> 3 days, (medium) risk=3 -> 2 days, (low) risk=4 -> 1 day\n num_change_requests: int\n The number of change requests to create a schedule for\n pre_existing_schedule: bool\n Whether to create a pre-existing schedule for the change requests. If set to True, the change requests created\n will all overlap and have durations of one day.\n \"\"\"\n\n # mapping between risk and duration\n risk_to_duration = {2: 3, 3: 2, 4: 1}\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n goal_type: str = \"base\",\n wide_schedule: bool = False,\n uniform_risk: bool = True,\n num_change_requests: int = 2,\n pre_existing_schedule: bool = False,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Change\",\n },\n level=level,\n protocol_name=\"Scheduling Your Change Requests\",\n )\n self.goal_type = goal_type\n self.wide_schedule = wide_schedule\n self.uniform_risk = uniform_risk\n self.num_change_requests = num_change_requests\n self.pre_existing_schedule = pre_existing_schedule\n self.change_request_sys_ids = []\n self.change_request_numbers = []\n self.change_request_impacts = [2] * num_change_requests # Medium priorities by default\n\n # start and end dates of the schedule\n self.schedule_start_date = fake.date_time_this_decade(\n after_now=True, before_now=False, tzinfo=None\n ).replace(microsecond=0)\n self.schedule_end_date = None\n self.schedule_bounds_goal = None # Part of the goal to append at the end of the goal to indicate the start and end of the schedule. Used in L2 tasks\n\n if self.uniform_risk:\n self.risks = [4] * num_change_requests\n else:\n self.risks = list(self.random.randint(2, 4, num_change_requests))\n\n self.change_request_hashtag = \"#SERIES-\" + self.unique_id[:10]\n if not self.pre_existing_schedule:\n schedule_type = \"tight schedule\" if \"tight\" in self.goal_type else \"schedule\"\n self.short_description = f\"Scheduling Your Change Requests\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) create a {schedule_type} for your change requests for those with hashtag {self.change_request_hashtag}.'\n else:\n self.short_description = f\"Re-scheduling Your Change Requests\"\n self.task_description = f'The schedule for your change requests with hashtag {self.change_request_hashtag} is currently broken. Please refer to company protocol \"{self.protocol_name}\" (located in the company protocols knowledge base) to fix it.'\n if \"tight\" in self.goal_type:\n self.task_description += \" The change requests should be scheduled according to the tight schedule setting.\"\n self.tasks = []\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n goal, info = super().setup_goal(page=page)\n\n if self.level == 2:\n goal += self.schedule_bounds_goal\n\n return goal, info\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/change_request_list.do\",\n \"expected_fields_path\": EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.change_request_hashtag}\",\n ],\n }\n self.change_request_impacts.sort() # Sort the impacts to make sure the the top impact requests are scheduled first\n\n start_date = self.schedule_start_date\n\n for risk, impact in zip(self.risks, self.change_request_impacts):\n if self.pre_existing_schedule:\n change_request_start_date = start_date + timedelta(hours=self.random.randint(1, 4))\n change_request_end_date = change_request_start_date + timedelta(days=1)\n else:\n change_request_start_date = \"\"\n change_request_end_date = \"\"\n change_request_sys_id, change_request_number = create_change_request(\n instance=self.instance,\n user_sys_id=self._base_user_sysid,\n risk=risk,\n start_date=str(change_request_start_date),\n end_date=str(change_request_end_date),\n impact=impact,\n hashtag=self.change_request_hashtag,\n random=self.random,\n )\n self.change_request_sys_ids.append(change_request_sys_id)\n self.change_request_numbers.append(change_request_number)\n\n for i, risk in enumerate(self.risks):\n skip_description = i > 0\n duration = self.risk_to_duration[risk]\n end_date = start_date + timedelta(days=duration)\n self.tasks.append(\n EditChangeRequestScheduleTask(\n instance=self.instance,\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=self.change_request_sys_ids[i],\n record_number=self.change_request_numbers[i],\n # Here the values will only be used by the cheat; the goal will be over-ridden to explain the task\n # at a high level only; see the get_pretty_printed_description method\n new_values={\"start_date\": str(start_date), \"end_date\": str(end_date)},\n level=self.level,\n goal_type=self.goal_type,\n skip_description=skip_description,\n )\n )\n start_date = end_date + timedelta(minutes=1)\n\n if self.wide_schedule:\n self.schedule_end_date = end_date + timedelta(weeks=2)\n else:\n self.schedule_end_date = end_date + timedelta(days=2)\n\n self.schedule_bounds_goal = f\" All the change requests should be scheduled between {self.schedule_start_date} and {self.schedule_end_date}, inclusively. \"\n # Add the schedule bounds to the task description\n self.task_description += self.schedule_bounds_goal\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n change_requests = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.change_request_hashtag}\",\n \"sysparm_fields\": \"impact,start_date,end_date,risk\",\n },\n )[\"result\"]\n change_requests = sorted(change_requests, key=lambda x: x[\"start_date\"])\n\n # max difference is 1 day if not tight, 1 hour if tight\n max_difference = 1 if self.goal_type == \"tight\" else 24\n\n for i, change_request in enumerate(change_requests):\n # Check that the change request has start/end dates\n if (\n not change_request[\"start_date\"]\n or not change_request[\"end_date\"]\n or (i > 0 and not change_requests[i - 1][\"end_date\"])\n ):\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Change request start date or end date is missing.\"},\n )\n # Confirm that the change request has appropriate duration (within 20% of expected duration)\n current_start_date = datetime.strptime(\n change_request[\"start_date\"], \"%Y-%m-%d %H:%M:%S\"\n )\n current_end_date = datetime.strptime(change_request[\"end_date\"], \"%Y-%m-%d %H:%M:%S\")\n\n # Check that the bounds of the schedule are respected\n if (\n current_start_date < self.schedule_start_date\n or current_end_date > self.schedule_end_date\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change request start date or end date is outside of the target schedule.\"\n },\n )\n\n difference = current_end_date - current_start_date\n # Expected duration is 3 days for high risk, 2 days for medium risk, 1 day for low risk\n duration = self.risk_to_duration[int(change_request[\"risk\"])]\n expected_duration = timedelta(days=duration)\n\n if difference < expected_duration * 0.95 or difference > expected_duration * 1.05:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change request duration is not within 5% of the expected duration.\"\n },\n )\n\n if i == 0:\n continue\n # Confirm change requests are not overlapping and respect maximum spacing (1 day if not tight, 1h if tight)\n previous_end_date = datetime.strptime(\n change_requests[i - 1][\"end_date\"], \"%Y-%m-%d %H:%M:%S\"\n )\n difference = current_start_date - previous_end_date\n if difference > timedelta(hours=max_difference) or difference < timedelta(0):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change requests are overlapping or not respecting the maximum spacing.\"\n },\n )\n # Confirm change requests are ordered by impact - lower number being more impactful\n if change_request[\"impact\"] > change_requests[i - 1][\"impact\"]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Change requests are not ordered by priority.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for change_request_sys_id in self.change_request_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass TwoChangesBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesPriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixPriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n# ... truncated ...","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ManageChangeRequestScheduleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ManageChangeRequestScheduleTask#L29-L287","kind":"class","name":"ManageChangeRequestScheduleTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":29,"end_line":287,"context_start_line":9,"context_end_line":307,"code":"from playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.form import (\n EditChangeRequestScheduleTask,\n)\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.change_request import create_change_request\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass ManageChangeRequestScheduleTask(FilterAndDoTask):\n \"\"\"Task to schedule change requests.\n Args:\n\n goal_type: str\n The type of goal to set. Choices are \"base\", \"priority\", \"tight\", \"tight priority\". Used for validation\n wide_schedule: bool\n Whether or not the change requests should be scheduled in a 'wide' schedule. If set to True, the change requests\n will have a period of 2 longer than the optimal schedule to be fitted in. Otherwise, they will have\n a period of 2 days longer than the optimal schedule.\n uniform_risk: bool\n whether to use uniform risk for the change requests. The risk is between 2 (high) and 4 (low) and sets the\n duration of the change request (high) risk=2 -> 3 days, (medium) risk=3 -> 2 days, (low) risk=4 -> 1 day\n num_change_requests: int\n The number of change requests to create a schedule for\n pre_existing_schedule: bool\n Whether to create a pre-existing schedule for the change requests. If set to True, the change requests created\n will all overlap and have durations of one day.\n \"\"\"\n\n # mapping between risk and duration\n risk_to_duration = {2: 3, 3: 2, 4: 1}\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n goal_type: str = \"base\",\n wide_schedule: bool = False,\n uniform_risk: bool = True,\n num_change_requests: int = 2,\n pre_existing_schedule: bool = False,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Change\",\n },\n level=level,\n protocol_name=\"Scheduling Your Change Requests\",\n )\n self.goal_type = goal_type\n self.wide_schedule = wide_schedule\n self.uniform_risk = uniform_risk\n self.num_change_requests = num_change_requests\n self.pre_existing_schedule = pre_existing_schedule\n self.change_request_sys_ids = []\n self.change_request_numbers = []\n self.change_request_impacts = [2] * num_change_requests # Medium priorities by default\n\n # start and end dates of the schedule\n self.schedule_start_date = fake.date_time_this_decade(\n after_now=True, before_now=False, tzinfo=None\n ).replace(microsecond=0)\n self.schedule_end_date = None\n self.schedule_bounds_goal = None # Part of the goal to append at the end of the goal to indicate the start and end of the schedule. Used in L2 tasks\n\n if self.uniform_risk:\n self.risks = [4] * num_change_requests\n else:\n self.risks = list(self.random.randint(2, 4, num_change_requests))\n\n self.change_request_hashtag = \"#SERIES-\" + self.unique_id[:10]\n if not self.pre_existing_schedule:\n schedule_type = \"tight schedule\" if \"tight\" in self.goal_type else \"schedule\"\n self.short_description = f\"Scheduling Your Change Requests\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) create a {schedule_type} for your change requests for those with hashtag {self.change_request_hashtag}.'\n else:\n self.short_description = f\"Re-scheduling Your Change Requests\"\n self.task_description = f'The schedule for your change requests with hashtag {self.change_request_hashtag} is currently broken. Please refer to company protocol \"{self.protocol_name}\" (located in the company protocols knowledge base) to fix it.'\n if \"tight\" in self.goal_type:\n self.task_description += \" The change requests should be scheduled according to the tight schedule setting.\"\n self.tasks = []\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n goal, info = super().setup_goal(page=page)\n\n if self.level == 2:\n goal += self.schedule_bounds_goal\n\n return goal, info\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/change_request_list.do\",\n \"expected_fields_path\": EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.change_request_hashtag}\",\n ],\n }\n self.change_request_impacts.sort() # Sort the impacts to make sure the the top impact requests are scheduled first\n\n start_date = self.schedule_start_date\n\n for risk, impact in zip(self.risks, self.change_request_impacts):\n if self.pre_existing_schedule:\n change_request_start_date = start_date + timedelta(hours=self.random.randint(1, 4))\n change_request_end_date = change_request_start_date + timedelta(days=1)\n else:\n change_request_start_date = \"\"\n change_request_end_date = \"\"\n change_request_sys_id, change_request_number = create_change_request(\n instance=self.instance,\n user_sys_id=self._base_user_sysid,\n risk=risk,\n start_date=str(change_request_start_date),\n end_date=str(change_request_end_date),\n impact=impact,\n hashtag=self.change_request_hashtag,\n random=self.random,\n )\n self.change_request_sys_ids.append(change_request_sys_id)\n self.change_request_numbers.append(change_request_number)\n\n for i, risk in enumerate(self.risks):\n skip_description = i > 0\n duration = self.risk_to_duration[risk]\n end_date = start_date + timedelta(days=duration)\n self.tasks.append(\n EditChangeRequestScheduleTask(\n instance=self.instance,\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=self.change_request_sys_ids[i],\n record_number=self.change_request_numbers[i],\n # Here the values will only be used by the cheat; the goal will be over-ridden to explain the task\n # at a high level only; see the get_pretty_printed_description method\n new_values={\"start_date\": str(start_date), \"end_date\": str(end_date)},\n level=self.level,\n goal_type=self.goal_type,\n skip_description=skip_description,\n )\n )\n start_date = end_date + timedelta(minutes=1)\n\n if self.wide_schedule:\n self.schedule_end_date = end_date + timedelta(weeks=2)\n else:\n self.schedule_end_date = end_date + timedelta(days=2)\n\n self.schedule_bounds_goal = f\" All the change requests should be scheduled between {self.schedule_start_date} and {self.schedule_end_date}, inclusively. \"\n # Add the schedule bounds to the task description\n self.task_description += self.schedule_bounds_goal\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n change_requests = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.change_request_hashtag}\",\n \"sysparm_fields\": \"impact,start_date,end_date,risk\",\n },\n )[\"result\"]\n change_requests = sorted(change_requests, key=lambda x: x[\"start_date\"])\n\n # max difference is 1 day if not tight, 1 hour if tight\n max_difference = 1 if self.goal_type == \"tight\" else 24\n\n for i, change_request in enumerate(change_requests):\n # Check that the change request has start/end dates\n if (\n not change_request[\"start_date\"]\n or not change_request[\"end_date\"]\n or (i > 0 and not change_requests[i - 1][\"end_date\"])\n ):\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Change request start date or end date is missing.\"},\n )\n # Confirm that the change request has appropriate duration (within 20% of expected duration)\n current_start_date = datetime.strptime(\n change_request[\"start_date\"], \"%Y-%m-%d %H:%M:%S\"\n )\n current_end_date = datetime.strptime(change_request[\"end_date\"], \"%Y-%m-%d %H:%M:%S\")\n\n # Check that the bounds of the schedule are respected\n if (\n current_start_date < self.schedule_start_date\n or current_end_date > self.schedule_end_date\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change request start date or end date is outside of the target schedule.\"\n },\n )\n\n difference = current_end_date - current_start_date\n # Expected duration is 3 days for high risk, 2 days for medium risk, 1 day for low risk\n duration = self.risk_to_duration[int(change_request[\"risk\"])]\n expected_duration = timedelta(days=duration)\n\n if difference < expected_duration * 0.95 or difference > expected_duration * 1.05:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change request duration is not within 5% of the expected duration.\"\n },\n )\n\n if i == 0:\n continue\n # Confirm change requests are not overlapping and respect maximum spacing (1 day if not tight, 1h if tight)\n previous_end_date = datetime.strptime(\n change_requests[i - 1][\"end_date\"], \"%Y-%m-%d %H:%M:%S\"\n )\n difference = current_start_date - previous_end_date\n if difference > timedelta(hours=max_difference) or difference < timedelta(0):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change requests are overlapping or not respecting the maximum spacing.\"\n },\n )\n # Confirm change requests are ordered by impact - lower number being more impactful\n if change_request[\"impact\"] > change_requests[i - 1][\"impact\"]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Change requests are not ordered by priority.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for change_request_sys_id in self.change_request_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass TwoChangesBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n level=level,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesBasicUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesBasicUniformRiskChangeRequestSchedulingTask#L290-L308","kind":"class","name":"TwoChangesBasicUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":290,"end_line":308,"context_start_line":270,"context_end_line":328,"code":" # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for change_request_sys_id in self.change_request_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass TwoChangesBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWideBasicUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWideBasicUniformRiskChangeRequestSchedulingTask#L311-L330","kind":"class","name":"TwoChangesWideBasicUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":311,"end_line":330,"context_start_line":291,"context_end_line":350,"code":" ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixBasicUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixBasicUniformRiskChangeRequestSchedulingTask#L333-L352","kind":"class","name":"TwoChangesFixBasicUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":333,"end_line":352,"context_start_line":313,"context_end_line":372,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWideBasicUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWideBasicUniformRiskChangeRequestSchedulingTask#L355-L375","kind":"class","name":"TwoChangesFixWideBasicUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":355,"end_line":375,"context_start_line":335,"context_end_line":395,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesBasicVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesBasicVariedRiskChangeRequestSchedulingTask#L378-L397","kind":"class","name":"TwoChangesBasicVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":378,"end_line":397,"context_start_line":358,"context_end_line":417,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWideBasicVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWideBasicVariedRiskChangeRequestSchedulingTask#L400-L420","kind":"class","name":"TwoChangesWideBasicVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":400,"end_line":420,"context_start_line":380,"context_end_line":440,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixBasicVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixBasicVariedRiskChangeRequestSchedulingTask#L423-L443","kind":"class","name":"TwoChangesFixBasicVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":423,"end_line":443,"context_start_line":403,"context_end_line":463,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWideBasicVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWideBasicVariedRiskChangeRequestSchedulingTask#L446-L467","kind":"class","name":"TwoChangesFixWideBasicVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":446,"end_line":467,"context_start_line":426,"context_end_line":487,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesPriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n level=level,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesPriorityUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesPriorityUniformRiskChangeRequestSchedulingTask#L470-L488","kind":"class","name":"TwoChangesPriorityUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":470,"end_line":488,"context_start_line":450,"context_end_line":508,"code":" self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesPriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWidePriorityUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWidePriorityUniformRiskChangeRequestSchedulingTask#L491-L510","kind":"class","name":"TwoChangesWidePriorityUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":491,"end_line":510,"context_start_line":471,"context_end_line":530,"code":" ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixPriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixPriorityUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixPriorityUniformRiskChangeRequestSchedulingTask#L513-L532","kind":"class","name":"TwoChangesFixPriorityUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":513,"end_line":532,"context_start_line":493,"context_end_line":552,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixPriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask#L535-L555","kind":"class","name":"TwoChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":535,"end_line":555,"context_start_line":515,"context_end_line":575,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesPriorityVariedRiskChangeRequestSchedulingTask#L558-L577","kind":"class","name":"TwoChangesPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":558,"end_line":577,"context_start_line":538,"context_end_line":597,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWidePriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWidePriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWidePriorityVariedRiskChangeRequestSchedulingTask#L580-L600","kind":"class","name":"TwoChangesWidePriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":580,"end_line":600,"context_start_line":560,"context_end_line":620,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWidePriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixPriorityVariedRiskChangeRequestSchedulingTask#L603-L623","kind":"class","name":"TwoChangesFixPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":603,"end_line":623,"context_start_line":583,"context_end_line":643,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask#L626-L647","kind":"class","name":"TwoChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":626,"end_line":647,"context_start_line":606,"context_end_line":667,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n level=level,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesTightUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesTightUniformRiskChangeRequestSchedulingTask#L650-L668","kind":"class","name":"TwoChangesTightUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":650,"end_line":668,"context_start_line":630,"context_end_line":688,"code":" self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask#L671-L690","kind":"class","name":"TwoChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":671,"end_line":690,"context_start_line":651,"context_end_line":710,"code":" ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixTightUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixTightUniformRiskChangeRequestSchedulingTask#L693-L712","kind":"class","name":"TwoChangesFixTightUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":693,"end_line":712,"context_start_line":673,"context_end_line":732,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask#L715-L735","kind":"class","name":"TwoChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":715,"end_line":735,"context_start_line":695,"context_end_line":755,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesTightPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesTightPriorityVariedRiskChangeRequestSchedulingTask#L738-L757","kind":"class","name":"TwoChangesTightPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":738,"end_line":757,"context_start_line":718,"context_end_line":777,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask#L760-L780","kind":"class","name":"TwoChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":760,"end_line":780,"context_start_line":740,"context_end_line":800,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask#L783-L803","kind":"class","name":"TwoChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":783,"end_line":803,"context_start_line":763,"context_end_line":823,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass TwoChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n wide_schedule=True,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.TwoChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask#L806-L827","kind":"class","name":"TwoChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":806,"end_line":827,"context_start_line":786,"context_end_line":847,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass TwoChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n level=level,\n )\n","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesBasicUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesBasicUniformRiskChangeRequestSchedulingTask#L830-L846","kind":"class","name":"ThreeChangesBasicUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":830,"end_line":846,"context_start_line":810,"context_end_line":866,"code":" self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWideBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWideBasicUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWideBasicUniformRiskChangeRequestSchedulingTask#L849-L866","kind":"class","name":"ThreeChangesWideBasicUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":849,"end_line":866,"context_start_line":829,"context_end_line":886,"code":"\nclass ThreeChangesBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWideBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixBasicUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixBasicUniformRiskChangeRequestSchedulingTask#L869-L886","kind":"class","name":"ThreeChangesFixBasicUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":869,"end_line":886,"context_start_line":849,"context_end_line":906,"code":"class ThreeChangesWideBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWideBasicUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWideBasicUniformRiskChangeRequestSchedulingTask#L889-L909","kind":"class","name":"ThreeChangesFixWideBasicUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":889,"end_line":909,"context_start_line":869,"context_end_line":929,"code":"class ThreeChangesFixBasicUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesBasicVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesBasicVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesBasicVariedRiskChangeRequestSchedulingTask#L912-L929","kind":"class","name":"ThreeChangesBasicVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":912,"end_line":929,"context_start_line":892,"context_end_line":949,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesBasicVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWideBasicVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWideBasicVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWideBasicVariedRiskChangeRequestSchedulingTask#L932-L950","kind":"class","name":"ThreeChangesWideBasicVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":932,"end_line":950,"context_start_line":912,"context_end_line":970,"code":"class ThreeChangesBasicVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWideBasicVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixBasicVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixBasicVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixBasicVariedRiskChangeRequestSchedulingTask#L953-L971","kind":"class","name":"ThreeChangesFixBasicVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":953,"end_line":971,"context_start_line":933,"context_end_line":991,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixBasicVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWideBasicVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWideBasicVariedRiskChangeRequestSchedulingTask#L974-L995","kind":"class","name":"ThreeChangesFixWideBasicVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":974,"end_line":995,"context_start_line":954,"context_end_line":1015,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideBasicVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesPriorityUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n level=level,\n )\n","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesPriorityUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesPriorityUniformRiskChangeRequestSchedulingTask#L998-L1014","kind":"class","name":"ThreeChangesPriorityUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":998,"end_line":1014,"context_start_line":978,"context_end_line":1034,"code":" self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesPriorityUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWidePriorityUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWidePriorityUniformRiskChangeRequestSchedulingTask#L1017-L1036","kind":"class","name":"ThreeChangesWidePriorityUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1017,"end_line":1036,"context_start_line":997,"context_end_line":1056,"code":"\nclass ThreeChangesPriorityUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixPriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixPriorityUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixPriorityUniformRiskChangeRequestSchedulingTask#L1039-L1058","kind":"class","name":"ThreeChangesFixPriorityUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1039,"end_line":1058,"context_start_line":1019,"context_end_line":1078,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixPriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask#L1061-L1081","kind":"class","name":"ThreeChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1061,"end_line":1081,"context_start_line":1041,"context_end_line":1101,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesPriorityVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesPriorityVariedRiskChangeRequestSchedulingTask#L1084-L1101","kind":"class","name":"ThreeChangesPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1084,"end_line":1101,"context_start_line":1064,"context_end_line":1121,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesPriorityVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWidePriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWidePriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWidePriorityVariedRiskChangeRequestSchedulingTask#L1104-L1124","kind":"class","name":"ThreeChangesWidePriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1104,"end_line":1124,"context_start_line":1084,"context_end_line":1144,"code":"class ThreeChangesPriorityVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWidePriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixPriorityVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixPriorityVariedRiskChangeRequestSchedulingTask#L1127-L1145","kind":"class","name":"ThreeChangesFixPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1127,"end_line":1145,"context_start_line":1107,"context_end_line":1165,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixPriorityVariedRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask#L1148-L1169","kind":"class","name":"ThreeChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1148,"end_line":1169,"context_start_line":1128,"context_end_line":1189,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWidePriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesTightUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n level=level,\n )\n","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesTightUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesTightUniformRiskChangeRequestSchedulingTask#L1172-L1188","kind":"class","name":"ThreeChangesTightUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1172,"end_line":1188,"context_start_line":1152,"context_end_line":1208,"code":" self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesTightUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask#L1191-L1210","kind":"class","name":"ThreeChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1191,"end_line":1210,"context_start_line":1171,"context_end_line":1230,"code":"\nclass ThreeChangesTightUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWideScheduleTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixTightUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixTightUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixTightUniformRiskChangeRequestSchedulingTask#L1213-L1230","kind":"class","name":"ThreeChangesFixTightUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1213,"end_line":1230,"context_start_line":1193,"context_end_line":1250,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixTightUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask#L1233-L1253","kind":"class","name":"ThreeChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1233,"end_line":1253,"context_start_line":1213,"context_end_line":1273,"code":"class ThreeChangesFixTightUniformRiskChangeRequestSchedulingTask(ManageChangeRequestScheduleTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideScheduleTightUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesTightPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesTightPriorityVariedRiskChangeRequestSchedulingTask#L1256-L1275","kind":"class","name":"ThreeChangesTightPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1256,"end_line":1275,"context_start_line":1236,"context_end_line":1295,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight\",\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n wide_schedule=True,\n uniform_risk=False,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask#L1278-L1298","kind":"class","name":"ThreeChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1278,"end_line":1298,"context_start_line":1258,"context_end_line":1318,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask#L1301-L1321","kind":"class","name":"ThreeChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1301,"end_line":1321,"context_start_line":1281,"context_end_line":1341,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n wide_schedule=True,\n uniform_risk=False,\n num_change_requests=num_change_requests,\n level=level,\n )\n\n\nclass ThreeChangesFixTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n wide_schedule=True,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.ThreeChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask#L1324-L1345","kind":"class","name":"ThreeChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1324,"end_line":1345,"context_start_line":1304,"context_end_line":1365,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nlocal_vars = locals().copy()\n\n\nSMALL_BASE_SCHEDULING_TASKS = [\n TwoChangesBasicUniformRiskChangeRequestSchedulingTask,\n TwoChangesWideBasicUniformRiskChangeRequestSchedulingTask,\n TwoChangesFixBasicUniformRiskChangeRequestSchedulingTask,\n TwoChangesFixWideBasicUniformRiskChangeRequestSchedulingTask,\n TwoChangesBasicVariedRiskChangeRequestSchedulingTask,\n TwoChangesWideBasicVariedRiskChangeRequestSchedulingTask,\n TwoChangesFixBasicVariedRiskChangeRequestSchedulingTask,\n TwoChangesFixWideBasicVariedRiskChangeRequestSchedulingTask,\n]\nSMALL_TIGHT_SCHEDULING_TASKS = [\n TwoChangesPriorityUniformRiskChangeRequestSchedulingTask,\n TwoChangesWidePriorityUniformRiskChangeRequestSchedulingTask,\n TwoChangesFixPriorityUniformRiskChangeRequestSchedulingTask,\n TwoChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.__init__#L1327-L1345","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1327,"end_line":1345,"context_start_line":1307,"context_end_line":1365,"code":" instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nclass ThreeChangesFixWideTightPriorityVariedRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 3,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"tight priority\",\n uniform_risk=False,\n wide_schedule=True,\n num_change_requests=num_change_requests,\n pre_existing_schedule=True,\n level=level,\n )\n\n\nlocal_vars = locals().copy()\n\n\nSMALL_BASE_SCHEDULING_TASKS = [\n TwoChangesBasicUniformRiskChangeRequestSchedulingTask,\n TwoChangesWideBasicUniformRiskChangeRequestSchedulingTask,\n TwoChangesFixBasicUniformRiskChangeRequestSchedulingTask,\n TwoChangesFixWideBasicUniformRiskChangeRequestSchedulingTask,\n TwoChangesBasicVariedRiskChangeRequestSchedulingTask,\n TwoChangesWideBasicVariedRiskChangeRequestSchedulingTask,\n TwoChangesFixBasicVariedRiskChangeRequestSchedulingTask,\n TwoChangesFixWideBasicVariedRiskChangeRequestSchedulingTask,\n]\nSMALL_TIGHT_SCHEDULING_TASKS = [\n TwoChangesPriorityUniformRiskChangeRequestSchedulingTask,\n TwoChangesWidePriorityUniformRiskChangeRequestSchedulingTask,\n TwoChangesFixPriorityUniformRiskChangeRequestSchedulingTask,\n TwoChangesFixWidePriorityUniformRiskChangeRequestSchedulingTask,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.setup_goal#L108-L114","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":108,"end_line":114,"context_start_line":88,"context_end_line":134,"code":" self.schedule_end_date = None\n self.schedule_bounds_goal = None # Part of the goal to append at the end of the goal to indicate the start and end of the schedule. Used in L2 tasks\n\n if self.uniform_risk:\n self.risks = [4] * num_change_requests\n else:\n self.risks = list(self.random.randint(2, 4, num_change_requests))\n\n self.change_request_hashtag = \"#SERIES-\" + self.unique_id[:10]\n if not self.pre_existing_schedule:\n schedule_type = \"tight schedule\" if \"tight\" in self.goal_type else \"schedule\"\n self.short_description = f\"Scheduling Your Change Requests\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) create a {schedule_type} for your change requests for those with hashtag {self.change_request_hashtag}.'\n else:\n self.short_description = f\"Re-scheduling Your Change Requests\"\n self.task_description = f'The schedule for your change requests with hashtag {self.change_request_hashtag} is currently broken. Please refer to company protocol \"{self.protocol_name}\" (located in the company protocols knowledge base) to fix it.'\n if \"tight\" in self.goal_type:\n self.task_description += \" The change requests should be scheduled according to the tight schedule setting.\"\n self.tasks = []\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n goal, info = super().setup_goal(page=page)\n\n if self.level == 2:\n goal += self.schedule_bounds_goal\n\n return goal, info\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/change_request_list.do\",\n \"expected_fields_path\": EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.change_request_hashtag}\",\n ],\n }\n self.change_request_impacts.sort() # Sort the impacts to make sure the the top impact requests are scheduled first\n\n start_date = self.schedule_start_date\n\n for risk, impact in zip(self.risks, self.change_request_impacts):\n if self.pre_existing_schedule:","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule._setup_list","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule._setup_list#L116-L181","kind":"function","name":"_setup_list","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":116,"end_line":181,"context_start_line":96,"context_end_line":201,"code":" self.change_request_hashtag = \"#SERIES-\" + self.unique_id[:10]\n if not self.pre_existing_schedule:\n schedule_type = \"tight schedule\" if \"tight\" in self.goal_type else \"schedule\"\n self.short_description = f\"Scheduling Your Change Requests\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) create a {schedule_type} for your change requests for those with hashtag {self.change_request_hashtag}.'\n else:\n self.short_description = f\"Re-scheduling Your Change Requests\"\n self.task_description = f'The schedule for your change requests with hashtag {self.change_request_hashtag} is currently broken. Please refer to company protocol \"{self.protocol_name}\" (located in the company protocols knowledge base) to fix it.'\n if \"tight\" in self.goal_type:\n self.task_description += \" The change requests should be scheduled according to the tight schedule setting.\"\n self.tasks = []\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n goal, info = super().setup_goal(page=page)\n\n if self.level == 2:\n goal += self.schedule_bounds_goal\n\n return goal, info\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/change_request_list.do\",\n \"expected_fields_path\": EXPECTED_CHANGE_REQUEST_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.change_request_hashtag}\",\n ],\n }\n self.change_request_impacts.sort() # Sort the impacts to make sure the the top impact requests are scheduled first\n\n start_date = self.schedule_start_date\n\n for risk, impact in zip(self.risks, self.change_request_impacts):\n if self.pre_existing_schedule:\n change_request_start_date = start_date + timedelta(hours=self.random.randint(1, 4))\n change_request_end_date = change_request_start_date + timedelta(days=1)\n else:\n change_request_start_date = \"\"\n change_request_end_date = \"\"\n change_request_sys_id, change_request_number = create_change_request(\n instance=self.instance,\n user_sys_id=self._base_user_sysid,\n risk=risk,\n start_date=str(change_request_start_date),\n end_date=str(change_request_end_date),\n impact=impact,\n hashtag=self.change_request_hashtag,\n random=self.random,\n )\n self.change_request_sys_ids.append(change_request_sys_id)\n self.change_request_numbers.append(change_request_number)\n\n for i, risk in enumerate(self.risks):\n skip_description = i > 0\n duration = self.risk_to_duration[risk]\n end_date = start_date + timedelta(days=duration)\n self.tasks.append(\n EditChangeRequestScheduleTask(\n instance=self.instance,\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=self.change_request_sys_ids[i],\n record_number=self.change_request_numbers[i],\n # Here the values will only be used by the cheat; the goal will be over-ridden to explain the task\n # at a high level only; see the get_pretty_printed_description method\n new_values={\"start_date\": str(start_date), \"end_date\": str(end_date)},\n level=self.level,\n goal_type=self.goal_type,\n skip_description=skip_description,\n )\n )\n start_date = end_date + timedelta(minutes=1)\n\n if self.wide_schedule:\n self.schedule_end_date = end_date + timedelta(weeks=2)\n else:\n self.schedule_end_date = end_date + timedelta(days=2)\n\n self.schedule_bounds_goal = f\" All the change requests should be scheduled between {self.schedule_start_date} and {self.schedule_end_date}, inclusively. \"\n # Add the schedule bounds to the task description\n self.task_description += self.schedule_bounds_goal\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n change_requests = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.change_request_hashtag}\",\n \"sysparm_fields\": \"impact,start_date,end_date,risk\",\n },\n )[\"result\"]\n change_requests = sorted(change_requests, key=lambda x: x[\"start_date\"])\n\n # max difference is 1 day if not tight, 1 hour if tight\n max_difference = 1 if self.goal_type == \"tight\" else 24\n\n for i, change_request in enumerate(change_requests):\n # Check that the change request has start/end dates\n if (\n not change_request[\"start_date\"]\n or not change_request[\"end_date\"]","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.validate#L183-L272","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":183,"end_line":272,"context_start_line":163,"context_end_line":292,"code":" record_number=self.change_request_numbers[i],\n # Here the values will only be used by the cheat; the goal will be over-ridden to explain the task\n # at a high level only; see the get_pretty_printed_description method\n new_values={\"start_date\": str(start_date), \"end_date\": str(end_date)},\n level=self.level,\n goal_type=self.goal_type,\n skip_description=skip_description,\n )\n )\n start_date = end_date + timedelta(minutes=1)\n\n if self.wide_schedule:\n self.schedule_end_date = end_date + timedelta(weeks=2)\n else:\n self.schedule_end_date = end_date + timedelta(days=2)\n\n self.schedule_bounds_goal = f\" All the change requests should be scheduled between {self.schedule_start_date} and {self.schedule_end_date}, inclusively. \"\n # Add the schedule bounds to the task description\n self.task_description += self.schedule_bounds_goal\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n change_requests = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.change_request_hashtag}\",\n \"sysparm_fields\": \"impact,start_date,end_date,risk\",\n },\n )[\"result\"]\n change_requests = sorted(change_requests, key=lambda x: x[\"start_date\"])\n\n # max difference is 1 day if not tight, 1 hour if tight\n max_difference = 1 if self.goal_type == \"tight\" else 24\n\n for i, change_request in enumerate(change_requests):\n # Check that the change request has start/end dates\n if (\n not change_request[\"start_date\"]\n or not change_request[\"end_date\"]\n or (i > 0 and not change_requests[i - 1][\"end_date\"])\n ):\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Change request start date or end date is missing.\"},\n )\n # Confirm that the change request has appropriate duration (within 20% of expected duration)\n current_start_date = datetime.strptime(\n change_request[\"start_date\"], \"%Y-%m-%d %H:%M:%S\"\n )\n current_end_date = datetime.strptime(change_request[\"end_date\"], \"%Y-%m-%d %H:%M:%S\")\n\n # Check that the bounds of the schedule are respected\n if (\n current_start_date < self.schedule_start_date\n or current_end_date > self.schedule_end_date\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change request start date or end date is outside of the target schedule.\"\n },\n )\n\n difference = current_end_date - current_start_date\n # Expected duration is 3 days for high risk, 2 days for medium risk, 1 day for low risk\n duration = self.risk_to_duration[int(change_request[\"risk\"])]\n expected_duration = timedelta(days=duration)\n\n if difference < expected_duration * 0.95 or difference > expected_duration * 1.05:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change request duration is not within 5% of the expected duration.\"\n },\n )\n\n if i == 0:\n continue\n # Confirm change requests are not overlapping and respect maximum spacing (1 day if not tight, 1h if tight)\n previous_end_date = datetime.strptime(\n change_requests[i - 1][\"end_date\"], \"%Y-%m-%d %H:%M:%S\"\n )\n difference = current_start_date - previous_end_date\n if difference > timedelta(hours=max_difference) or difference < timedelta(0):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Change requests are overlapping or not respecting the maximum spacing.\"\n },\n )\n # Confirm change requests are ordered by impact - lower number being more impactful\n if change_request[\"impact\"] > change_requests[i - 1][\"impact\"]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Change requests are not ordered by priority.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for change_request_sys_id in self.change_request_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass TwoChangesBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.manage_change_request_schedule.teardown#L274-L287","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":274,"end_line":287,"context_start_line":254,"context_end_line":307,"code":" 0,\n False,\n \"\",\n {\n \"message\": \"Change requests are overlapping or not respecting the maximum spacing.\"\n },\n )\n # Confirm change requests are ordered by impact - lower number being more impactful\n if change_request[\"impact\"] > change_requests[i - 1][\"impact\"]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Change requests are not ordered by priority.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for change_request_sys_id in self.change_request_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass TwoChangesBasicUniformRiskChangeRequestSchedulingTask(\n ManageChangeRequestScheduleTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_change_requests: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n goal_type=\"base\",\n num_change_requests=num_change_requests,\n level=level,","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.base#L1-L364","kind":"module","name":"src.browsergym.workarena.tasks.compositional.base","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":1,"end_line":364,"context_start_line":1,"context_end_line":364,"code":"import json\nimport time\nimport warnings\n\nfrom typing import List, Tuple\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.config import PROTOCOL_KB_FILEPATH\n\nfrom .update_task import UpdatePrivateTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..navigation import AllMenuTask\n\nfrom ...instance import SNowInstance\n\n\nclass CompositionalTask(AbstractServiceNowTask):\n # Final private task instructions\n final_private_task_instructions = 'Don\\'t forget to mark this task as \"Closed - complete\" once successfully completed. If the task appears infeasible, mark the task as \"Closed - skipped\" .'\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n start_rel_url: str = \"/now/nav/ui/home\",\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n protocol_name: str = \"\",\n user_roles: List[str] = [\"admin\"],\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n start_rel_url: str\n The relative URL to start the task from.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n protocol_name: str\n The name of the protocol to follow to complete the task; only used for level 3 tasks.\n user_roles: list[str]\n The roles to assign to the user (default: [\"admin\"])\n \"\"\"\n super().__init__(\n seed=seed, instance=instance, start_rel_url=start_rel_url, user_roles=user_roles\n )\n # Set the task as completed in L3\n self.set_private_task_as_completed = True\n self.seed = seed\n\n self.fixed_config = fixed_config\n self.protocol_name = protocol_name\n self.task_description = \"\"\n self.short_description = \"\"\n\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n if self.level == 2:\n start_rel_url = \"/now/nav/ui/home\"\n else:\n self.private_task_id = \"PTSK\" + str(id(self) % (10**8)).zfill(8)\n self.sys_id = None\n start_rel_url = \"\" # For level 3 tasks, the start URL depends on the sys ID of the private task created for it\n\n def __len__(self) -> int:\n return len(self.subtasks)\n\n def setup_goal(\n self,\n page: Page,\n config: list[AbstractServiceNowTask],\n build_pretty_print_description: bool = True,\n ) -> tuple[str, str, dict]:\n super().setup_goal(page=page)\n # Index to keep track of the task we are currently validating\n self.valid_index = 0\n\n # Setup all the subtasks\n self.subtasks = []\n self.subgoals = []\n for task in config:\n if (\n self.level == 2 and not task.used_in_level_2\n ): # Skip tasks that are not used in level 2; e.g. navigate to the company protocol\n continue\n self.subtasks.append(task)\n self.subgoals.append(self.subtasks[-1].setup(page=page, do_start=False)[0])\n\n if self.level == 3:\n if build_pretty_print_description:\n self._build_pretty_printed_description(config)\n level_3_final_tasks = [\n # Navigate to the My Work task list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"My Work\",\n \"url\": \"/now/nav/ui/classic/params/target/task_list.do%3Fsysparm_userpref_module%3D1523b8d4c611227b00be8216ec331b9a%26sysparm_query%3Dactive%253Dtrue%255Eassigned_to%253Djavascript%253AgetMyAssignments%2528%2529%255Estate%2521%253D-5%255EEQ\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Close the private task\n UpdatePrivateTask(\n instance=self.instance,\n fixed_config={\n \"task_description\": self.task_description,\n \"short_description\": self.short_description,\n },\n set_as_completed=self.set_private_task_as_completed,\n is_validated=True,\n used_in_level_2=False,\n ),\n ]\n self.subtasks.extend(level_3_final_tasks)\n # Set identical user credentials for all subtasks\n for task in self.subtasks:\n task._base_initial_instance = self.instance\n task._base_user_name, task._base_user_password, task._base_user_sysid = (\n self._base_user_name,\n self._base_user_password,\n self._base_user_sysid,\n )\n task.instance = self.instance\n task.instance.snow_credentials = (self._base_user_name, self._base_user_password)\n\n # Finish the setup with the L3-specific tasks\n for task in self.subtasks[-2:]:\n task.setup(page=page, do_start=False)\n # The sys ID of the private task is the sys ID of the last task in the list\n self.sys_id = level_3_final_tasks[-1].sys_id\n\n self.start_url = (\n self.instance.snow_url\n + f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n\n # For level 2, include all substeps in the goal\n # For level 3, the goal is already set in the private task\n if self.level == 2:\n task_intro = self.short_description + \"\\n\"\n # Get the protocol to follow for the task and pre-pend it to the goal\n goal = task_intro\n goal += \" \\n Concretely, you need to complete the following steps:\"\n\n # In some cases, more than one subtasks with identical subgoals are present and the duplicated tasks have empty goals\n # These multiple tasks are used to provide a complete cheat for the tasks like ManageChangeRequestScheduleTask subclasses\n # To avoid having empty steps in the enumeration, we check if the goal is empty and skip if it is\n i = 1\n for subgoal in self.subgoals:\n if not subgoal:\n continue\n goal += f\"\\n{i}. {subgoal}\"\n i += 1\n\n elif self.level == 3:\n goal = f\"Please complete the following task.\"\n\n return goal, {}\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Get a configuration for a given compositional task, in the form of a list subtasks.\n \"\"\"\n raise NotImplementedError(\"This method should be implemented in a subclass\")\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"\n Solve the a subtask of the task\n\n Parameters:\n ----------\n page: Page\n The page to solve the task on\n chat_messages: list[str]\n The list of messages in the chat\n subtask_idx: int\n The index of the subtask to solve.\n\n Note:\n -----\n * We proceed separately for each subtask since this enables validation of each subtask separately.\n This is useful for certifying the feasibility of tasks in the benchmark. Otherwise, cheat would\n bring us to the final state of the task, which would make it impossible to validate subtasks.\n * Use len(self) to get the number of subtasks in the task.\n\n \"\"\"\n super().cheat(page, chat_messages)\n self.subtasks[subtask_idx].cheat(page, chat_messages)\n\n def _build_pretty_printed_description(self, config: list[AbstractServiceNowTask]) -> str:\n \"\"\"\n Get the task information for the private task description; used for level 3 tasks.\n Args:\n config: list[AbstractServiceNowTask]\n The list of subtasks in the task\n \"\"\"\n for subtask in config:\n if subtask.is_validated or subtask.has_description:\n self.task_description += subtask.get_pretty_printed_description()\n self.task_description += \"\\n\"\n self.task_description += self.final_private_task_instructions\n\n return self.task_description\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n # Initialize the index of the first subtask that requires validation\n while (\n self.valid_index < len(self.subtasks)\n and not self.subtasks[self.valid_index].is_validated\n ):\n self.valid_index += 1\n\n if self.valid_index == len(self.subtasks):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n # Validate the current subtask\n subtask = self.subtasks[self.valid_index]\n reward, stop, info, message = subtask.validate(page, chat_messages)\n\n # If the subtask is valid\n if reward >= 1.0:\n # ... override the info and message to avoid success messages from the subtask\n info = message[\"message\"] = (\n f\"Step {self.valid_index + 1} has been completed successfully.\"\n )\n # ... this is a subtask, so we don't want to stop\n stop = False\n # ... increment index to flag this one as solved\n self.valid_index += 1\n\n # If the subtask is not valid\n else:\n # ... contextualize the info and message per subtask\n info = f\"Step {self.valid_index + 1}: \" + info\n message[\"message\"] = f\"Step {self.valid_index + 1}: \" + message.get(\"message\", \"\")\n\n # Check if all subtasks are solved\n if self.valid_index == len(self.subtasks):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n return 0, stop, info, message\n\n def teardown(self) -> None:\n # XXX: In base.py we define the teardown method as being independent of the\n # current state of the page. This means that we can just call all the\n # subtasks' teardown methods.\n for task in self.subtasks:\n task.teardown()\n super().teardown()\n\n\nclass InfeasibleCompositionalTask(CompositionalTask):\n \"\"\"\n Base class for infeasible tasks.\n\n Args:\n --------\n infeasible_reason (List[str]):\n The reason why the task is infeasible. If a task is infeasible, the validation will look for one of the reasons in the chat messages.\n set by children classes.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n start_rel_url: str = \"/now/nav/ui/home\",\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n protocol_name: str = \"\",\n user_roles: List[str] = [\"admin\"],\n infeasible_reasons: List[str] = [\"\"],\n provide_reason: bool = False,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=start_rel_url,\n fixed_config=fixed_config,\n level=level,\n protocol_name=protocol_name,\n user_roles=user_roles,\n )\n # Set the private task as closed-skipped in L3 tasks\n self.set_private_task_as_completed = False\n self.provide_reason = provide_reason\n self.infeasible_reasons = infeasible_reasons\n self.infeasible_reason_found = (\n False # flag to check if the infeasible reason was found in the chat messages\n )\n self.__dict__.update(kwargs)\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"Add the infeasible reasons to the chat messages\"\"\"\n # Index of the infeasible task that requires sending a message in the chat for the cheat\n # for L2 tasks, the last task is the infeasible one, whereas for L3 tasks, third from last is infeasible\n cheat_index = len(self.subtasks) - 1 if self.level == 2 else len(self.subtasks) - 3\n # We expect the last task of the trajectory to be infeasible. Therefore, we do all but the last cheat step\n if subtask_idx != cheat_index:\n super().cheat(page, chat_messages, subtask_idx)\n else:\n message = \", \".join(self.infeasible_reasons)\n chat_messages.append({\"role\": \"infeasible\", \"message\": message})\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"Check if the infeasible reasons are in the chat messages\"\"\"\n if chat_messages and chat_messages[-1][\"role\"] == \"infeasible\":\n answer = chat_messages[-1][\"message\"].lower()\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n if self.provide_reason and answer == \"\":\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide a reason for the infeasibility.\"},\n )\n if not self.infeasible_reason_found:\n for reason in self.infeasible_reasons:\n if reason.lower() in answer:\n self.infeasible_reason_found = True\n break\n if not self.infeasible_reason_found:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide the correct answer.\"},\n )\n\n return super().validate(page, chat_messages)\n\n\nclass HumanEvalTask:\n \"\"\"Base class to label tasks suitable for human evaluation.\"\"\"\n\n pass","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.CompositionalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.base.CompositionalTask#L18-L270","kind":"class","name":"CompositionalTask","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":18,"end_line":270,"context_start_line":1,"context_end_line":290,"code":"import json\nimport time\nimport warnings\n\nfrom typing import List, Tuple\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.config import PROTOCOL_KB_FILEPATH\n\nfrom .update_task import UpdatePrivateTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..navigation import AllMenuTask\n\nfrom ...instance import SNowInstance\n\n\nclass CompositionalTask(AbstractServiceNowTask):\n # Final private task instructions\n final_private_task_instructions = 'Don\\'t forget to mark this task as \"Closed - complete\" once successfully completed. If the task appears infeasible, mark the task as \"Closed - skipped\" .'\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n start_rel_url: str = \"/now/nav/ui/home\",\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n protocol_name: str = \"\",\n user_roles: List[str] = [\"admin\"],\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n start_rel_url: str\n The relative URL to start the task from.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n protocol_name: str\n The name of the protocol to follow to complete the task; only used for level 3 tasks.\n user_roles: list[str]\n The roles to assign to the user (default: [\"admin\"])\n \"\"\"\n super().__init__(\n seed=seed, instance=instance, start_rel_url=start_rel_url, user_roles=user_roles\n )\n # Set the task as completed in L3\n self.set_private_task_as_completed = True\n self.seed = seed\n\n self.fixed_config = fixed_config\n self.protocol_name = protocol_name\n self.task_description = \"\"\n self.short_description = \"\"\n\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n if self.level == 2:\n start_rel_url = \"/now/nav/ui/home\"\n else:\n self.private_task_id = \"PTSK\" + str(id(self) % (10**8)).zfill(8)\n self.sys_id = None\n start_rel_url = \"\" # For level 3 tasks, the start URL depends on the sys ID of the private task created for it\n\n def __len__(self) -> int:\n return len(self.subtasks)\n\n def setup_goal(\n self,\n page: Page,\n config: list[AbstractServiceNowTask],\n build_pretty_print_description: bool = True,\n ) -> tuple[str, str, dict]:\n super().setup_goal(page=page)\n # Index to keep track of the task we are currently validating\n self.valid_index = 0\n\n # Setup all the subtasks\n self.subtasks = []\n self.subgoals = []\n for task in config:\n if (\n self.level == 2 and not task.used_in_level_2\n ): # Skip tasks that are not used in level 2; e.g. navigate to the company protocol\n continue\n self.subtasks.append(task)\n self.subgoals.append(self.subtasks[-1].setup(page=page, do_start=False)[0])\n\n if self.level == 3:\n if build_pretty_print_description:\n self._build_pretty_printed_description(config)\n level_3_final_tasks = [\n # Navigate to the My Work task list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"My Work\",\n \"url\": \"/now/nav/ui/classic/params/target/task_list.do%3Fsysparm_userpref_module%3D1523b8d4c611227b00be8216ec331b9a%26sysparm_query%3Dactive%253Dtrue%255Eassigned_to%253Djavascript%253AgetMyAssignments%2528%2529%255Estate%2521%253D-5%255EEQ\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Close the private task\n UpdatePrivateTask(\n instance=self.instance,\n fixed_config={\n \"task_description\": self.task_description,\n \"short_description\": self.short_description,\n },\n set_as_completed=self.set_private_task_as_completed,\n is_validated=True,\n used_in_level_2=False,\n ),\n ]\n self.subtasks.extend(level_3_final_tasks)\n # Set identical user credentials for all subtasks\n for task in self.subtasks:\n task._base_initial_instance = self.instance\n task._base_user_name, task._base_user_password, task._base_user_sysid = (\n self._base_user_name,\n self._base_user_password,\n self._base_user_sysid,\n )\n task.instance = self.instance\n task.instance.snow_credentials = (self._base_user_name, self._base_user_password)\n\n # Finish the setup with the L3-specific tasks\n for task in self.subtasks[-2:]:\n task.setup(page=page, do_start=False)\n # The sys ID of the private task is the sys ID of the last task in the list\n self.sys_id = level_3_final_tasks[-1].sys_id\n\n self.start_url = (\n self.instance.snow_url\n + f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n\n # For level 2, include all substeps in the goal\n # For level 3, the goal is already set in the private task\n if self.level == 2:\n task_intro = self.short_description + \"\\n\"\n # Get the protocol to follow for the task and pre-pend it to the goal\n goal = task_intro\n goal += \" \\n Concretely, you need to complete the following steps:\"\n\n # In some cases, more than one subtasks with identical subgoals are present and the duplicated tasks have empty goals\n # These multiple tasks are used to provide a complete cheat for the tasks like ManageChangeRequestScheduleTask subclasses\n # To avoid having empty steps in the enumeration, we check if the goal is empty and skip if it is\n i = 1\n for subgoal in self.subgoals:\n if not subgoal:\n continue\n goal += f\"\\n{i}. {subgoal}\"\n i += 1\n\n elif self.level == 3:\n goal = f\"Please complete the following task.\"\n\n return goal, {}\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Get a configuration for a given compositional task, in the form of a list subtasks.\n \"\"\"\n raise NotImplementedError(\"This method should be implemented in a subclass\")\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"\n Solve the a subtask of the task\n\n Parameters:\n ----------\n page: Page\n The page to solve the task on\n chat_messages: list[str]\n The list of messages in the chat\n subtask_idx: int\n The index of the subtask to solve.\n\n Note:\n -----\n * We proceed separately for each subtask since this enables validation of each subtask separately.\n This is useful for certifying the feasibility of tasks in the benchmark. Otherwise, cheat would\n bring us to the final state of the task, which would make it impossible to validate subtasks.\n * Use len(self) to get the number of subtasks in the task.\n\n \"\"\"\n super().cheat(page, chat_messages)\n self.subtasks[subtask_idx].cheat(page, chat_messages)\n\n def _build_pretty_printed_description(self, config: list[AbstractServiceNowTask]) -> str:\n \"\"\"\n Get the task information for the private task description; used for level 3 tasks.\n Args:\n config: list[AbstractServiceNowTask]\n The list of subtasks in the task\n \"\"\"\n for subtask in config:\n if subtask.is_validated or subtask.has_description:\n self.task_description += subtask.get_pretty_printed_description()\n self.task_description += \"\\n\"\n self.task_description += self.final_private_task_instructions\n\n return self.task_description\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n # Initialize the index of the first subtask that requires validation\n while (\n self.valid_index < len(self.subtasks)\n and not self.subtasks[self.valid_index].is_validated\n ):\n self.valid_index += 1\n\n if self.valid_index == len(self.subtasks):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n # Validate the current subtask\n subtask = self.subtasks[self.valid_index]\n reward, stop, info, message = subtask.validate(page, chat_messages)\n\n # If the subtask is valid\n if reward >= 1.0:\n # ... override the info and message to avoid success messages from the subtask\n info = message[\"message\"] = (\n f\"Step {self.valid_index + 1} has been completed successfully.\"\n )\n # ... this is a subtask, so we don't want to stop\n stop = False\n # ... increment index to flag this one as solved\n self.valid_index += 1\n\n # If the subtask is not valid\n else:\n # ... contextualize the info and message per subtask\n info = f\"Step {self.valid_index + 1}: \" + info\n message[\"message\"] = f\"Step {self.valid_index + 1}: \" + message.get(\"message\", \"\")\n\n # Check if all subtasks are solved\n if self.valid_index == len(self.subtasks):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n return 0, stop, info, message\n\n def teardown(self) -> None:\n # XXX: In base.py we define the teardown method as being independent of the\n # current state of the page. This means that we can just call all the\n # subtasks' teardown methods.\n for task in self.subtasks:\n task.teardown()\n super().teardown()\n\n\nclass InfeasibleCompositionalTask(CompositionalTask):\n \"\"\"\n Base class for infeasible tasks.\n\n Args:\n --------\n infeasible_reason (List[str]):\n The reason why the task is infeasible. If a task is infeasible, the validation will look for one of the reasons in the chat messages.\n set by children classes.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n start_rel_url: str = \"/now/nav/ui/home\",\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.InfeasibleCompositionalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.base.InfeasibleCompositionalTask#L273-L358","kind":"class","name":"InfeasibleCompositionalTask","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":273,"end_line":358,"context_start_line":253,"context_end_line":364,"code":" # Check if all subtasks are solved\n if self.valid_index == len(self.subtasks):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n return 0, stop, info, message\n\n def teardown(self) -> None:\n # XXX: In base.py we define the teardown method as being independent of the\n # current state of the page. This means that we can just call all the\n # subtasks' teardown methods.\n for task in self.subtasks:\n task.teardown()\n super().teardown()\n\n\nclass InfeasibleCompositionalTask(CompositionalTask):\n \"\"\"\n Base class for infeasible tasks.\n\n Args:\n --------\n infeasible_reason (List[str]):\n The reason why the task is infeasible. If a task is infeasible, the validation will look for one of the reasons in the chat messages.\n set by children classes.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n start_rel_url: str = \"/now/nav/ui/home\",\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n protocol_name: str = \"\",\n user_roles: List[str] = [\"admin\"],\n infeasible_reasons: List[str] = [\"\"],\n provide_reason: bool = False,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=start_rel_url,\n fixed_config=fixed_config,\n level=level,\n protocol_name=protocol_name,\n user_roles=user_roles,\n )\n # Set the private task as closed-skipped in L3 tasks\n self.set_private_task_as_completed = False\n self.provide_reason = provide_reason\n self.infeasible_reasons = infeasible_reasons\n self.infeasible_reason_found = (\n False # flag to check if the infeasible reason was found in the chat messages\n )\n self.__dict__.update(kwargs)\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"Add the infeasible reasons to the chat messages\"\"\"\n # Index of the infeasible task that requires sending a message in the chat for the cheat\n # for L2 tasks, the last task is the infeasible one, whereas for L3 tasks, third from last is infeasible\n cheat_index = len(self.subtasks) - 1 if self.level == 2 else len(self.subtasks) - 3\n # We expect the last task of the trajectory to be infeasible. Therefore, we do all but the last cheat step\n if subtask_idx != cheat_index:\n super().cheat(page, chat_messages, subtask_idx)\n else:\n message = \", \".join(self.infeasible_reasons)\n chat_messages.append({\"role\": \"infeasible\", \"message\": message})\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"Check if the infeasible reasons are in the chat messages\"\"\"\n if chat_messages and chat_messages[-1][\"role\"] == \"infeasible\":\n answer = chat_messages[-1][\"message\"].lower()\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n if self.provide_reason and answer == \"\":\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide a reason for the infeasibility.\"},\n )\n if not self.infeasible_reason_found:\n for reason in self.infeasible_reasons:\n if reason.lower() in answer:\n self.infeasible_reason_found = True\n break\n if not self.infeasible_reason_found:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide the correct answer.\"},\n )\n\n return super().validate(page, chat_messages)\n\n\nclass HumanEvalTask:\n \"\"\"Base class to label tasks suitable for human evaluation.\"\"\"\n\n pass","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.HumanEvalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.base.HumanEvalTask#L361-L364","kind":"class","name":"HumanEvalTask","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":361,"end_line":364,"context_start_line":341,"context_end_line":364,"code":" False,\n \"\",\n {\"message\": \"The assistant did not provide a reason for the infeasibility.\"},\n )\n if not self.infeasible_reason_found:\n for reason in self.infeasible_reasons:\n if reason.lower() in answer:\n self.infeasible_reason_found = True\n break\n if not self.infeasible_reason_found:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide the correct answer.\"},\n )\n\n return super().validate(page, chat_messages)\n\n\nclass HumanEvalTask:\n \"\"\"Base class to label tasks suitable for human evaluation.\"\"\"\n\n pass","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.base.__init__#L284-L313","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":284,"end_line":313,"context_start_line":264,"context_end_line":333,"code":" def teardown(self) -> None:\n # XXX: In base.py we define the teardown method as being independent of the\n # current state of the page. This means that we can just call all the\n # subtasks' teardown methods.\n for task in self.subtasks:\n task.teardown()\n super().teardown()\n\n\nclass InfeasibleCompositionalTask(CompositionalTask):\n \"\"\"\n Base class for infeasible tasks.\n\n Args:\n --------\n infeasible_reason (List[str]):\n The reason why the task is infeasible. If a task is infeasible, the validation will look for one of the reasons in the chat messages.\n set by children classes.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n start_rel_url: str = \"/now/nav/ui/home\",\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n protocol_name: str = \"\",\n user_roles: List[str] = [\"admin\"],\n infeasible_reasons: List[str] = [\"\"],\n provide_reason: bool = False,\n **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=start_rel_url,\n fixed_config=fixed_config,\n level=level,\n protocol_name=protocol_name,\n user_roles=user_roles,\n )\n # Set the private task as closed-skipped in L3 tasks\n self.set_private_task_as_completed = False\n self.provide_reason = provide_reason\n self.infeasible_reasons = infeasible_reasons\n self.infeasible_reason_found = (\n False # flag to check if the infeasible reason was found in the chat messages\n )\n self.__dict__.update(kwargs)\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"Add the infeasible reasons to the chat messages\"\"\"\n # Index of the infeasible task that requires sending a message in the chat for the cheat\n # for L2 tasks, the last task is the infeasible one, whereas for L3 tasks, third from last is infeasible\n cheat_index = len(self.subtasks) - 1 if self.level == 2 else len(self.subtasks) - 3\n # We expect the last task of the trajectory to be infeasible. Therefore, we do all but the last cheat step\n if subtask_idx != cheat_index:\n super().cheat(page, chat_messages, subtask_idx)\n else:\n message = \", \".join(self.infeasible_reasons)\n chat_messages.append({\"role\": \"infeasible\", \"message\": message})\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"Check if the infeasible reasons are in the chat messages\"\"\"\n if chat_messages and chat_messages[-1][\"role\"] == \"infeasible\":\n answer = chat_messages[-1][\"message\"].lower()\n else:\n return (\n 0,","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.__len__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.base.__len__#L73-L74","kind":"function","name":"__len__","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":73,"end_line":74,"context_start_line":53,"context_end_line":94,"code":" seed=seed, instance=instance, start_rel_url=start_rel_url, user_roles=user_roles\n )\n # Set the task as completed in L3\n self.set_private_task_as_completed = True\n self.seed = seed\n\n self.fixed_config = fixed_config\n self.protocol_name = protocol_name\n self.task_description = \"\"\n self.short_description = \"\"\n\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n if self.level == 2:\n start_rel_url = \"/now/nav/ui/home\"\n else:\n self.private_task_id = \"PTSK\" + str(id(self) % (10**8)).zfill(8)\n self.sys_id = None\n start_rel_url = \"\" # For level 3 tasks, the start URL depends on the sys ID of the private task created for it\n\n def __len__(self) -> int:\n return len(self.subtasks)\n\n def setup_goal(\n self,\n page: Page,\n config: list[AbstractServiceNowTask],\n build_pretty_print_description: bool = True,\n ) -> tuple[str, str, dict]:\n super().setup_goal(page=page)\n # Index to keep track of the task we are currently validating\n self.valid_index = 0\n\n # Setup all the subtasks\n self.subtasks = []\n self.subgoals = []\n for task in config:\n if (\n self.level == 2 and not task.used_in_level_2\n ): # Skip tasks that are not used in level 2; e.g. navigate to the company protocol\n continue\n self.subtasks.append(task)","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.base.setup_goal#L76-L168","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":76,"end_line":168,"context_start_line":56,"context_end_line":188,"code":" self.set_private_task_as_completed = True\n self.seed = seed\n\n self.fixed_config = fixed_config\n self.protocol_name = protocol_name\n self.task_description = \"\"\n self.short_description = \"\"\n\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n if self.level == 2:\n start_rel_url = \"/now/nav/ui/home\"\n else:\n self.private_task_id = \"PTSK\" + str(id(self) % (10**8)).zfill(8)\n self.sys_id = None\n start_rel_url = \"\" # For level 3 tasks, the start URL depends on the sys ID of the private task created for it\n\n def __len__(self) -> int:\n return len(self.subtasks)\n\n def setup_goal(\n self,\n page: Page,\n config: list[AbstractServiceNowTask],\n build_pretty_print_description: bool = True,\n ) -> tuple[str, str, dict]:\n super().setup_goal(page=page)\n # Index to keep track of the task we are currently validating\n self.valid_index = 0\n\n # Setup all the subtasks\n self.subtasks = []\n self.subgoals = []\n for task in config:\n if (\n self.level == 2 and not task.used_in_level_2\n ): # Skip tasks that are not used in level 2; e.g. navigate to the company protocol\n continue\n self.subtasks.append(task)\n self.subgoals.append(self.subtasks[-1].setup(page=page, do_start=False)[0])\n\n if self.level == 3:\n if build_pretty_print_description:\n self._build_pretty_printed_description(config)\n level_3_final_tasks = [\n # Navigate to the My Work task list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"My Work\",\n \"url\": \"/now/nav/ui/classic/params/target/task_list.do%3Fsysparm_userpref_module%3D1523b8d4c611227b00be8216ec331b9a%26sysparm_query%3Dactive%253Dtrue%255Eassigned_to%253Djavascript%253AgetMyAssignments%2528%2529%255Estate%2521%253D-5%255EEQ\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Close the private task\n UpdatePrivateTask(\n instance=self.instance,\n fixed_config={\n \"task_description\": self.task_description,\n \"short_description\": self.short_description,\n },\n set_as_completed=self.set_private_task_as_completed,\n is_validated=True,\n used_in_level_2=False,\n ),\n ]\n self.subtasks.extend(level_3_final_tasks)\n # Set identical user credentials for all subtasks\n for task in self.subtasks:\n task._base_initial_instance = self.instance\n task._base_user_name, task._base_user_password, task._base_user_sysid = (\n self._base_user_name,\n self._base_user_password,\n self._base_user_sysid,\n )\n task.instance = self.instance\n task.instance.snow_credentials = (self._base_user_name, self._base_user_password)\n\n # Finish the setup with the L3-specific tasks\n for task in self.subtasks[-2:]:\n task.setup(page=page, do_start=False)\n # The sys ID of the private task is the sys ID of the last task in the list\n self.sys_id = level_3_final_tasks[-1].sys_id\n\n self.start_url = (\n self.instance.snow_url\n + f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n\n # For level 2, include all substeps in the goal\n # For level 3, the goal is already set in the private task\n if self.level == 2:\n task_intro = self.short_description + \"\\n\"\n # Get the protocol to follow for the task and pre-pend it to the goal\n goal = task_intro\n goal += \" \\n Concretely, you need to complete the following steps:\"\n\n # In some cases, more than one subtasks with identical subgoals are present and the duplicated tasks have empty goals\n # These multiple tasks are used to provide a complete cheat for the tasks like ManageChangeRequestScheduleTask subclasses\n # To avoid having empty steps in the enumeration, we check if the goal is empty and skip if it is\n i = 1\n for subgoal in self.subgoals:\n if not subgoal:\n continue\n goal += f\"\\n{i}. {subgoal}\"\n i += 1\n\n elif self.level == 3:\n goal = f\"Please complete the following task.\"\n\n return goal, {}\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Get a configuration for a given compositional task, in the form of a list subtasks.\n \"\"\"\n raise NotImplementedError(\"This method should be implemented in a subclass\")\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"\n Solve the a subtask of the task\n\n Parameters:\n ----------\n page: Page\n The page to solve the task on\n chat_messages: list[str]\n The list of messages in the chat\n subtask_idx: int\n The index of the subtask to solve.\n","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.base._get_config#L170-L174","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":170,"end_line":174,"context_start_line":150,"context_end_line":194,"code":" task_intro = self.short_description + \"\\n\"\n # Get the protocol to follow for the task and pre-pend it to the goal\n goal = task_intro\n goal += \" \\n Concretely, you need to complete the following steps:\"\n\n # In some cases, more than one subtasks with identical subgoals are present and the duplicated tasks have empty goals\n # These multiple tasks are used to provide a complete cheat for the tasks like ManageChangeRequestScheduleTask subclasses\n # To avoid having empty steps in the enumeration, we check if the goal is empty and skip if it is\n i = 1\n for subgoal in self.subgoals:\n if not subgoal:\n continue\n goal += f\"\\n{i}. {subgoal}\"\n i += 1\n\n elif self.level == 3:\n goal = f\"Please complete the following task.\"\n\n return goal, {}\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Get a configuration for a given compositional task, in the form of a list subtasks.\n \"\"\"\n raise NotImplementedError(\"This method should be implemented in a subclass\")\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"\n Solve the a subtask of the task\n\n Parameters:\n ----------\n page: Page\n The page to solve the task on\n chat_messages: list[str]\n The list of messages in the chat\n subtask_idx: int\n The index of the subtask to solve.\n\n Note:\n -----\n * We proceed separately for each subtask since this enables validation of each subtask separately.\n This is useful for certifying the feasibility of tasks in the benchmark. Otherwise, cheat would\n bring us to the final state of the task, which would make it impossible to validate subtasks.\n * Use len(self) to get the number of subtasks in the task.","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.base.cheat#L315-L325","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":315,"end_line":325,"context_start_line":295,"context_end_line":345,"code":" **kwargs,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n start_rel_url=start_rel_url,\n fixed_config=fixed_config,\n level=level,\n protocol_name=protocol_name,\n user_roles=user_roles,\n )\n # Set the private task as closed-skipped in L3 tasks\n self.set_private_task_as_completed = False\n self.provide_reason = provide_reason\n self.infeasible_reasons = infeasible_reasons\n self.infeasible_reason_found = (\n False # flag to check if the infeasible reason was found in the chat messages\n )\n self.__dict__.update(kwargs)\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"Add the infeasible reasons to the chat messages\"\"\"\n # Index of the infeasible task that requires sending a message in the chat for the cheat\n # for L2 tasks, the last task is the infeasible one, whereas for L3 tasks, third from last is infeasible\n cheat_index = len(self.subtasks) - 1 if self.level == 2 else len(self.subtasks) - 3\n # We expect the last task of the trajectory to be infeasible. Therefore, we do all but the last cheat step\n if subtask_idx != cheat_index:\n super().cheat(page, chat_messages, subtask_idx)\n else:\n message = \", \".join(self.infeasible_reasons)\n chat_messages.append({\"role\": \"infeasible\", \"message\": message})\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"Check if the infeasible reasons are in the chat messages\"\"\"\n if chat_messages and chat_messages[-1][\"role\"] == \"infeasible\":\n answer = chat_messages[-1][\"message\"].lower()\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n if self.provide_reason and answer == \"\":\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide a reason for the infeasibility.\"},\n )\n if not self.infeasible_reason_found:","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base._build_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.base._build_pretty_printed_description#L200-L213","kind":"function","name":"_build_pretty_printed_description","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":200,"end_line":213,"context_start_line":180,"context_end_line":233,"code":" Parameters:\n ----------\n page: Page\n The page to solve the task on\n chat_messages: list[str]\n The list of messages in the chat\n subtask_idx: int\n The index of the subtask to solve.\n\n Note:\n -----\n * We proceed separately for each subtask since this enables validation of each subtask separately.\n This is useful for certifying the feasibility of tasks in the benchmark. Otherwise, cheat would\n bring us to the final state of the task, which would make it impossible to validate subtasks.\n * Use len(self) to get the number of subtasks in the task.\n\n \"\"\"\n super().cheat(page, chat_messages)\n self.subtasks[subtask_idx].cheat(page, chat_messages)\n\n def _build_pretty_printed_description(self, config: list[AbstractServiceNowTask]) -> str:\n \"\"\"\n Get the task information for the private task description; used for level 3 tasks.\n Args:\n config: list[AbstractServiceNowTask]\n The list of subtasks in the task\n \"\"\"\n for subtask in config:\n if subtask.is_validated or subtask.has_description:\n self.task_description += subtask.get_pretty_printed_description()\n self.task_description += \"\\n\"\n self.task_description += self.final_private_task_instructions\n\n return self.task_description\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n # Initialize the index of the first subtask that requires validation\n while (\n self.valid_index < len(self.subtasks)\n and not self.subtasks[self.valid_index].is_validated\n ):\n self.valid_index += 1\n\n if self.valid_index == len(self.subtasks):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n # Validate the current subtask\n subtask = self.subtasks[self.valid_index]","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.base.validate#L327-L358","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":327,"end_line":358,"context_start_line":307,"context_end_line":364,"code":" self.set_private_task_as_completed = False\n self.provide_reason = provide_reason\n self.infeasible_reasons = infeasible_reasons\n self.infeasible_reason_found = (\n False # flag to check if the infeasible reason was found in the chat messages\n )\n self.__dict__.update(kwargs)\n\n def cheat(self, page: Page, chat_messages: list[str], subtask_idx: int) -> None:\n \"\"\"Add the infeasible reasons to the chat messages\"\"\"\n # Index of the infeasible task that requires sending a message in the chat for the cheat\n # for L2 tasks, the last task is the infeasible one, whereas for L3 tasks, third from last is infeasible\n cheat_index = len(self.subtasks) - 1 if self.level == 2 else len(self.subtasks) - 3\n # We expect the last task of the trajectory to be infeasible. Therefore, we do all but the last cheat step\n if subtask_idx != cheat_index:\n super().cheat(page, chat_messages, subtask_idx)\n else:\n message = \", \".join(self.infeasible_reasons)\n chat_messages.append({\"role\": \"infeasible\", \"message\": message})\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"Check if the infeasible reasons are in the chat messages\"\"\"\n if chat_messages and chat_messages[-1][\"role\"] == \"infeasible\":\n answer = chat_messages[-1][\"message\"].lower()\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n if self.provide_reason and answer == \"\":\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide a reason for the infeasibility.\"},\n )\n if not self.infeasible_reason_found:\n for reason in self.infeasible_reasons:\n if reason.lower() in answer:\n self.infeasible_reason_found = True\n break\n if not self.infeasible_reason_found:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide the correct answer.\"},\n )\n\n return super().validate(page, chat_messages)\n\n\nclass HumanEvalTask:\n \"\"\"Base class to label tasks suitable for human evaluation.\"\"\"\n\n pass","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.base.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.base.teardown#L264-L270","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":264,"end_line":270,"context_start_line":244,"context_end_line":290,"code":" # ... increment index to flag this one as solved\n self.valid_index += 1\n\n # If the subtask is not valid\n else:\n # ... contextualize the info and message per subtask\n info = f\"Step {self.valid_index + 1}: \" + info\n message[\"message\"] = f\"Step {self.valid_index + 1}: \" + message.get(\"message\", \"\")\n\n # Check if all subtasks are solved\n if self.valid_index == len(self.subtasks):\n return (\n 1,\n True,\n \"Nice work, thank you!\",\n {\"message\": \"Task completed successfully.\"},\n )\n\n return 0, stop, info, message\n\n def teardown(self) -> None:\n # XXX: In base.py we define the teardown method as being independent of the\n # current state of the page. This means that we can just call all the\n # subtasks' teardown methods.\n for task in self.subtasks:\n task.teardown()\n super().teardown()\n\n\nclass InfeasibleCompositionalTask(CompositionalTask):\n \"\"\"\n Base class for infeasible tasks.\n\n Args:\n --------\n infeasible_reason (List[str]):\n The reason why the task is infeasible. If a task is infeasible, the validation will look for one of the reasons in the chat messages.\n set by children classes.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n start_rel_url: str = \"/now/nav/ui/home\",\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.navigate_and_do#L1-L1151","kind":"module","name":"src.browsergym.workarena.tasks.compositional.navigate_and_do","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":1,"end_line":1151,"context_start_line":1,"context_end_line":1151,"code":"import json\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.form import (\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,\n CreateUserTask,\n)\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterChangeRequestListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterServiceCatalogItemListTask,\n FilterUserListTask,\n SortAssetListTask,\n SortChangeRequestListTask,\n SortHardwareListTask,\n SortIncidentListTask,\n SortServiceCatalogItemListTask,\n SortUserListTask,\n)\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...instance import SNowInstance\n\n\nclass NavigateAndDoTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n navigation_config: dict = None,\n level: int = 2,\n task: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Generic task to navigate to a specific page and perform a task.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n navigation_config: dict\n Configuration to use for the navigation task. Contains the application and the module; the URL is not necessary as the\n nav step is not validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n task: AbstractServiceNowTask\n The task to perform after navigating to the page.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.task = task\n self.task_description = None\n self.short_description = None\n # Get the navigation configuration; there is only one configuration for each application and module combo\n self.navigation_config = navigation_config\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n config = self.fixed_config if self.fixed_config else self._get_config()\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n config = [\n # Navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task,\n ]\n\n return config\n\n\nclass NavigateAndCreateUserTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n task=CreateUserTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass NavigateAndCreateIncidentTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n task=CreateIncidentTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass NavigateAndCreateChangeRequestTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n task=CreateChangeRequestTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass NavigateAndCreateProblemTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n task=CreateProblemTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass NavigateAndCreateHardwareAssetTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n task=CreateHardwareAssetTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass NavigateAndOrderStandardLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderStandardLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the service catalog\"\n\n\nclass NavigateAndOrderSalesLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a sales laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderSalesLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a sales laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a sales laptop from the service catalog\"\n\n\nclass NavigateAndOrderDeveloperLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a developer laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderDeveloperLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a developer laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a developer laptop from the service catalog\"\n\n\nclass NavigateAndOrderIpadProTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an iPad Pro.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderIpadProTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an iPad Pro from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Pro from the service catalog\"\n\n\nclass NavigateAndOrderIpadMiniTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an iPad Mini.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderIpadMiniTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an iPad Mini from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Mini from the service catalog\"\n\n\nclass NavigateAndOrderAppleWatchTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an Apple Watch.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderAppleWatchTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an Apple Watch from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an Apple Watch from the service catalog\"\n\n\nclass NavigateAndOrderAppleMacBookPro15Task(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an Apple MacBook Pro 15\".\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderAppleMacBookPro15Task(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = 'Order an Apple MacBook Pro 15\" from the service catalog with the required configuration if applicable. \\n'\n self.short_description = 'Order an Apple MacBook Pro 15\" from the service catalog'\n\n\nclass NavigateAndOrderDevelopmentLaptopPCTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a development laptop PC.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderDevelopmentLaptopPCTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a development laptop PC from the service catalog with the re\n# ... truncated ...","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndDoTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndDoTask#L50-L121","kind":"class","name":"NavigateAndDoTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":50,"end_line":121,"context_start_line":30,"context_end_line":141,"code":"from browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...instance import SNowInstance\n\n\nclass NavigateAndDoTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n navigation_config: dict = None,\n level: int = 2,\n task: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Generic task to navigate to a specific page and perform a task.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n navigation_config: dict\n Configuration to use for the navigation task. Contains the application and the module; the URL is not necessary as the\n nav step is not validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n task: AbstractServiceNowTask\n The task to perform after navigating to the page.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.task = task\n self.task_description = None\n self.short_description = None\n # Get the navigation configuration; there is only one configuration for each application and module combo\n self.navigation_config = navigation_config\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n config = self.fixed_config if self.fixed_config else self._get_config()\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n config = [\n # Navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task,\n ]\n\n return config\n\n\nclass NavigateAndCreateUserTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateUserTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateUserTask#L124-L156","kind":"class","name":"NavigateAndCreateUserTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":124,"end_line":156,"context_start_line":104,"context_end_line":176,"code":"\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n config = [\n # Navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task,\n ]\n\n return config\n\n\nclass NavigateAndCreateUserTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n task=CreateUserTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass NavigateAndCreateIncidentTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateIncidentTask#L159-L191","kind":"class","name":"NavigateAndCreateIncidentTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":159,"end_line":191,"context_start_line":139,"context_end_line":211,"code":" short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n task=CreateUserTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass NavigateAndCreateIncidentTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n task=CreateIncidentTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass NavigateAndCreateChangeRequestTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateChangeRequestTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateChangeRequestTask#L194-L228","kind":"class","name":"NavigateAndCreateChangeRequestTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":194,"end_line":228,"context_start_line":174,"context_end_line":248,"code":" short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n task=CreateIncidentTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass NavigateAndCreateChangeRequestTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n task=CreateChangeRequestTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass NavigateAndCreateProblemTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateProblemTask#L231-L263","kind":"class","name":"NavigateAndCreateProblemTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":231,"end_line":263,"context_start_line":211,"context_end_line":283,"code":" \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n task=CreateChangeRequestTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass NavigateAndCreateProblemTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n task=CreateProblemTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass NavigateAndCreateHardwareAssetTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateHardwareAssetTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndCreateHardwareAssetTask#L266-L298","kind":"class","name":"NavigateAndCreateHardwareAssetTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":266,"end_line":298,"context_start_line":246,"context_end_line":318,"code":" short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n task=CreateProblemTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass NavigateAndCreateHardwareAssetTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n task=CreateHardwareAssetTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass NavigateAndOrderStandardLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderStandardLaptopTask#L301-L333","kind":"class","name":"NavigateAndOrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":301,"end_line":333,"context_start_line":281,"context_end_line":353,"code":" short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n task=CreateHardwareAssetTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass NavigateAndOrderStandardLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderStandardLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the service catalog\"\n\n\nclass NavigateAndOrderSalesLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a sales laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderSalesLaptopTask#L336-L368","kind":"class","name":"NavigateAndOrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":336,"end_line":368,"context_start_line":316,"context_end_line":388,"code":" short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderStandardLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the service catalog\"\n\n\nclass NavigateAndOrderSalesLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a sales laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderSalesLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a sales laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a sales laptop from the service catalog\"\n\n\nclass NavigateAndOrderDeveloperLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a developer laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderDeveloperLaptopTask#L371-L403","kind":"class","name":"NavigateAndOrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":371,"end_line":403,"context_start_line":351,"context_end_line":423,"code":" short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderSalesLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a sales laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a sales laptop from the service catalog\"\n\n\nclass NavigateAndOrderDeveloperLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a developer laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderDeveloperLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a developer laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a developer laptop from the service catalog\"\n\n\nclass NavigateAndOrderIpadProTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an iPad Pro.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderIpadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderIpadProTask#L406-L438","kind":"class","name":"NavigateAndOrderIpadProTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":406,"end_line":438,"context_start_line":386,"context_end_line":458,"code":" short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderDeveloperLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a developer laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a developer laptop from the service catalog\"\n\n\nclass NavigateAndOrderIpadProTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an iPad Pro.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderIpadProTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an iPad Pro from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Pro from the service catalog\"\n\n\nclass NavigateAndOrderIpadMiniTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an iPad Mini.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderIpadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderIpadMiniTask#L441-L473","kind":"class","name":"NavigateAndOrderIpadMiniTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":441,"end_line":473,"context_start_line":421,"context_end_line":493,"code":" short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderIpadProTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an iPad Pro from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Pro from the service catalog\"\n\n\nclass NavigateAndOrderIpadMiniTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an iPad Mini.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderIpadMiniTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an iPad Mini from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Mini from the service catalog\"\n\n\nclass NavigateAndOrderAppleWatchTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an Apple Watch.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderAppleWatchTask#L476-L508","kind":"class","name":"NavigateAndOrderAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":476,"end_line":508,"context_start_line":456,"context_end_line":528,"code":" short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderIpadMiniTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an iPad Mini from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Mini from the service catalog\"\n\n\nclass NavigateAndOrderAppleWatchTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an Apple Watch.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderAppleWatchTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an Apple Watch from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an Apple Watch from the service catalog\"\n\n\nclass NavigateAndOrderAppleMacBookPro15Task(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an Apple MacBook Pro 15\".\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderAppleMacBookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderAppleMacBookPro15Task#L511-L543","kind":"class","name":"NavigateAndOrderAppleMacBookPro15Task","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":511,"end_line":543,"context_start_line":491,"context_end_line":563,"code":" short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderAppleWatchTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order an Apple Watch from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an Apple Watch from the service catalog\"\n\n\nclass NavigateAndOrderAppleMacBookPro15Task(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order an Apple MacBook Pro 15\".\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderAppleMacBookPro15Task(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = 'Order an Apple MacBook Pro 15\" from the service catalog with the required configuration if applicable. \\n'\n self.short_description = 'Order an Apple MacBook Pro 15\" from the service catalog'\n\n\nclass NavigateAndOrderDevelopmentLaptopPCTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a development laptop PC.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderDevelopmentLaptopPCTask#L546-L578","kind":"class","name":"NavigateAndOrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":546,"end_line":578,"context_start_line":526,"context_end_line":598,"code":" short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderAppleMacBookPro15Task(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = 'Order an Apple MacBook Pro 15\" from the service catalog with the required configuration if applicable. \\n'\n self.short_description = 'Order an Apple MacBook Pro 15\" from the service catalog'\n\n\nclass NavigateAndOrderDevelopmentLaptopPCTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a development laptop PC.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderDevelopmentLaptopPCTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a development laptop PC from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a development laptop PC from the service catalog\"\n\n\nclass NavigateAndOrderLoanerLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a loaner laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndOrderLoanerLaptopTask#L581-L613","kind":"class","name":"NavigateAndOrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":581,"end_line":613,"context_start_line":561,"context_end_line":633,"code":" short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderDevelopmentLaptopPCTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a development laptop PC from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a development laptop PC from the service catalog\"\n\n\nclass NavigateAndOrderLoanerLaptopTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and order a loaner laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderLoanerLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a loaner laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a loaner laptop from the service catalog\"\n\n\nclass NavigateAndFilterAssetListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterAssetListTask#L616-L654","kind":"class","name":"NavigateAndFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":616,"end_line":654,"context_start_line":596,"context_end_line":674,"code":" short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n task=OrderLoanerLaptopTask(\n seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True\n ),\n )\n self.task_description = \"Order a loaner laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a loaner laptop from the service catalog\"\n\n\nclass NavigateAndFilterAssetListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n task=FilterAssetListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Filter the asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterUserListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the user list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterUserListTask#L657-L695","kind":"class","name":"NavigateAndFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":657,"end_line":695,"context_start_line":637,"context_end_line":715,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n task=FilterAssetListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Filter the asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterUserListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n task=FilterUserListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the user list based on specific criteria. \\n\"\n self.short_description = \"Filter the user list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterIncidentListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Navigate to the incident list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the incident list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterIncidentListTask#L698-L736","kind":"class","name":"NavigateAndFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":698,"end_line":736,"context_start_line":678,"context_end_line":756,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n task=FilterUserListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the user list based on specific criteria. \\n\"\n self.short_description = \"Filter the user list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterIncidentListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Navigate to the incident list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n task=FilterIncidentListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the incident list based on specific criteria. \\n\"\n self.short_description = \"Filter the incident list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterChangeRequestListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Navigate to the change request list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the change request list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterChangeRequestListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterChangeRequestListTask#L739-L777","kind":"class","name":"NavigateAndFilterChangeRequestListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":739,"end_line":777,"context_start_line":719,"context_end_line":797,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n task=FilterIncidentListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the incident list based on specific criteria. \\n\"\n self.short_description = \"Filter the incident list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterChangeRequestListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Navigate to the change request list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n task=FilterChangeRequestListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the change request list based on specific criteria. \\n\"\n self.short_description = \"Filter the change request list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterHardwareListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Navigate to the hardware asset list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the hardware asset list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterHardwareListTask#L780-L818","kind":"class","name":"NavigateAndFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":780,"end_line":818,"context_start_line":760,"context_end_line":838,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n task=FilterChangeRequestListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the change request list based on specific criteria. \\n\"\n self.short_description = \"Filter the change request list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterHardwareListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Navigate to the hardware asset list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n task=FilterHardwareListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Filter the hardware asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterServiceCatalogItemListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the service catalog item list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterServiceCatalogItemListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndFilterServiceCatalogItemListTask#L821-L861","kind":"class","name":"NavigateAndFilterServiceCatalogItemListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":821,"end_line":861,"context_start_line":801,"context_end_line":881,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n task=FilterHardwareListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Filter the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Filter the hardware asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndFilterServiceCatalogItemListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n task=FilterServiceCatalogItemListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = (\n \"Filter the service catalog item list based on specific criteria. \\n\"\n )\n self.short_description = \"Filter the service catalog item list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortAssetListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the asset list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortAssetListTask#L864-L902","kind":"class","name":"NavigateAndSortAssetListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":864,"end_line":902,"context_start_line":844,"context_end_line":922,"code":" navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n task=FilterServiceCatalogItemListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = (\n \"Filter the service catalog item list based on specific criteria. \\n\"\n )\n self.short_description = \"Filter the service catalog item list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortAssetListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n task=SortAssetListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Sort the asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortUserListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the user list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortUserListTask#L905-L943","kind":"class","name":"NavigateAndSortUserListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":905,"end_line":943,"context_start_line":885,"context_end_line":963,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n task=SortAssetListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Sort the asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortUserListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n task=SortUserListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the user list based on specific criteria. \\n\"\n self.short_description = \"Sort the user list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortIncidentListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Navigate to the incident list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the incident list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortIncidentListTask#L946-L984","kind":"class","name":"NavigateAndSortIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":946,"end_line":984,"context_start_line":926,"context_end_line":1004,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n task=SortUserListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the user list based on specific criteria. \\n\"\n self.short_description = \"Sort the user list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortIncidentListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Navigate to the incident list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n task=SortIncidentListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the incident list based on specific criteria. \\n\"\n self.short_description = \"Sort the incident list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortChangeRequestListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Navigate to the change request list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the change request list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortChangeRequestListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortChangeRequestListTask#L987-L1025","kind":"class","name":"NavigateAndSortChangeRequestListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":987,"end_line":1025,"context_start_line":967,"context_end_line":1045,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n task=SortIncidentListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the incident list based on specific criteria. \\n\"\n self.short_description = \"Sort the incident list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortChangeRequestListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Navigate to the change request list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n task=SortChangeRequestListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the change request list based on specific criteria. \\n\"\n self.short_description = \"Sort the change request list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortHardwareListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Navigate to the hardware asset list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the hardware asset list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortHardwareListTask#L1028-L1066","kind":"class","name":"NavigateAndSortHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":1028,"end_line":1066,"context_start_line":1008,"context_end_line":1086,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n task=SortChangeRequestListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the change request list based on specific criteria. \\n\"\n self.short_description = \"Sort the change request list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortHardwareListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Navigate to the hardware asset list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n task=SortHardwareListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Sort the hardware asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortServiceCatalogItemListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the service catalog item list\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortServiceCatalogItemListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do.NavigateAndSortServiceCatalogItemListTask#L1069-L1107","kind":"class","name":"NavigateAndSortServiceCatalogItemListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":1069,"end_line":1107,"context_start_line":1049,"context_end_line":1127,"code":" instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n task=SortHardwareListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Sort the hardware asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortServiceCatalogItemListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n task=SortServiceCatalogItemListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the service catalog item list based on specific criteria. \\n\"\n self.short_description = \"Sort the service catalog item list.\"\n self.list_name = list_name\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, NavigateAndDoTask) and var is not NavigateAndDoTask\n]\n\nNAVIGATE_AND_CREATE_TASKS = [\n NavigateAndCreateUserTask,\n NavigateAndCreateIncidentTask,\n NavigateAndCreateChangeRequestTask,\n NavigateAndCreateProblemTask,\n NavigateAndCreateHardwareAssetTask,\n]\nNAVIGATE_AND_ORDER_TASKS = [\n NavigateAndOrderStandardLaptopTask,\n NavigateAndOrderSalesLaptopTask,","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.navigate_and_do.__init__#L1070-L1107","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":1070,"end_line":1107,"context_start_line":1050,"context_end_line":1127,"code":" fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n task=SortHardwareListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Sort the hardware asset list.\"\n self.list_name = list_name\n\n\nclass NavigateAndSortServiceCatalogItemListTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Navigate to the service catalog item list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n task=SortServiceCatalogItemListTask(\n seed=seed,\n instance=instance,\n used_in_level_2=(level == 2),\n is_validated=True,\n list_name=list_name,\n ),\n )\n self.task_description = \"Sort the service catalog item list based on specific criteria. \\n\"\n self.short_description = \"Sort the service catalog item list.\"\n self.list_name = list_name\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, NavigateAndDoTask) and var is not NavigateAndDoTask\n]\n\nNAVIGATE_AND_CREATE_TASKS = [\n NavigateAndCreateUserTask,\n NavigateAndCreateIncidentTask,\n NavigateAndCreateChangeRequestTask,\n NavigateAndCreateProblemTask,\n NavigateAndCreateHardwareAssetTask,\n]\nNAVIGATE_AND_ORDER_TASKS = [\n NavigateAndOrderStandardLaptopTask,\n NavigateAndOrderSalesLaptopTask,","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.navigate_and_do.setup_goal#L101-L105","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":101,"end_line":105,"context_start_line":81,"context_end_line":125,"code":" task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.task = task\n self.task_description = None\n self.short_description = None\n # Get the navigation configuration; there is only one configuration for each application and module combo\n self.navigation_config = navigation_config\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n config = self.fixed_config if self.fixed_config else self._get_config()\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n config = [\n # Navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task,\n ]\n\n return config\n\n\nclass NavigateAndCreateUserTask(NavigateAndDoTask):\n def __init__(","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.navigate_and_do._get_config#L107-L121","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":107,"end_line":121,"context_start_line":87,"context_end_line":141,"code":" self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.task = task\n self.task_description = None\n self.short_description = None\n # Get the navigation configuration; there is only one configuration for each application and module combo\n self.navigation_config = navigation_config\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n config = self.fixed_config if self.fixed_config else self._get_config()\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n config = [\n # Navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task,\n ]\n\n return config\n\n\nclass NavigateAndCreateUserTask(NavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_create_incident#L1-L403","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_create_incident","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":1,"end_line":403,"context_start_line":1,"context_end_line":403,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateIncidentTask\n\n\nclass DashboardRetrieveIncidentAndCreateIncidentTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n self.filter_than = \"lesser\"\n self.attribute_name = \"assigned_to\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.prefix = \"DCI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n base_user = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n },\n )[\"result\"][0]\n self.user_name = base_user[\"first_name\"] + \" \" + base_user[\"last_name\"]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n incident_numbers = []\n for _ in range(len(agent_full_names)):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n while (\n incident_number in self.all_incident_numbers or incident_number in incident_numbers\n ):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n incident_numbers.append(incident_number)\n\n self.incident_numbers = incident_numbers\n\n create_incident_subtasks = []\n\n for agent_full_name, incident_number in zip(agent_full_names, incident_numbers):\n self.incident_short_description = \"Compulsory training for employee in probation\"\n incident_config = {\n \"fields\": {\n \"caller_id\": \"Caller\",\n \"category\": \"Category\",\n \"short_description\": \"Short description\",\n \"impact\": \"Impact\",\n \"number\": \"Number\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n },\n \"task_fields\": [\n \"caller_id\",\n \"category\",\n \"short_description\",\n \"impact\",\n \"number\",\n \"urgency\",\n \"assigned_to\",\n ],\n \"template_record\": {\n \"caller_id\": self.user_name,\n \"category\": \"Inquiry / Help\",\n \"short_description\": self.incident_short_description,\n \"impact\": \"1 - High\",\n \"number\": incident_number,\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n }\n\n create_incident_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an incident\n CreateIncidentTask(\n instance=self.instance,\n fixed_config=incident_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_incident_subtasks += create_incident_subtask\n\n self.compositional_task = create_incident_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n incident_numbers_string = \", \".join(self.incident_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Using this value, retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create an 'incident' with the following information (only fill these fields and the 'incident number' from below) and assign it to them using the 'Assigned to' field: \\n\"\n + f\"\\t\\t Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'. Make sure to use an 'incident number' from the list as described below.\\n\"\n + f\"\\t Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\\n\\n\"\n + f\"Note that you will create as many incidents as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\n5. You have to create new 'incidents' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new incident:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}' and 'assign' them to each agent using the 'Assigned to' field.\\n\\n\"\n + f\"Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\\n\"\n + f\"Note that you will create as many incidents as there are agents matching the above criteria.\"\n + \"\\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n fixed_template_record = {\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1\",\n \"urgency\": \"1\",\n }\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n \"sysparm_fields\": \"assigned_to,impact,urgency,short_description,description\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"No incident created with number {incident_number}.\"},\n )\n elif len(created_incident_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Multiple incidents created with number {incident_number}.\"},\n )\n created_incident_response = created_incident_response[0]\n if created_incident_response[\"assigned_to\"][\"value\"] not in self.agent_value_sysids:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Incident {incident_number} assigned to a random agent.\"},\n )\n\n for key, value in fixed_template_record.items():\n if str(created_incident_response[key]).lower() != str(value).lower():\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Incident {incident_number} assigned incorrect value to field {key}.\"\n },\n )\n\n for agent_sysid in self.agent_value_sysids:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}^short_description={self.incident_short_description}\",\n \"sysparm_fields\": \"assigned_to\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No incident assigned to agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_incident_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple incidents assigned to agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )\n\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_AND_CREATE_INCIDENT = [\n DashboardRetrieveIncidentAndMinCreateIncidentTask,\n]\nDASH_COMPUTE_AND_CREATE_INCIDENT = [\n DashboardRetrieveIncidentAndMeanCreateIncidentTask,\n DashboardRetrieveIncidentAndMedianCreateIncidentTask,\n DashboardRetrieveIncidentAndModeCreateIncidentTask,\n]","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndCreateIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndCreateIncidentTask#L17-L269","kind":"class","name":"DashboardRetrieveIncidentAndCreateIncidentTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":17,"end_line":269,"context_start_line":1,"context_end_line":289,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateIncidentTask\n\n\nclass DashboardRetrieveIncidentAndCreateIncidentTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n self.filter_than = \"lesser\"\n self.attribute_name = \"assigned_to\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.prefix = \"DCI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n base_user = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n },\n )[\"result\"][0]\n self.user_name = base_user[\"first_name\"] + \" \" + base_user[\"last_name\"]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n incident_numbers = []\n for _ in range(len(agent_full_names)):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n while (\n incident_number in self.all_incident_numbers or incident_number in incident_numbers\n ):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n incident_numbers.append(incident_number)\n\n self.incident_numbers = incident_numbers\n\n create_incident_subtasks = []\n\n for agent_full_name, incident_number in zip(agent_full_names, incident_numbers):\n self.incident_short_description = \"Compulsory training for employee in probation\"\n incident_config = {\n \"fields\": {\n \"caller_id\": \"Caller\",\n \"category\": \"Category\",\n \"short_description\": \"Short description\",\n \"impact\": \"Impact\",\n \"number\": \"Number\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n },\n \"task_fields\": [\n \"caller_id\",\n \"category\",\n \"short_description\",\n \"impact\",\n \"number\",\n \"urgency\",\n \"assigned_to\",\n ],\n \"template_record\": {\n \"caller_id\": self.user_name,\n \"category\": \"Inquiry / Help\",\n \"short_description\": self.incident_short_description,\n \"impact\": \"1 - High\",\n \"number\": incident_number,\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n }\n\n create_incident_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an incident\n CreateIncidentTask(\n instance=self.instance,\n fixed_config=incident_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_incident_subtasks += create_incident_subtask\n\n self.compositional_task = create_incident_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n incident_numbers_string = \", \".join(self.incident_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Using this value, retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create an 'incident' with the following information (only fill these fields and the 'incident number' from below) and assign it to them using the 'Assigned to' field: \\n\"\n + f\"\\t\\t Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'. Make sure to use an 'incident number' from the list as described below.\\n\"\n + f\"\\t Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\\n\\n\"\n + f\"Note that you will create as many incidents as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\n5. You have to create new 'incidents' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new incident:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}' and 'assign' them to each agent using the 'Assigned to' field.\\n\\n\"\n + f\"Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\\n\"\n + f\"Note that you will create as many incidents as there are agents matching the above criteria.\"\n + \"\\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n fixed_template_record = {\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1\",\n \"urgency\": \"1\",\n }\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n \"sysparm_fields\": \"assigned_to,impact,urgency,short_description,description\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"No incident created with number {incident_number}.\"},\n )\n elif len(created_incident_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Multiple incidents created with number {incident_number}.\"},\n )\n created_incident_response = created_incident_response[0]\n if created_incident_response[\"assigned_to\"][\"value\"] not in self.agent_value_sysids:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Incident {incident_number} assigned to a random agent.\"},\n )\n\n for key, value in fixed_template_record.items():\n if str(created_incident_response[key]).lower() != str(value).lower():\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Incident {incident_number} assigned incorrect value to field {key}.\"\n },\n )\n\n for agent_sysid in self.agent_value_sysids:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}^short_description={self.incident_short_description}\",\n \"sysparm_fields\": \"assigned_to\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No incident assigned to agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_incident_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple incidents assigned to agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )\n\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndMinCreateIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndMinCreateIncidentTask#L272-L298","kind":"class","name":"DashboardRetrieveIncidentAndMinCreateIncidentTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":272,"end_line":298,"context_start_line":252,"context_end_line":318,"code":" instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )\n\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndMeanCreateIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndMeanCreateIncidentTask#L301-L327","kind":"class","name":"DashboardRetrieveIncidentAndMeanCreateIncidentTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":301,"end_line":327,"context_start_line":281,"context_end_line":347,"code":" ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndMedianCreateIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndMedianCreateIncidentTask#L330-L356","kind":"class","name":"DashboardRetrieveIncidentAndMedianCreateIncidentTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":330,"end_line":356,"context_start_line":310,"context_end_line":376,"code":" ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndModeCreateIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.DashboardRetrieveIncidentAndModeCreateIncidentTask#L359-L385","kind":"class","name":"DashboardRetrieveIncidentAndModeCreateIncidentTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":359,"end_line":385,"context_start_line":339,"context_end_line":403,"code":" ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_AND_CREATE_INCIDENT = [\n DashboardRetrieveIncidentAndMinCreateIncidentTask,\n]\nDASH_COMPUTE_AND_CREATE_INCIDENT = [\n DashboardRetrieveIncidentAndMeanCreateIncidentTask,\n DashboardRetrieveIncidentAndMedianCreateIncidentTask,\n DashboardRetrieveIncidentAndModeCreateIncidentTask,\n]","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.__init__#L362-L385","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":362,"end_line":385,"context_start_line":342,"context_end_line":403,"code":" Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_AND_CREATE_INCIDENT = [\n DashboardRetrieveIncidentAndMinCreateIncidentTask,\n]\nDASH_COMPUTE_AND_CREATE_INCIDENT = [\n DashboardRetrieveIncidentAndMeanCreateIncidentTask,\n DashboardRetrieveIncidentAndMedianCreateIncidentTask,\n DashboardRetrieveIncidentAndModeCreateIncidentTask,\n]","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.set_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.set_compositional_task#L48-L131","kind":"function","name":"set_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":48,"end_line":131,"context_start_line":28,"context_end_line":151,"code":" Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n self.filter_than = \"lesser\"\n self.attribute_name = \"assigned_to\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.prefix = \"DCI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n base_user = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n },\n )[\"result\"][0]\n self.user_name = base_user[\"first_name\"] + \" \" + base_user[\"last_name\"]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n incident_numbers = []\n for _ in range(len(agent_full_names)):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n while (\n incident_number in self.all_incident_numbers or incident_number in incident_numbers\n ):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n incident_numbers.append(incident_number)\n\n self.incident_numbers = incident_numbers\n\n create_incident_subtasks = []\n\n for agent_full_name, incident_number in zip(agent_full_names, incident_numbers):\n self.incident_short_description = \"Compulsory training for employee in probation\"\n incident_config = {\n \"fields\": {\n \"caller_id\": \"Caller\",\n \"category\": \"Category\",\n \"short_description\": \"Short description\",\n \"impact\": \"Impact\",\n \"number\": \"Number\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n },\n \"task_fields\": [\n \"caller_id\",\n \"category\",\n \"short_description\",\n \"impact\",\n \"number\",\n \"urgency\",\n \"assigned_to\",\n ],\n \"template_record\": {\n \"caller_id\": self.user_name,\n \"category\": \"Inquiry / Help\",\n \"short_description\": self.incident_short_description,\n \"impact\": \"1 - High\",\n \"number\": incident_number,\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n }\n\n create_incident_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an incident\n CreateIncidentTask(\n instance=self.instance,\n fixed_config=incident_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_incident_subtasks += create_incident_subtask\n\n self.compositional_task = create_incident_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n incident_numbers_string = \", \".join(self.incident_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Using this value, retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create an 'incident' with the following information (only fill these fields and the 'incident number' from below) and assign it to them using the 'Assigned to' field: \\n\"\n + f\"\\t\\t Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'. Make sure to use an 'incident number' from the list as described below.\\n\"\n + f\"\\t Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\\n\\n\"\n + f\"Note that you will create as many incidents as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.setup_goal#L133-L166","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":133,"end_line":166,"context_start_line":113,"context_end_line":186,"code":" \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an incident\n CreateIncidentTask(\n instance=self.instance,\n fixed_config=incident_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_incident_subtasks += create_incident_subtask\n\n self.compositional_task = create_incident_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n incident_numbers_string = \", \".join(self.incident_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Using this value, retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create an 'incident' with the following information (only fill these fields and the 'incident number' from below) and assign it to them using the 'Assigned to' field: \\n\"\n + f\"\\t\\t Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'. Make sure to use an 'incident number' from the list as described below.\\n\"\n + f\"\\t Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\\n\\n\"\n + f\"Note that you will create as many incidents as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\n5. You have to create new 'incidents' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new incident:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}' and 'assign' them to each agent using the 'Assigned to' field.\\n\\n\"\n + f\"Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\\n\"\n + f\"Note that you will create as many incidents as there are agents matching the above criteria.\"\n + \"\\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n fixed_template_record = {\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1\",\n \"urgency\": \"1\",\n }\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n \"sysparm_fields\": \"assigned_to,impact,urgency,short_description,description\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) == 0:\n return (\n 0,","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.validate#L168-L247","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":168,"end_line":247,"context_start_line":148,"context_end_line":267,"code":" + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\n5. You have to create new 'incidents' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new incident:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}' and 'assign' them to each agent using the 'Assigned to' field.\\n\\n\"\n + f\"Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\\n\"\n + f\"Note that you will create as many incidents as there are agents matching the above criteria.\"\n + \"\\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n fixed_template_record = {\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1\",\n \"urgency\": \"1\",\n }\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n \"sysparm_fields\": \"assigned_to,impact,urgency,short_description,description\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"No incident created with number {incident_number}.\"},\n )\n elif len(created_incident_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Multiple incidents created with number {incident_number}.\"},\n )\n created_incident_response = created_incident_response[0]\n if created_incident_response[\"assigned_to\"][\"value\"] not in self.agent_value_sysids:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Incident {incident_number} assigned to a random agent.\"},\n )\n\n for key, value in fixed_template_record.items():\n if str(created_incident_response[key]).lower() != str(value).lower():\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Incident {incident_number} assigned incorrect value to field {key}.\"\n },\n )\n\n for agent_sysid in self.agent_value_sysids:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}^short_description={self.incident_short_description}\",\n \"sysparm_fields\": \"assigned_to\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No incident assigned to agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_incident_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple incidents assigned to agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident.teardown#L249-L269","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":249,"end_line":269,"context_start_line":229,"context_end_line":289,"code":" return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No incident assigned to agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_incident_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple incidents assigned to agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )\n\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentTask(\n DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.work_assignment#L1-L804","kind":"module","name":"src.browsergym.workarena.tasks.compositional.work_assignment","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":1,"end_line":804,"context_start_line":1,"context_end_line":804,"code":"from typing import Tuple\nfrom faker import Faker\nimport random\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ...api.incident import create_incident\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ..base import AbstractServiceNowTask\nfrom ..list import FilterIncidentListTask\nfrom ..form import EditIncidentTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..navigation import AllMenuTask\n\nfrom ...instance import SNowInstance\n\n\nclass WorkAssignmentTask(CompositionalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_experts_per_category: int = 2,\n max_assignments: int = None,\n min_assignments: int = None,\n num_categories: int = None,\n seed: int = None,\n prefix: str = None,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[tuple[AbstractServiceNowTask, dict, bool]]\n A list of tuples, each containing a subtask, its configuration and whether or not it should be validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n max_experts_per_category: int\n How many maximum new agents to create for each category.\n max_assignments: int\n Maximum number of incidents created to be assigned.\n For a task, the number is randomly sampled between max_assignments and min_assignments.\n max_assignments: int\n Minimum number of incidents created to be assigned.\n For a task, the number is randomly sampled between max_assignments and min_assignments.\n prefix: str\n Prefix to name the incidents created with a unique prefix\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Work Assignment', assign incidents to different agents with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Assign task to relevant expert agents\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Work Assignment: Assign Incidents to Relevant Agents\"\n super().__init__(\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n seed=seed,\n )\n\n self.task_description = None\n self.short_description = f\"Assign work to relevant agents\"\n self.max_experts_per_category = max_experts_per_category\n self.max_assignments = max_assignments\n self.min_assignments = min_assignments\n self.num_categories = num_categories\n if self.num_categories > 4 or self.num_categories < 1:\n raise Exception(\"Should have at least 1 and at most 4 categories.\")\n self.prefix = prefix\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.incident_configs = []\n number_assignments = self.random.randint(self.min_assignments, self.max_assignments)\n\n all_existing_incidents = table_api_call(\n instance=self.instance, table=\"incident\", method=\"GET\"\n )[\"result\"]\n all_incident_numbers = [incident[\"number\"] for incident in all_existing_incidents]\n new_incident_numbers = []\n for _ in range(number_assignments):\n incident_number = (\n self.prefix + str(id(self) % (10**8)).zfill(8)[:4] + str(random.randint(100, 999))\n )\n while (\n incident_number in all_incident_numbers or incident_number in new_incident_numbers\n ):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(random.randint(100, 999))\n )\n new_incident_numbers.append(incident_number)\n\n self.active_categories = self.random.choice(\n [\"hardware\", \"software\", \"network\", \"database\"], self.num_categories, replace=False\n )\n for incident_number in new_incident_numbers:\n ### We can reduce the categories here if the setup takes too long\n category = self.random.choice(self.active_categories)\n incident_response = create_incident(\n instance=self.instance,\n incident_number=incident_number,\n caller_sys_id=self._base_user_sysid,\n category=category,\n priority=4,\n impact=2, # priority is calculated as some combination of impact and urgency\n urgency=3,\n )\n self.incident_configs.append(incident_response)\n\n self.experts = dict({category: [] for category in self.active_categories})\n for _ in range(self.max_experts_per_category):\n for category in self.active_categories:\n self.experts[category].append(\n create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=[\"itil\"],\n random=self.random,\n )\n )\n expert_string = \"\"\n for category in self.active_categories:\n category_experts = \", \".join(\n expert[\"first_name\"] + \" \" + expert[\"last_name\"]\n for expert in self.experts[category]\n )\n expert_string += f\"{category.capitalize()} agents: {category_experts} \\n\"\n incident_numbers = \", \".join(new_incident_numbers)\n\n # Get the task description\n self.task_description = (\n f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) assign work to the agents with the following information: \\n'\n + f\"Incidents to assign: {incident_numbers} \\n\\n\"\n + f\"{expert_string}\"\n )\n\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Service Desk > Incidents. \\n\"\n + f\"\\n2. You have to assign the following incidents to relevant agents: {incident_numbers}. You can filter the list using each incident number and use the 'Assigned to' field to assign an incident.\\n\"\n + f\"\\n3. You have to ensure that each incident is assigned to a relevant agent based on the category of the incident.\\n\"\n + f\"\\nThe category wise agents are as follows. You can assign an incident to ANY agent from the category:\\n\"\n + f\"{expert_string}\"\n )\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": \"Can you find the Work Assignment Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n all_incident_assignments = []\n\n for incident_config in self.incident_configs:\n assigned_to = self.random.choice(self.experts[incident_config[\"category\"]])\n assigned_to = assigned_to[\"first_name\"] + \" \" + assigned_to[\"last_name\"]\n assign_incidents_subtask = [\n # Navigate to the incidents list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter incident\n FilterIncidentListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\n \"number\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n incident_config[\"number\"],\n ],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Edit incident\n EditIncidentTask(\n instance=self.instance,\n # fixed_config=incident_config,\n new_values={\"assigned_to\": assigned_to},\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=incident_config[\"sys_id\"],\n level=self.level,\n ),\n ]\n all_incident_assignments.extend(assign_incidents_subtask)\n\n config = navigate_to_protocol_subtask + all_incident_assignments\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n experts_sys_ids = {\n category: [expert[\"sys_id\"] for expert in self.experts[category]]\n for category in self.experts\n }\n for incident_config in self.incident_configs:\n incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"sys_id={incident_config['sys_id']}\",\n \"sysparm_fields\": \"category,assigned_to\",\n },\n method=\"GET\",\n )[\"result\"][0]\n if incident_response[\"category\"] != incident_config[\"category\"]:\n raise Exception(\"Corrupted incident data\")\n if not incident_response[\"assigned_to\"]:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} has not been assigned to anyone.\"\n },\n )\n if (\n incident_response[\"assigned_to\"][\"value\"]\n not in experts_sys_ids[incident_response[\"category\"]]\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} was assigned to an incorrect expert.\"\n },\n )\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident in self.incident_configs:\n db_delete_from_table(\n instance=self.instance, table=\"incident\", sys_id=incident[\"sys_id\"]\n )\n\n for experts in self.experts.values():\n for expert in experts:\n db_delete_from_table(\n instance=self.instance, table=\"sys_user\", sys_id=expert[\"sys_id\"]\n )\n\n return super().teardown()\n\n\nclass WorkAssignmentSmallTask(WorkAssignmentTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Small version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=4,\n min_assignments=3,\n num_categories=2,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAS\",\n )\n\n\nclass WorkAssignmentMediumTask(WorkAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Medium version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=6,\n min_assignments=5,\n num_categories=3,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAM\",\n )\n\n\nclass WorkAssignmentLargeTask(WorkAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Large version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=8,\n min_assignments=7,\n num_categories=4,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAL\",\n )\n\n\nclass PriorityAssignmentTask(CompositionalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_tasks_per_priority: int = 2,\n min_tasks_per_priority: int = 1,\n num_categories: int = None,\n seed: int = None,\n prefix: str = None,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[tuple[AbstractServiceNowTask, dict, bool]]\n A list of tuples, each containing a subtask, its configuration and whether or not it should be validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n experts_per_category: int\n How many new agents to create for each category.\n max_assignments: int\n Maximum number of incidents created to be assigned.\n For a task, the number is randomly sampled between max_assignments and min_assignments.\n max_assignments: int\n Minimum number of incidents created to be assigned.\n For a task, the number is randomly sampled between max_assignments and min_assignments.\n prefix: str\n Prefix to name the incidents created with a unique prefix\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Priority Assignment', assign incidents to different agents in terms of priority with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Assign task to relevant expert agents based on the incident priorities\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Work Assignment: Assign Incidents to Relevant Agents\"\n super().__init__(\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n seed=seed,\n )\n\n self.task_description = None\n self.short_description = None\n self.experts_per_category = 3 # We divide agents into 'expert', 'supporter', and 'planner'\n self.max_tasks_per_priority = max_tasks_per_priority\n self.min_tasks_per_priority = min_tasks_per_priority\n # Priority 1 is urgent, 3 is moderate, 5 is planning.\n # Also priority depends on impact and urgency rather than being an independent attribute\n self.priorities = {\n 1: {\n \"impact\": 1,\n \"urgency\": 1,\n \"num_incidents\": self.random.randint(\n self.min_tasks_per_priority, self.max_tasks_per_priority\n ),\n \"agent_type\": \"expert\",\n },\n 3: {\n \"impact\": 2,\n \"urgency\": 2,\n \"num_incidents\": self.random.randint(\n self.min_tasks_per_priority, self.max_tasks_per_priority\n ),\n \"agent_type\": \"supporter\",\n },\n 5: {\n \"impact\": 3,\n \"urgency\": 3,\n \"num_incidents\": self.random.randint(\n self.min_tasks_per_priority, self.max_tasks_per_priority\n ),\n \"agent_type\": \"planner\",\n },\n }\n self.num_categories = num_categories\n if self.num_categories > 4 or self.num_categories < 1:\n raise Exception(\"Should have at least 1 and at most 4 categories.\")\n self.prefix = prefix\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.incident_configs = []\n number_assignments = sum(\n [attribute[\"num_incidents\"] for attribute in self.priorities.values()]\n )\n\n all_existing_incidents = table_api_call(\n instance=self.instance, table=\"incident\", method=\"GET\"\n )[\"result\"]\n all_incident_numbers = [incident[\"number\"] for incident in all_existing_incidents]\n\n new_incident_numbers = []\n for _ in range(number_assignments):\n incident_number = (\n self.prefix + str(id(self) % (10**8)).zfill(8)[:4] + str(random.randint(100, 999))\n )\n while (\n incident_number in all_incident_numbers or incident_number in new_incident_numbers\n ):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(random.randint(100, 999))\n )\n new_incident_numbers.append(incident_number)\n incident_category = []\n self.active_categories = self.random.choice(\n [\"hardware\"\n# ... truncated ...","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.WorkAssignmentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.work_assignment.WorkAssignmentTask#L23-L304","kind":"class","name":"WorkAssignmentTask","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":23,"end_line":304,"context_start_line":3,"context_end_line":324,"code":"import random\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ...api.incident import create_incident\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ..base import AbstractServiceNowTask\nfrom ..list import FilterIncidentListTask\nfrom ..form import EditIncidentTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..navigation import AllMenuTask\n\nfrom ...instance import SNowInstance\n\n\nclass WorkAssignmentTask(CompositionalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_experts_per_category: int = 2,\n max_assignments: int = None,\n min_assignments: int = None,\n num_categories: int = None,\n seed: int = None,\n prefix: str = None,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[tuple[AbstractServiceNowTask, dict, bool]]\n A list of tuples, each containing a subtask, its configuration and whether or not it should be validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n max_experts_per_category: int\n How many maximum new agents to create for each category.\n max_assignments: int\n Maximum number of incidents created to be assigned.\n For a task, the number is randomly sampled between max_assignments and min_assignments.\n max_assignments: int\n Minimum number of incidents created to be assigned.\n For a task, the number is randomly sampled between max_assignments and min_assignments.\n prefix: str\n Prefix to name the incidents created with a unique prefix\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Work Assignment', assign incidents to different agents with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Assign task to relevant expert agents\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Work Assignment: Assign Incidents to Relevant Agents\"\n super().__init__(\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n seed=seed,\n )\n\n self.task_description = None\n self.short_description = f\"Assign work to relevant agents\"\n self.max_experts_per_category = max_experts_per_category\n self.max_assignments = max_assignments\n self.min_assignments = min_assignments\n self.num_categories = num_categories\n if self.num_categories > 4 or self.num_categories < 1:\n raise Exception(\"Should have at least 1 and at most 4 categories.\")\n self.prefix = prefix\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.incident_configs = []\n number_assignments = self.random.randint(self.min_assignments, self.max_assignments)\n\n all_existing_incidents = table_api_call(\n instance=self.instance, table=\"incident\", method=\"GET\"\n )[\"result\"]\n all_incident_numbers = [incident[\"number\"] for incident in all_existing_incidents]\n new_incident_numbers = []\n for _ in range(number_assignments):\n incident_number = (\n self.prefix + str(id(self) % (10**8)).zfill(8)[:4] + str(random.randint(100, 999))\n )\n while (\n incident_number in all_incident_numbers or incident_number in new_incident_numbers\n ):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(random.randint(100, 999))\n )\n new_incident_numbers.append(incident_number)\n\n self.active_categories = self.random.choice(\n [\"hardware\", \"software\", \"network\", \"database\"], self.num_categories, replace=False\n )\n for incident_number in new_incident_numbers:\n ### We can reduce the categories here if the setup takes too long\n category = self.random.choice(self.active_categories)\n incident_response = create_incident(\n instance=self.instance,\n incident_number=incident_number,\n caller_sys_id=self._base_user_sysid,\n category=category,\n priority=4,\n impact=2, # priority is calculated as some combination of impact and urgency\n urgency=3,\n )\n self.incident_configs.append(incident_response)\n\n self.experts = dict({category: [] for category in self.active_categories})\n for _ in range(self.max_experts_per_category):\n for category in self.active_categories:\n self.experts[category].append(\n create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=[\"itil\"],\n random=self.random,\n )\n )\n expert_string = \"\"\n for category in self.active_categories:\n category_experts = \", \".join(\n expert[\"first_name\"] + \" \" + expert[\"last_name\"]\n for expert in self.experts[category]\n )\n expert_string += f\"{category.capitalize()} agents: {category_experts} \\n\"\n incident_numbers = \", \".join(new_incident_numbers)\n\n # Get the task description\n self.task_description = (\n f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) assign work to the agents with the following information: \\n'\n + f\"Incidents to assign: {incident_numbers} \\n\\n\"\n + f\"{expert_string}\"\n )\n\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Service Desk > Incidents. \\n\"\n + f\"\\n2. You have to assign the following incidents to relevant agents: {incident_numbers}. You can filter the list using each incident number and use the 'Assigned to' field to assign an incident.\\n\"\n + f\"\\n3. You have to ensure that each incident is assigned to a relevant agent based on the category of the incident.\\n\"\n + f\"\\nThe category wise agents are as follows. You can assign an incident to ANY agent from the category:\\n\"\n + f\"{expert_string}\"\n )\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": \"Can you find the Work Assignment Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n all_incident_assignments = []\n\n for incident_config in self.incident_configs:\n assigned_to = self.random.choice(self.experts[incident_config[\"category\"]])\n assigned_to = assigned_to[\"first_name\"] + \" \" + assigned_to[\"last_name\"]\n assign_incidents_subtask = [\n # Navigate to the incidents list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter incident\n FilterIncidentListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\n \"number\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n incident_config[\"number\"],\n ],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Edit incident\n EditIncidentTask(\n instance=self.instance,\n # fixed_config=incident_config,\n new_values={\"assigned_to\": assigned_to},\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=incident_config[\"sys_id\"],\n level=self.level,\n ),\n ]\n all_incident_assignments.extend(assign_incidents_subtask)\n\n config = navigate_to_protocol_subtask + all_incident_assignments\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n experts_sys_ids = {\n category: [expert[\"sys_id\"] for expert in self.experts[category]]\n for category in self.experts\n }\n for incident_config in self.incident_configs:\n incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"sys_id={incident_config['sys_id']}\",\n \"sysparm_fields\": \"category,assigned_to\",\n },\n method=\"GET\",\n )[\"result\"][0]\n if incident_response[\"category\"] != incident_config[\"category\"]:\n raise Exception(\"Corrupted incident data\")\n if not incident_response[\"assigned_to\"]:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} has not been assigned to anyone.\"\n },\n )\n if (\n incident_response[\"assigned_to\"][\"value\"]\n not in experts_sys_ids[incident_response[\"category\"]]\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} was assigned to an incorrect expert.\"\n },\n )\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident in self.incident_configs:\n db_delete_from_table(\n instance=self.instance, table=\"incident\", sys_id=incident[\"sys_id\"]\n )\n\n for experts in self.experts.values():\n for expert in experts:\n db_delete_from_table(\n instance=self.instance, table=\"sys_user\", sys_id=expert[\"sys_id\"]\n )\n\n return super().teardown()\n\n\nclass WorkAssignmentSmallTask(WorkAssignmentTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Small version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=4,\n min_assignments=3,\n num_categories=2,","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.WorkAssignmentSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.work_assignment.WorkAssignmentSmallTask#L307-L328","kind":"class","name":"WorkAssignmentSmallTask","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":307,"end_line":328,"context_start_line":287,"context_end_line":348,"code":" )\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident in self.incident_configs:\n db_delete_from_table(\n instance=self.instance, table=\"incident\", sys_id=incident[\"sys_id\"]\n )\n\n for experts in self.experts.values():\n for expert in experts:\n db_delete_from_table(\n instance=self.instance, table=\"sys_user\", sys_id=expert[\"sys_id\"]\n )\n\n return super().teardown()\n\n\nclass WorkAssignmentSmallTask(WorkAssignmentTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Small version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=4,\n min_assignments=3,\n num_categories=2,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAS\",\n )\n\n\nclass WorkAssignmentMediumTask(WorkAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Medium version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=6,\n min_assignments=5,\n num_categories=3,","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.WorkAssignmentMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.work_assignment.WorkAssignmentMediumTask#L331-L352","kind":"class","name":"WorkAssignmentMediumTask","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":331,"end_line":352,"context_start_line":311,"context_end_line":372,"code":" seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Small version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=4,\n min_assignments=3,\n num_categories=2,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAS\",\n )\n\n\nclass WorkAssignmentMediumTask(WorkAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Medium version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=6,\n min_assignments=5,\n num_categories=3,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAM\",\n )\n\n\nclass WorkAssignmentLargeTask(WorkAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Large version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=8,\n min_assignments=7,\n num_categories=4,","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.WorkAssignmentLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.work_assignment.WorkAssignmentLargeTask#L355-L376","kind":"class","name":"WorkAssignmentLargeTask","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":355,"end_line":376,"context_start_line":335,"context_end_line":396,"code":" seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Medium version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=6,\n min_assignments=5,\n num_categories=3,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAM\",\n )\n\n\nclass WorkAssignmentLargeTask(WorkAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Large version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=8,\n min_assignments=7,\n num_categories=4,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAL\",\n )\n\n\nclass PriorityAssignmentTask(CompositionalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_tasks_per_priority: int = 2,\n min_tasks_per_priority: int = 1,\n num_categories: int = None,\n seed: int = None,\n prefix: str = None,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.PriorityAssignmentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.work_assignment.PriorityAssignmentTask#L379-L731","kind":"class","name":"PriorityAssignmentTask","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":379,"end_line":731,"context_start_line":359,"context_end_line":751,"code":" seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Large version of workassignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n max_experts_per_category=2,\n max_assignments=8,\n min_assignments=7,\n num_categories=4,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"WAL\",\n )\n\n\nclass PriorityAssignmentTask(CompositionalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_tasks_per_priority: int = 2,\n min_tasks_per_priority: int = 1,\n num_categories: int = None,\n seed: int = None,\n prefix: str = None,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[tuple[AbstractServiceNowTask, dict, bool]]\n A list of tuples, each containing a subtask, its configuration and whether or not it should be validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n experts_per_category: int\n How many new agents to create for each category.\n max_assignments: int\n Maximum number of incidents created to be assigned.\n For a task, the number is randomly sampled between max_assignments and min_assignments.\n max_assignments: int\n Minimum number of incidents created to be assigned.\n For a task, the number is randomly sampled between max_assignments and min_assignments.\n prefix: str\n Prefix to name the incidents created with a unique prefix\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Priority Assignment', assign incidents to different agents in terms of priority with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Assign task to relevant expert agents based on the incident priorities\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Work Assignment: Assign Incidents to Relevant Agents\"\n super().__init__(\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n seed=seed,\n )\n\n self.task_description = None\n self.short_description = None\n self.experts_per_category = 3 # We divide agents into 'expert', 'supporter', and 'planner'\n self.max_tasks_per_priority = max_tasks_per_priority\n self.min_tasks_per_priority = min_tasks_per_priority\n # Priority 1 is urgent, 3 is moderate, 5 is planning.\n # Also priority depends on impact and urgency rather than being an independent attribute\n self.priorities = {\n 1: {\n \"impact\": 1,\n \"urgency\": 1,\n \"num_incidents\": self.random.randint(\n self.min_tasks_per_priority, self.max_tasks_per_priority\n ),\n \"agent_type\": \"expert\",\n },\n 3: {\n \"impact\": 2,\n \"urgency\": 2,\n \"num_incidents\": self.random.randint(\n self.min_tasks_per_priority, self.max_tasks_per_priority\n ),\n \"agent_type\": \"supporter\",\n },\n 5: {\n \"impact\": 3,\n \"urgency\": 3,\n \"num_incidents\": self.random.randint(\n self.min_tasks_per_priority, self.max_tasks_per_priority\n ),\n \"agent_type\": \"planner\",\n },\n }\n self.num_categories = num_categories\n if self.num_categories > 4 or self.num_categories < 1:\n raise Exception(\"Should have at least 1 and at most 4 categories.\")\n self.prefix = prefix\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.incident_configs = []\n number_assignments = sum(\n [attribute[\"num_incidents\"] for attribute in self.priorities.values()]\n )\n\n all_existing_incidents = table_api_call(\n instance=self.instance, table=\"incident\", method=\"GET\"\n )[\"result\"]\n all_incident_numbers = [incident[\"number\"] for incident in all_existing_incidents]\n\n new_incident_numbers = []\n for _ in range(number_assignments):\n incident_number = (\n self.prefix + str(id(self) % (10**8)).zfill(8)[:4] + str(random.randint(100, 999))\n )\n while (\n incident_number in all_incident_numbers or incident_number in new_incident_numbers\n ):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(random.randint(100, 999))\n )\n new_incident_numbers.append(incident_number)\n incident_category = []\n self.active_categories = self.random.choice(\n [\"hardware\", \"software\", \"network\", \"database\"], self.num_categories, replace=False\n )\n incident_number_idx = 0\n for priority, attributes in self.priorities.items():\n for _ in range(attributes[\"num_incidents\"]):\n category = self.random.choice(self.active_categories)\n incident_response = create_incident(\n instance=self.instance,\n incident_number=new_incident_numbers[incident_number_idx],\n caller_sys_id=self._base_user_sysid,\n category=category,\n priority=priority,\n impact=attributes[\n \"impact\"\n ], # priority is calculated as some combination of impact and urgency\n urgency=attributes[\"urgency\"],\n )\n self.incident_configs.append(incident_response)\n incident_category.append(\n [new_incident_numbers[incident_number_idx], category, priority]\n )\n incident_number_idx += 1\n\n self.agents_per_category = dict({category: {} for category in self.active_categories})\n for category in self.agents_per_category:\n self.agents_per_category[category][\"expert\"] = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=[\"itil\"],\n random=self.random,\n )\n self.agents_per_category[category][\"expert\"][\"full_name\"] = (\n self.agents_per_category[category][\"expert\"][\"first_name\"]\n + \" \"\n + self.agents_per_category[category][\"expert\"][\"last_name\"]\n )\n\n self.agents_per_category[category][\"supporter\"] = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=[\"itil\"],\n random=self.random,\n )\n self.agents_per_category[category][\"supporter\"][\"full_name\"] = (\n self.agents_per_category[category][\"supporter\"][\"first_name\"]\n + \" \"\n + self.agents_per_category[category][\"supporter\"][\"last_name\"]\n )\n\n self.agents_per_category[category][\"planner\"] = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=[\"itil\"],\n random=self.random,\n )\n self.agents_per_category[category][\"planner\"][\"full_name\"] = (\n self.agents_per_category[category][\"planner\"][\"first_name\"]\n + \" \"\n + self.agents_per_category[category][\"planner\"][\"last_name\"]\n )\n\n incident_numbers = \", \".join(new_incident_numbers)\n\n expert_string = \"\"\n for category in self.active_categories:\n category_experts = f\"Expert: {self.agents_per_category[category]['expert']['full_name']}, Supporter: {self.agents_per_category[category]['supporter']['full_name']}, Planner: {self.agents_per_category[category]['planner']['full_name']}\"\n expert_string += f\"{category.capitalize()} agents - {category_experts} \\n\"\n # Get the task description\n self.short_description = f\"Assign work using priority to relevant agents\"\n self.task_description = (\n f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) assign work to the agents with the following information: \\n'\n + f\"Incidents to assign: {incident_numbers} \\n\\n\"\n + f\"{expert_string}\"\n )\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Service Desk > Incidents. \\n\"\n + f\"\\n2. You have to assign the following incidents to relevant agents: {incident_numbers}. You can filter the list using each incident number and use the 'Assigned to' field to assign an incident.\\n\"\n + f\"\\n3. You have to ensure that each incident is assigned to a relevant agent based on the priority of the incident and its category. For an incident with priority 1 - Critical, assign it to an 'expert' agent of the category, for priority 3 - Moderate, assign it to a 'supporter' of the category, and for priority 5 - Planning assign it to a 'planner' of the category.\\n\"\n + f\"\\nThe category wise relevant agent are as follows:\\n\"\n + f\"{expert_string}\"\n )\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": \"Can you find the Work Assignment Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n all_incident_assignments = []\n\n for incident_config in self.incident_configs:\n assigned_to = self.agents_per_category[incident_config[\"category\"]][\n self.priorities[int(incident_config[\"priority\"])][\"agent_type\"]\n ][\"full_name\"]\n assign_incidents_subtask = [\n # Navigate to the incidents list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter incident\n FilterIncidentListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\n \"number\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n incident_config[\"number\"],\n ],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Edit incident\n EditIncidentTask(\n instance=self.instance,\n # fixed_config=incident_config,\n new_values={\"assigned_to\": assigned_to},\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=incident_config[\"sys_id\"],\n level=self.level,\n ),\n ]\n all_incident_assignments.extend(assign_incidents_subtask)\n\n config = navigate_to_protocol_subtask + all_incident_assignments\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n agents_per_category_sys_ids = {\n category: {\n agent_type: agent[\"sys_id\"]\n for agent_type, agent in self.agents_per_category[category].items()\n }\n for category in self.agents_per_category\n }\n for incident_config in self.incident_configs:\n incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"sys_id={incident_config['sys_id']}\",\n \"sysparm_fields\": \"category,assigned_to,priority\",\n },\n method=\"GET\",\n )[\"result\"][0]\n if incident_response[\"category\"] != incident_config[\"category\"]:\n raise Exception(\"Corrupted incident data\")\n if not incident_response[\"assigned_to\"]:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} has not been assigned to anyone.\"\n },\n )\n if (\n incident_response[\"assigned_to\"][\"value\"]\n != agents_per_category_sys_ids[incident_response[\"category\"]][\n self.priorities[int(incident_response[\"priority\"])][\"agent_type\"]\n ]\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} was assigned to an incorrect agent.\"\n },\n )\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident in self.incident_configs:\n db_delete_from_table(\n instance=self.instance, table=\"incident\", sys_id=incident[\"sys_id\"]\n )\n\n for category in self.agents_per_category.values():\n for agent in category.values():\n db_delete_from_table(\n instance=self.instance, table=\"sys_user\", sys_id=agent[\"sys_id\"]\n )\n\n return super().teardown()\n\n\nclass PriorityAssignmentSmallTask(PriorityAssignmentTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Small version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=2,\n fixed_config=fixed_config,\n seed=0,\n prefix=\"PAS\",","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.PriorityAssignmentSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.work_assignment.PriorityAssignmentSmallTask#L734-L752","kind":"class","name":"PriorityAssignmentSmallTask","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":734,"end_line":752,"context_start_line":714,"context_end_line":772,"code":" )\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident in self.incident_configs:\n db_delete_from_table(\n instance=self.instance, table=\"incident\", sys_id=incident[\"sys_id\"]\n )\n\n for category in self.agents_per_category.values():\n for agent in category.values():\n db_delete_from_table(\n instance=self.instance, table=\"sys_user\", sys_id=agent[\"sys_id\"]\n )\n\n return super().teardown()\n\n\nclass PriorityAssignmentSmallTask(PriorityAssignmentTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Small version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=2,\n fixed_config=fixed_config,\n seed=0,\n prefix=\"PAS\",\n )\n\n\nclass PriorityAssignmentMediumTask(PriorityAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Medium version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=3,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"PAM\",","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.PriorityAssignmentMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.work_assignment.PriorityAssignmentMediumTask#L755-L773","kind":"class","name":"PriorityAssignmentMediumTask","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":755,"end_line":773,"context_start_line":735,"context_end_line":793,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Small version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=2,\n fixed_config=fixed_config,\n seed=0,\n prefix=\"PAS\",\n )\n\n\nclass PriorityAssignmentMediumTask(PriorityAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Medium version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=3,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"PAM\",\n )\n\n\nclass PriorityAssignmentLargeTask(PriorityAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Large version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=4,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"PAL\",","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.PriorityAssignmentLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.work_assignment.PriorityAssignmentLargeTask#L776-L794","kind":"class","name":"PriorityAssignmentLargeTask","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":776,"end_line":794,"context_start_line":756,"context_end_line":804,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Medium version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=3,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"PAM\",\n )\n\n\nclass PriorityAssignmentLargeTask(PriorityAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Large version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=4,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"PAL\",\n )\n\n\n__TASKS__ = [\n WorkAssignmentSmallTask,\n WorkAssignmentMediumTask,\n WorkAssignmentLargeTask,\n PriorityAssignmentSmallTask,\n PriorityAssignmentMediumTask,\n PriorityAssignmentLargeTask,\n]","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.work_assignment.__init__#L777-L794","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":777,"end_line":794,"context_start_line":757,"context_end_line":804,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Medium version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=3,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"PAM\",\n )\n\n\nclass PriorityAssignmentLargeTask(PriorityAssignmentTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Large version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=4,\n fixed_config=fixed_config,\n seed=seed,\n prefix=\"PAL\",\n )\n\n\n__TASKS__ = [\n WorkAssignmentSmallTask,\n WorkAssignmentMediumTask,\n WorkAssignmentLargeTask,\n PriorityAssignmentSmallTask,\n PriorityAssignmentMediumTask,\n PriorityAssignmentLargeTask,\n]","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.work_assignment.setup_goal#L470-L592","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":470,"end_line":592,"context_start_line":450,"context_end_line":612,"code":" \"urgency\": 2,\n \"num_incidents\": self.random.randint(\n self.min_tasks_per_priority, self.max_tasks_per_priority\n ),\n \"agent_type\": \"supporter\",\n },\n 5: {\n \"impact\": 3,\n \"urgency\": 3,\n \"num_incidents\": self.random.randint(\n self.min_tasks_per_priority, self.max_tasks_per_priority\n ),\n \"agent_type\": \"planner\",\n },\n }\n self.num_categories = num_categories\n if self.num_categories > 4 or self.num_categories < 1:\n raise Exception(\"Should have at least 1 and at most 4 categories.\")\n self.prefix = prefix\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.incident_configs = []\n number_assignments = sum(\n [attribute[\"num_incidents\"] for attribute in self.priorities.values()]\n )\n\n all_existing_incidents = table_api_call(\n instance=self.instance, table=\"incident\", method=\"GET\"\n )[\"result\"]\n all_incident_numbers = [incident[\"number\"] for incident in all_existing_incidents]\n\n new_incident_numbers = []\n for _ in range(number_assignments):\n incident_number = (\n self.prefix + str(id(self) % (10**8)).zfill(8)[:4] + str(random.randint(100, 999))\n )\n while (\n incident_number in all_incident_numbers or incident_number in new_incident_numbers\n ):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(random.randint(100, 999))\n )\n new_incident_numbers.append(incident_number)\n incident_category = []\n self.active_categories = self.random.choice(\n [\"hardware\", \"software\", \"network\", \"database\"], self.num_categories, replace=False\n )\n incident_number_idx = 0\n for priority, attributes in self.priorities.items():\n for _ in range(attributes[\"num_incidents\"]):\n category = self.random.choice(self.active_categories)\n incident_response = create_incident(\n instance=self.instance,\n incident_number=new_incident_numbers[incident_number_idx],\n caller_sys_id=self._base_user_sysid,\n category=category,\n priority=priority,\n impact=attributes[\n \"impact\"\n ], # priority is calculated as some combination of impact and urgency\n urgency=attributes[\"urgency\"],\n )\n self.incident_configs.append(incident_response)\n incident_category.append(\n [new_incident_numbers[incident_number_idx], category, priority]\n )\n incident_number_idx += 1\n\n self.agents_per_category = dict({category: {} for category in self.active_categories})\n for category in self.agents_per_category:\n self.agents_per_category[category][\"expert\"] = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=[\"itil\"],\n random=self.random,\n )\n self.agents_per_category[category][\"expert\"][\"full_name\"] = (\n self.agents_per_category[category][\"expert\"][\"first_name\"]\n + \" \"\n + self.agents_per_category[category][\"expert\"][\"last_name\"]\n )\n\n self.agents_per_category[category][\"supporter\"] = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=[\"itil\"],\n random=self.random,\n )\n self.agents_per_category[category][\"supporter\"][\"full_name\"] = (\n self.agents_per_category[category][\"supporter\"][\"first_name\"]\n + \" \"\n + self.agents_per_category[category][\"supporter\"][\"last_name\"]\n )\n\n self.agents_per_category[category][\"planner\"] = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=[\"itil\"],\n random=self.random,\n )\n self.agents_per_category[category][\"planner\"][\"full_name\"] = (\n self.agents_per_category[category][\"planner\"][\"first_name\"]\n + \" \"\n + self.agents_per_category[category][\"planner\"][\"last_name\"]\n )\n\n incident_numbers = \", \".join(new_incident_numbers)\n\n expert_string = \"\"\n for category in self.active_categories:\n category_experts = f\"Expert: {self.agents_per_category[category]['expert']['full_name']}, Supporter: {self.agents_per_category[category]['supporter']['full_name']}, Planner: {self.agents_per_category[category]['planner']['full_name']}\"\n expert_string += f\"{category.capitalize()} agents - {category_experts} \\n\"\n # Get the task description\n self.short_description = f\"Assign work using priority to relevant agents\"\n self.task_description = (\n f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) assign work to the agents with the following information: \\n'\n + f\"Incidents to assign: {incident_numbers} \\n\\n\"\n + f\"{expert_string}\"\n )\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Service Desk > Incidents. \\n\"\n + f\"\\n2. You have to assign the following incidents to relevant agents: {incident_numbers}. You can filter the list using each incident number and use the 'Assigned to' field to assign an incident.\\n\"\n + f\"\\n3. You have to ensure that each incident is assigned to a relevant agent based on the priority of the incident and its category. For an incident with priority 1 - Critical, assign it to an 'expert' agent of the category, for priority 3 - Moderate, assign it to a 'supporter' of the category, and for priority 5 - Planning assign it to a 'planner' of the category.\\n\"\n + f\"\\nThe category wise relevant agent are as follows:\\n\"\n + f\"{expert_string}\"\n )\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.work_assignment._get_config#L594-L670","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":594,"end_line":670,"context_start_line":574,"context_end_line":690,"code":" + f\"Incidents to assign: {incident_numbers} \\n\\n\"\n + f\"{expert_string}\"\n )\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Service Desk > Incidents. \\n\"\n + f\"\\n2. You have to assign the following incidents to relevant agents: {incident_numbers}. You can filter the list using each incident number and use the 'Assigned to' field to assign an incident.\\n\"\n + f\"\\n3. You have to ensure that each incident is assigned to a relevant agent based on the priority of the incident and its category. For an incident with priority 1 - Critical, assign it to an 'expert' agent of the category, for priority 3 - Moderate, assign it to a 'supporter' of the category, and for priority 5 - Planning assign it to a 'planner' of the category.\\n\"\n + f\"\\nThe category wise relevant agent are as follows:\\n\"\n + f\"{expert_string}\"\n )\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": \"Can you find the Work Assignment Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n all_incident_assignments = []\n\n for incident_config in self.incident_configs:\n assigned_to = self.agents_per_category[incident_config[\"category\"]][\n self.priorities[int(incident_config[\"priority\"])][\"agent_type\"]\n ][\"full_name\"]\n assign_incidents_subtask = [\n # Navigate to the incidents list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter incident\n FilterIncidentListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\n \"number\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n incident_config[\"number\"],\n ],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Edit incident\n EditIncidentTask(\n instance=self.instance,\n # fixed_config=incident_config,\n new_values={\"assigned_to\": assigned_to},\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=incident_config[\"sys_id\"],\n level=self.level,\n ),\n ]\n all_incident_assignments.extend(assign_incidents_subtask)\n\n config = navigate_to_protocol_subtask + all_incident_assignments\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n agents_per_category_sys_ids = {\n category: {\n agent_type: agent[\"sys_id\"]\n for agent_type, agent in self.agents_per_category[category].items()\n }\n for category in self.agents_per_category\n }\n for incident_config in self.incident_configs:\n incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"sys_id={incident_config['sys_id']}\",\n \"sysparm_fields\": \"category,assigned_to,priority\",\n },\n method=\"GET\",\n )[\"result\"][0]\n if incident_response[\"category\"] != incident_config[\"category\"]:","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.work_assignment.validate#L672-L717","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":672,"end_line":717,"context_start_line":652,"context_end_line":737,"code":" is_validated=False,\n used_in_level_2=True,\n ),\n # Edit incident\n EditIncidentTask(\n instance=self.instance,\n # fixed_config=incident_config,\n new_values={\"assigned_to\": assigned_to},\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=incident_config[\"sys_id\"],\n level=self.level,\n ),\n ]\n all_incident_assignments.extend(assign_incidents_subtask)\n\n config = navigate_to_protocol_subtask + all_incident_assignments\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n agents_per_category_sys_ids = {\n category: {\n agent_type: agent[\"sys_id\"]\n for agent_type, agent in self.agents_per_category[category].items()\n }\n for category in self.agents_per_category\n }\n for incident_config in self.incident_configs:\n incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"sys_id={incident_config['sys_id']}\",\n \"sysparm_fields\": \"category,assigned_to,priority\",\n },\n method=\"GET\",\n )[\"result\"][0]\n if incident_response[\"category\"] != incident_config[\"category\"]:\n raise Exception(\"Corrupted incident data\")\n if not incident_response[\"assigned_to\"]:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} has not been assigned to anyone.\"\n },\n )\n if (\n incident_response[\"assigned_to\"][\"value\"]\n != agents_per_category_sys_ids[incident_response[\"category\"]][\n self.priorities[int(incident_response[\"priority\"])][\"agent_type\"]\n ]\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} was assigned to an incorrect agent.\"\n },\n )\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident in self.incident_configs:\n db_delete_from_table(\n instance=self.instance, table=\"incident\", sys_id=incident[\"sys_id\"]\n )\n\n for category in self.agents_per_category.values():\n for agent in category.values():\n db_delete_from_table(\n instance=self.instance, table=\"sys_user\", sys_id=agent[\"sys_id\"]\n )\n\n return super().teardown()\n\n\nclass PriorityAssignmentSmallTask(PriorityAssignmentTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.work_assignment.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.work_assignment.teardown#L719-L731","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":719,"end_line":731,"context_start_line":699,"context_end_line":751,"code":" },\n )\n if (\n incident_response[\"assigned_to\"][\"value\"]\n != agents_per_category_sys_ids[incident_response[\"category\"]][\n self.priorities[int(incident_response[\"priority\"])][\"agent_type\"]\n ]\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"The incident {incident_config['number']} was assigned to an incorrect agent.\"\n },\n )\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for incident in self.incident_configs:\n db_delete_from_table(\n instance=self.instance, table=\"incident\", sys_id=incident[\"sys_id\"]\n )\n\n for category in self.agents_per_category.values():\n for agent in category.values():\n db_delete_from_table(\n instance=self.instance, table=\"sys_user\", sys_id=agent[\"sys_id\"]\n )\n\n return super().teardown()\n\n\nclass PriorityAssignmentSmallTask(PriorityAssignmentTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Small version of priority assignment task.\n \"\"\"\n super().__init__(\n instance=instance,\n level=level,\n num_categories=2,\n fixed_config=fixed_config,\n seed=0,\n prefix=\"PAS\",","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems#L1-L499","kind":"module","name":"src.browsergym.workarena.tasks.compositional.mark_duplicate_problems","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":1,"end_line":499,"context_start_line":1,"context_end_line":499,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..mark_duplicate_problem import SetProblemAsDuplicateTask\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.problem import create_problem\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_PROBLEM_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass FilterProblemsAndMarkDuplicatesTask(FilterAndDoTask):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates.\"\"\"\n\n def __init__(\n self,\n seed: int,\n extra_problems: int,\n navigation_config: dict,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config=navigation_config,\n level=level,\n protocol_name=\"Problem List Cleanup\",\n )\n self.extra_problems = extra_problems # Number of non-duplicates to create; total problems will be extra_problems + 2\n self.problem_priorities = [2, 2] + [\n 1\n ] * extra_problems # The first two problems will be duplicates with the same priority; the other ones will get top priority by default\n self.problem_sys_ids = []\n self.duplicate_problems = []\n\n self.problem_hashtag = \"#SERIES-\" + self.unique_id[:10]\n self.short_description = f\"Clean-up your duplicate problems\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) clean-up your problem list (problems assigned to you) by marking duplicate problems among those with hashtag {self.problem_hashtag}.'\n\n def _setup_list(self) -> None:\n duplicated_short_descripton = f\"{fake.sentence(4)}\"\n\n for i, priority in enumerate(self.problem_priorities):\n # The first two problems will have the same short description; the other ones will get random ones\n if i < 2:\n short_description = duplicated_short_descripton\n else:\n short_description = None\n\n problem_sys_id, problem_number = create_problem(\n instance=self.instance,\n problem_hashtag=self.problem_hashtag,\n priority=priority,\n user_sys_id=self._base_user_sysid,\n short_description=short_description,\n return_number=True,\n )\n self.problem_sys_ids.append(problem_sys_id)\n\n if i < 2:\n self.duplicate_problems.append({\"number\": problem_number, \"sys_id\": problem_sys_id})\n\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n \"expected_fields_path\": EXPECTED_PROBLEM_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.problem_hashtag}\",\n ],\n }\n # the 'tasks' attribute needs to be defined by children classes\n\n def teardown(self) -> None:\n for problem_sys_id in self.problem_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"sys_id={problem_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem_sys_id,\n )\n super().teardown()\n\n\nclass BasicFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Assigned to me\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass BasicFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Assigned to me\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass BasicFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Assigned to me\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not FilterProblemsAndMarkDuplicatesTask\n]","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.FilterProblemsAndMarkDuplicatesTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.FilterProblemsAndMarkDuplicatesTask#L22-L103","kind":"class","name":"FilterProblemsAndMarkDuplicatesTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":22,"end_line":103,"context_start_line":2,"context_end_line":123,"code":"\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..mark_duplicate_problem import SetProblemAsDuplicateTask\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.problem import create_problem\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_PROBLEM_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass FilterProblemsAndMarkDuplicatesTask(FilterAndDoTask):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates.\"\"\"\n\n def __init__(\n self,\n seed: int,\n extra_problems: int,\n navigation_config: dict,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config=navigation_config,\n level=level,\n protocol_name=\"Problem List Cleanup\",\n )\n self.extra_problems = extra_problems # Number of non-duplicates to create; total problems will be extra_problems + 2\n self.problem_priorities = [2, 2] + [\n 1\n ] * extra_problems # The first two problems will be duplicates with the same priority; the other ones will get top priority by default\n self.problem_sys_ids = []\n self.duplicate_problems = []\n\n self.problem_hashtag = \"#SERIES-\" + self.unique_id[:10]\n self.short_description = f\"Clean-up your duplicate problems\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) clean-up your problem list (problems assigned to you) by marking duplicate problems among those with hashtag {self.problem_hashtag}.'\n\n def _setup_list(self) -> None:\n duplicated_short_descripton = f\"{fake.sentence(4)}\"\n\n for i, priority in enumerate(self.problem_priorities):\n # The first two problems will have the same short description; the other ones will get random ones\n if i < 2:\n short_description = duplicated_short_descripton\n else:\n short_description = None\n\n problem_sys_id, problem_number = create_problem(\n instance=self.instance,\n problem_hashtag=self.problem_hashtag,\n priority=priority,\n user_sys_id=self._base_user_sysid,\n short_description=short_description,\n return_number=True,\n )\n self.problem_sys_ids.append(problem_sys_id)\n\n if i < 2:\n self.duplicate_problems.append({\"number\": problem_number, \"sys_id\": problem_sys_id})\n\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n \"expected_fields_path\": EXPECTED_PROBLEM_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.problem_hashtag}\",\n ],\n }\n # the 'tasks' attribute needs to be defined by children classes\n\n def teardown(self) -> None:\n for problem_sys_id in self.problem_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"sys_id={problem_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem_sys_id,\n )\n super().teardown()\n\n\nclass BasicFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.BasicFilterProblemsAndMarkDuplicatesSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.BasicFilterProblemsAndMarkDuplicatesSmallTask#L106-L145","kind":"class","name":"BasicFilterProblemsAndMarkDuplicatesSmallTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":106,"end_line":145,"context_start_line":86,"context_end_line":165,"code":" ],\n }\n # the 'tasks' attribute needs to be defined by children classes\n\n def teardown(self) -> None:\n for problem_sys_id in self.problem_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"sys_id={problem_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem_sys_id,\n )\n super().teardown()\n\n\nclass BasicFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Assigned to me\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass BasicFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Assigned to me\",","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.BasicFilterProblemsAndMarkDuplicatesMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.BasicFilterProblemsAndMarkDuplicatesMediumTask#L148-L185","kind":"class","name":"BasicFilterProblemsAndMarkDuplicatesMediumTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":148,"end_line":185,"context_start_line":128,"context_end_line":205,"code":" level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass BasicFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Assigned to me\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass BasicFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Assigned to me\",","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.BasicFilterProblemsAndMarkDuplicatesLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.BasicFilterProblemsAndMarkDuplicatesLargeTask#L188-L225","kind":"class","name":"BasicFilterProblemsAndMarkDuplicatesLargeTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":188,"end_line":225,"context_start_line":168,"context_end_line":245,"code":" level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass BasicFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Assigned to me\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.PriorityFilterProblemsAndMarkDuplicatesSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.PriorityFilterProblemsAndMarkDuplicatesSmallTask#L228-L269","kind":"class","name":"PriorityFilterProblemsAndMarkDuplicatesSmallTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":228,"end_line":269,"context_start_line":208,"context_end_line":289,"code":" level=level,\n )\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"base\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.PriorityFilterProblemsAndMarkDuplicatesMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.PriorityFilterProblemsAndMarkDuplicatesMediumTask#L272-L311","kind":"class","name":"PriorityFilterProblemsAndMarkDuplicatesMediumTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":272,"end_line":311,"context_start_line":252,"context_end_line":331,"code":" self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.PriorityFilterProblemsAndMarkDuplicatesLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.PriorityFilterProblemsAndMarkDuplicatesLargeTask#L314-L353","kind":"class","name":"PriorityFilterProblemsAndMarkDuplicatesLargeTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":314,"end_line":353,"context_start_line":294,"context_end_line":373,"code":" self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass PriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first.\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.HighPriorityFilterProblemsAndMarkDuplicatesSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.HighPriorityFilterProblemsAndMarkDuplicatesSmallTask#L356-L399","kind":"class","name":"HighPriorityFilterProblemsAndMarkDuplicatesSmallTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":356,"end_line":399,"context_start_line":336,"context_end_line":419,"code":" self.problem_priorities = [1, 2] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=True,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.HighPriorityFilterProblemsAndMarkDuplicatesMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.HighPriorityFilterProblemsAndMarkDuplicatesMediumTask#L402-L443","kind":"class","name":"HighPriorityFilterProblemsAndMarkDuplicatesMediumTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":402,"end_line":443,"context_start_line":382,"context_end_line":463,"code":" self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.HighPriorityFilterProblemsAndMarkDuplicatesLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.HighPriorityFilterProblemsAndMarkDuplicatesLargeTask#L446-L487","kind":"class","name":"HighPriorityFilterProblemsAndMarkDuplicatesLargeTask","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":446,"end_line":487,"context_start_line":426,"context_end_line":499,"code":" self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not FilterProblemsAndMarkDuplicatesTask\n]","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.__init__#L451-L470","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":451,"end_line":470,"context_start_line":431,"context_end_line":490,"code":" SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nclass HighPriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):\n \"\"\"Task to filter problems with a specific hashtag and mark high priority items as duplicates. As\n a top priority item is marked as duplicate, we have to add a comment to it.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nlocal_vars = locals().copy()","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems._setup_list","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems._setup_list#L472-L487","kind":"function","name":"_setup_list","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":472,"end_line":487,"context_start_line":452,"context_end_line":499,"code":" self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"All\",\n \"application\": \"Problem\",\n },\n level=level,\n )\n self.problem_priorities = [1, 1] + [1] * extra_problems\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SetProblemAsDuplicateTask(\n instance=self.instance,\n fixed_config={\n \"target_problem\": self.duplicate_problems[1],\n \"source_problem\": self.duplicate_problems[0],\n },\n respect_problem_ordering=False,\n is_validated=True,\n used_in_level_2=True,\n goal_version=\"high priority\",\n level=self.level,\n ),\n ]\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not FilterProblemsAndMarkDuplicatesTask\n]","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.mark_duplicate_problems.teardown#L90-L103","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":90,"end_line":103,"context_start_line":70,"context_end_line":123,"code":" )\n self.problem_sys_ids.append(problem_sys_id)\n\n if i < 2:\n self.duplicate_problems.append({\"number\": problem_number, \"sys_id\": problem_sys_id})\n\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n \"expected_fields_path\": EXPECTED_PROBLEM_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.problem_hashtag}\",\n ],\n }\n # the 'tasks' attribute needs to be defined by children classes\n\n def teardown(self) -> None:\n for problem_sys_id in self.problem_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"sys_id={problem_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem_sys_id,\n )\n super().teardown()\n\n\nclass BasicFilterProblemsAndMarkDuplicatesSmallTask(\n FilterProblemsAndMarkDuplicatesTask, HumanEvalTask\n):\n \"\"\"Basic task to filter problems with a specific hashtag and mark them as duplicates. This\"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n extra_problems: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n extra_problems=extra_problems,\n fixed_config=fixed_config,","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible#L1-L693","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":1,"end_line":693,"context_start_line":1,"context_end_line":693,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateItemRequestTask\n\n\nclass DashboardRetrieveIncidentAndRequestItemInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n item: str = None,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an item for them.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"\"Order an item for the best performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n if not item:\n raise Exception(\"No item passed to assign\")\n self.item = item\n self.task_description = \"\"\n self.short_description = (\n f\"Order an {self.item} for the best performing employee from the list.\"\n )\n self.attribute_name = \"assigned_to\" # Return full name\n self.filter_than = \"greater\"\n self.prefix = \"IRI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n requested_items = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n method=\"GET\",\n )[\"result\"]\n current_requested_items_numbers = [\n requested_item[\"number\"] for requested_item in requested_items\n ]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n\n requested_item_numbers = []\n\n for _ in range(len(agent_full_names)):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n while (\n requested_item_number in current_requested_items_numbers\n or requested_item_number in requested_item_numbers\n ):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n requested_item_numbers.append(requested_item_number)\n\n self.requested_item_numbers = requested_item_numbers\n\n create_item_request_subtasks = []\n\n for agent_full_name, requested_item_number in zip(agent_full_names, requested_item_numbers):\n request_item_config = {\n \"fields\": {\n \"number\": \"Number\",\n \"cat_item\": \"Item\",\n \"requested_for\": \"Requested for\",\n \"quantity\": \"Quantity\",\n },\n \"task_fields\": [\"number\", \"cat_item\", \"requested_for\", \"quantity\"],\n \"template_record\": {\n \"number\": requested_item_number,\n \"cat_item\": self.item,\n \"requested_for\": agent_full_name,\n \"quantity\": \"1\",\n },\n \"infeasible_task_fields\": [\"number\", \"cat_item\", \"quantity\"],\n }\n request_item_config, self.infeasible_reasons = self.function(\n config=request_item_config, random=self.random\n )\n create_item_request_subtask = [\n # Navigate to the item request list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Open Records\",\n \"module\": \"Open Records > Items\",\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an item request\n CreateItemRequestTask(\n instance=self.instance,\n fixed_config=request_item_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_item_request_subtasks += create_item_request_subtask\n\n self.compositional_task = create_item_request_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Greather than or equal to the value.\\n\"\n + f\"Task: Request items with the following information: \\n\"\n + f\"Item: {self.item}, Quantity: 1.\\n\"\n + f\"Request the item for each of the agents mentioned above. You can use the item numbers: {self.requested_item_numbers}, one for each request.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"2. Find the agents with number of incidents greater than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"3. Navigate to Open Records > Items. \\n\"\n + f\"4. Create new item requests with the following field values:- 'Item: {self.item}, Quantity: 1' and assign them to each of the agents. You will create as many item requests as there are agents.\\n\"\n + f\"You should use the following request numbers for each item request (one for each): {self.requested_item_numbers}.\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for requested_item_number in self.requested_item_numbers:\n created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Su\n# ... truncated ...","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndRequestItemInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndRequestItemInfeasibleTask#L18-L184","kind":"class","name":"DashboardRetrieveIncidentAndRequestItemInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":18,"end_line":184,"context_start_line":1,"context_end_line":204,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateItemRequestTask\n\n\nclass DashboardRetrieveIncidentAndRequestItemInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n item: str = None,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an item for them.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"\"Order an item for the best performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n if not item:\n raise Exception(\"No item passed to assign\")\n self.item = item\n self.task_description = \"\"\n self.short_description = (\n f\"Order an {self.item} for the best performing employee from the list.\"\n )\n self.attribute_name = \"assigned_to\" # Return full name\n self.filter_than = \"greater\"\n self.prefix = \"IRI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n requested_items = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n method=\"GET\",\n )[\"result\"]\n current_requested_items_numbers = [\n requested_item[\"number\"] for requested_item in requested_items\n ]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n\n requested_item_numbers = []\n\n for _ in range(len(agent_full_names)):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n while (\n requested_item_number in current_requested_items_numbers\n or requested_item_number in requested_item_numbers\n ):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n requested_item_numbers.append(requested_item_number)\n\n self.requested_item_numbers = requested_item_numbers\n\n create_item_request_subtasks = []\n\n for agent_full_name, requested_item_number in zip(agent_full_names, requested_item_numbers):\n request_item_config = {\n \"fields\": {\n \"number\": \"Number\",\n \"cat_item\": \"Item\",\n \"requested_for\": \"Requested for\",\n \"quantity\": \"Quantity\",\n },\n \"task_fields\": [\"number\", \"cat_item\", \"requested_for\", \"quantity\"],\n \"template_record\": {\n \"number\": requested_item_number,\n \"cat_item\": self.item,\n \"requested_for\": agent_full_name,\n \"quantity\": \"1\",\n },\n \"infeasible_task_fields\": [\"number\", \"cat_item\", \"quantity\"],\n }\n request_item_config, self.infeasible_reasons = self.function(\n config=request_item_config, random=self.random\n )\n create_item_request_subtask = [\n # Navigate to the item request list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Open Records\",\n \"module\": \"Open Records > Items\",\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an item request\n CreateItemRequestTask(\n instance=self.instance,\n fixed_config=request_item_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_item_request_subtasks += create_item_request_subtask\n\n self.compositional_task = create_item_request_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Greather than or equal to the value.\\n\"\n + f\"Task: Request items with the following information: \\n\"\n + f\"Item: {self.item}, Quantity: 1.\\n\"\n + f\"Request the item for each of the agents mentioned above. You can use the item numbers: {self.requested_item_numbers}, one for each request.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"2. Find the agents with number of incidents greater than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"3. Navigate to Open Records > Items. \\n\"\n + f\"4. Create new item requests with the following field values:- 'Item: {self.item}, Quantity: 1' and assign them to each of the agents. You will create as many item requests as there are agents.\\n\"\n + f\"You should use the following request numbers for each item request (one for each): {self.requested_item_numbers}.\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for requested_item_number in self.requested_item_numbers:\n created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask#L187-L209","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":187,"end_line":209,"context_start_line":167,"context_end_line":229,"code":" created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask#L212-L234","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":212,"end_line":234,"context_start_line":192,"context_end_line":254,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask#L237-L259","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":237,"end_line":259,"context_start_line":217,"context_end_line":279,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask#L262-L284","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":262,"end_line":284,"context_start_line":242,"context_end_line":304,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask#L287-L309","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":287,"end_line":309,"context_start_line":267,"context_end_line":329,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask#L312-L334","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":312,"end_line":334,"context_start_line":292,"context_end_line":354,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask#L337-L359","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":337,"end_line":359,"context_start_line":317,"context_end_line":379,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask#L362-L384","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":362,"end_line":384,"context_start_line":342,"context_end_line":404,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask#L387-L409","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":387,"end_line":409,"context_start_line":367,"context_end_line":429,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask#L412-L434","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":412,"end_line":434,"context_start_line":392,"context_end_line":454,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleWithReasonTask#L437-L459","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":437,"end_line":459,"context_start_line":417,"context_end_line":479,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleTask#L462-L484","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":462,"end_line":484,"context_start_line":442,"context_end_line":504,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleWithReasonTask#L487-L509","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":487,"end_line":509,"context_start_line":467,"context_end_line":529,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleTask#L512-L534","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":512,"end_line":534,"context_start_line":492,"context_end_line":554,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleWithReasonTask#L537-L559","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":537,"end_line":559,"context_start_line":517,"context_end_line":579,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleTask#L562-L584","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":562,"end_line":584,"context_start_line":542,"context_end_line":604,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleWithReasonTask#L587-L609","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":587,"end_line":609,"context_start_line":567,"context_end_line":629,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleTask#L612-L634","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":612,"end_line":634,"context_start_line":592,"context_end_line":654,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleWithReasonTask#L637-L659","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":637,"end_line":659,"context_start_line":617,"context_end_line":679,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask#L662-L684","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":662,"end_line":684,"context_start_line":642,"context_end_line":693,"code":" instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.__init__#L665-L684","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":665,"end_line":684,"context_start_line":645,"context_end_line":693,"code":" level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.set_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.set_compositional_task#L62-L136","kind":"function","name":"set_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":62,"end_line":136,"context_start_line":42,"context_end_line":156,"code":" instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n if not item:\n raise Exception(\"No item passed to assign\")\n self.item = item\n self.task_description = \"\"\n self.short_description = (\n f\"Order an {self.item} for the best performing employee from the list.\"\n )\n self.attribute_name = \"assigned_to\" # Return full name\n self.filter_than = \"greater\"\n self.prefix = \"IRI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n requested_items = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n method=\"GET\",\n )[\"result\"]\n current_requested_items_numbers = [\n requested_item[\"number\"] for requested_item in requested_items\n ]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n\n requested_item_numbers = []\n\n for _ in range(len(agent_full_names)):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n while (\n requested_item_number in current_requested_items_numbers\n or requested_item_number in requested_item_numbers\n ):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n requested_item_numbers.append(requested_item_number)\n\n self.requested_item_numbers = requested_item_numbers\n\n create_item_request_subtasks = []\n\n for agent_full_name, requested_item_number in zip(agent_full_names, requested_item_numbers):\n request_item_config = {\n \"fields\": {\n \"number\": \"Number\",\n \"cat_item\": \"Item\",\n \"requested_for\": \"Requested for\",\n \"quantity\": \"Quantity\",\n },\n \"task_fields\": [\"number\", \"cat_item\", \"requested_for\", \"quantity\"],\n \"template_record\": {\n \"number\": requested_item_number,\n \"cat_item\": self.item,\n \"requested_for\": agent_full_name,\n \"quantity\": \"1\",\n },\n \"infeasible_task_fields\": [\"number\", \"cat_item\", \"quantity\"],\n }\n request_item_config, self.infeasible_reasons = self.function(\n config=request_item_config, random=self.random\n )\n create_item_request_subtask = [\n # Navigate to the item request list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Open Records\",\n \"module\": \"Open Records > Items\",\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an item request\n CreateItemRequestTask(\n instance=self.instance,\n fixed_config=request_item_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_item_request_subtasks += create_item_request_subtask\n\n self.compositional_task = create_item_request_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Greather than or equal to the value.\\n\"\n + f\"Task: Request items with the following information: \\n\"\n + f\"Item: {self.item}, Quantity: 1.\\n\"\n + f\"Request the item for each of the agents mentioned above. You can use the item numbers: {self.requested_item_numbers}, one for each request.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.setup_goal#L138-L163","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":138,"end_line":163,"context_start_line":118,"context_end_line":183,"code":" \"application\": \"Open Records\",\n \"module\": \"Open Records > Items\",\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an item request\n CreateItemRequestTask(\n instance=self.instance,\n fixed_config=request_item_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_item_request_subtasks += create_item_request_subtask\n\n self.compositional_task = create_item_request_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Greather than or equal to the value.\\n\"\n + f\"Task: Request items with the following information: \\n\"\n + f\"Item: {self.item}, Quantity: 1.\\n\"\n + f\"Request the item for each of the agents mentioned above. You can use the item numbers: {self.requested_item_numbers}, one for each request.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"2. Find the agents with number of incidents greater than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"3. Navigate to Open Records > Items. \\n\"\n + f\"4. Create new item requests with the following field values:- 'Item: {self.item}, Quantity: 1' and assign them to each of the agents. You will create as many item requests as there are agents.\\n\"\n + f\"You should use the following request numbers for each item request (one for each): {self.requested_item_numbers}.\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for requested_item_number in self.requested_item_numbers:\n created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item_infeasible.teardown#L165-L184","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":165,"end_line":184,"context_start_line":145,"context_end_line":204,"code":" + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Greather than or equal to the value.\\n\"\n + f\"Task: Request items with the following information: \\n\"\n + f\"Item: {self.item}, Quantity: 1.\\n\"\n + f\"Request the item for each of the agents mentioned above. You can use the item numbers: {self.requested_item_numbers}, one for each request.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"2. Find the agents with number of incidents greater than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"3. Navigate to Open Records > Items. \\n\"\n + f\"4. Create new item requests with the following field values:- 'Item: {self.item}, Quantity: 1' and assign them to each of the agents. You will create as many item requests as there are agents.\\n\"\n + f\"You should use the following request numbers for each item request (one for each): {self.requested_item_numbers}.\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for requested_item_number in self.requested_item_numbers:\n created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.find_and_order_item#L1-L345","kind":"module","name":"src.browsergym.workarena.tasks.compositional.find_and_order_item","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":1,"end_line":345,"context_start_line":1,"context_end_line":345,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.send_chat_message import SendChatMessageGenericTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.requested_items import create_requested_item\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass FilterRequestedItemsAndOrderCatalogItemTask(FilterAndDoTask, HumanEvalTask):\n \"\"\"Generic task to filter the requested items list to find what a given user has requested and order the same thing.\n Args:\n fixed_request_item: str\n The requested item to find and order.\n task_class: AbstractServiceNowTask\n The class of the task to order the item.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n fixed_request_item: str = None,\n order_task_class: AbstractServiceNowTask = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Requested Items\",\n \"application\": \"Self-Service\",\n },\n level=level,\n protocol_name=\"\",\n )\n self.fixed_request_item = fixed_request_item\n self.order_task_class = order_task_class\n # name of the user the item will be assigned to\n self.user_full_name = (\n fake.first_name()\n + \"-\"\n + fake.first_name()\n + \" \"\n + fake.last_name()\n + \"-\"\n + fake.last_name()\n )\n self.short_description = f\"Order same item as {self.user_full_name}\"\n self.task_description = f'{self.user_full_name} has recently requested an item from the service catalog. You need to order the same. Find what it is from the \"Requested Items\" list and order it from the service catalog. If possible, set the item\\'s configuration to match the following: \\n'\n self.created_user_sys_id = None # sys_id of the user to assign the item to\n self.requested_item_sys_id = None # sys_id of the requested item to order\n self.tasks = []\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n \"expected_fields_path\": EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,\n \"filter_columns\": [\n \"requested_for\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.user_full_name}\",\n ],\n }\n # Create a new user to assign the item to\n first_name = self.user_full_name.split(\" \")[0]\n last_name = self.user_full_name.split(\" \")[1]\n _, _, self.created_user_sys_id = create_user(\n self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n # Create a new requested item to order\n self.requested_item_sys_id, _ = create_requested_item(\n self.instance,\n system_name=self.fixed_request_item,\n user_sys_id=self.created_user_sys_id,\n )\n self.tasks.append(\n # After the filter has been made and the information retrieved, navigate to the catalog\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"module\": \"Service Catalog\",\n \"application\": \"Self-Service\",\n },\n used_in_level_2=True,\n is_validated=False,\n )\n )\n self.tasks.append(\n SendChatMessageGenericTask(\n instance=self.instance,\n message=\"a\",\n answer_format=\"a\",\n level=self.level,\n description=f\"Clear the existing filters on the page. \\n\",\n is_validated=False,\n use_description_in_l3=True,\n used_in_level_2=True,\n )\n )\n order_task_config = self.random.choice(self.order_task_class.all_configs())\n # task to order the item\n item_order_task = self.order_task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=order_task_config,\n used_in_level_2=True,\n is_validated=True,\n config_only_in_desc=True,\n )\n self.tasks.append(item_order_task)\n\n def teardown(self) -> None:\n # Delete the requested item and the user if they exist\n requested_item_exists = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\"sysparm_query\": f\"sys_id={self.requested_item_sys_id}\"},\n )[\"result\"]\n if requested_item_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=self.requested_item_sys_id,\n )\n user_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.created_user_sys_id}\"},\n )[\"result\"]\n if user_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.created_user_sys_id,\n )\n\n super().teardown()\n\n\nclass FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Developer Laptop (Mac)\",\n level=level,\n order_task_class=OrderDeveloperLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderIpadMiniTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"iPad mini\",\n level=level,\n order_task_class=OrderIpadMiniTask,\n )\n\n\nclass FilterRequestedItemsAndOrderIpadProTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"iPad pro\",\n level=level,\n order_task_class=OrderIpadProTask,\n )\n\n\nclass FilterRequestedItemsAndOrderSalesLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Sales Laptop\",\n level=level,\n order_task_class=OrderSalesLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderStandardLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Standard Laptop\",\n level=level,\n order_task_class=OrderStandardLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderAppleWatchTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Apple Watch\",\n level=level,\n order_task_class=OrderAppleWatchTask,\n )\n\n\nclass FilterRequestedItemsAndOrderAppleMacBookPro15Task(\n FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item='Apple MacBook Pro 15\"',\n level=level,\n order_task_class=OrderAppleMacBookPro15Task,\n )\n\n\nclass FilterRequestedItemsAndOrderDevelopmentLaptopPCTask(\n FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Development Laptop (PC)\",\n level=level,\n order_task_class=OrderDevelopmentLaptopPCTask,\n )\n\n\nclass FilterRequestedItemsAndOrderLoanerLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Notebook Computer Loaner\",\n level=level,\n order_task_class=OrderLoanerLaptopTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not FilterRequestedItemsAndOrderCatalogItemTask\n]","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderCatalogItemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderCatalogItemTask#L34-L167","kind":"class","name":"FilterRequestedItemsAndOrderCatalogItemTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":34,"end_line":167,"context_start_line":14,"context_end_line":187,"code":" OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.requested_items import create_requested_item\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass FilterRequestedItemsAndOrderCatalogItemTask(FilterAndDoTask, HumanEvalTask):\n \"\"\"Generic task to filter the requested items list to find what a given user has requested and order the same thing.\n Args:\n fixed_request_item: str\n The requested item to find and order.\n task_class: AbstractServiceNowTask\n The class of the task to order the item.\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n fixed_request_item: str = None,\n order_task_class: AbstractServiceNowTask = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Requested Items\",\n \"application\": \"Self-Service\",\n },\n level=level,\n protocol_name=\"\",\n )\n self.fixed_request_item = fixed_request_item\n self.order_task_class = order_task_class\n # name of the user the item will be assigned to\n self.user_full_name = (\n fake.first_name()\n + \"-\"\n + fake.first_name()\n + \" \"\n + fake.last_name()\n + \"-\"\n + fake.last_name()\n )\n self.short_description = f\"Order same item as {self.user_full_name}\"\n self.task_description = f'{self.user_full_name} has recently requested an item from the service catalog. You need to order the same. Find what it is from the \"Requested Items\" list and order it from the service catalog. If possible, set the item\\'s configuration to match the following: \\n'\n self.created_user_sys_id = None # sys_id of the user to assign the item to\n self.requested_item_sys_id = None # sys_id of the requested item to order\n self.tasks = []\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n \"expected_fields_path\": EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,\n \"filter_columns\": [\n \"requested_for\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.user_full_name}\",\n ],\n }\n # Create a new user to assign the item to\n first_name = self.user_full_name.split(\" \")[0]\n last_name = self.user_full_name.split(\" \")[1]\n _, _, self.created_user_sys_id = create_user(\n self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n # Create a new requested item to order\n self.requested_item_sys_id, _ = create_requested_item(\n self.instance,\n system_name=self.fixed_request_item,\n user_sys_id=self.created_user_sys_id,\n )\n self.tasks.append(\n # After the filter has been made and the information retrieved, navigate to the catalog\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"module\": \"Service Catalog\",\n \"application\": \"Self-Service\",\n },\n used_in_level_2=True,\n is_validated=False,\n )\n )\n self.tasks.append(\n SendChatMessageGenericTask(\n instance=self.instance,\n message=\"a\",\n answer_format=\"a\",\n level=self.level,\n description=f\"Clear the existing filters on the page. \\n\",\n is_validated=False,\n use_description_in_l3=True,\n used_in_level_2=True,\n )\n )\n order_task_config = self.random.choice(self.order_task_class.all_configs())\n # task to order the item\n item_order_task = self.order_task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=order_task_config,\n used_in_level_2=True,\n is_validated=True,\n config_only_in_desc=True,\n )\n self.tasks.append(item_order_task)\n\n def teardown(self) -> None:\n # Delete the requested item and the user if they exist\n requested_item_exists = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\"sysparm_query\": f\"sys_id={self.requested_item_sys_id}\"},\n )[\"result\"]\n if requested_item_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=self.requested_item_sys_id,\n )\n user_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.created_user_sys_id}\"},\n )[\"result\"]\n if user_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.created_user_sys_id,\n )\n\n super().teardown()\n\n\nclass FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Developer Laptop (Mac)\",\n level=level,\n order_task_class=OrderDeveloperLaptopTask,\n )\n\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderDeveloperLaptopTask#L170-L185","kind":"class","name":"FilterRequestedItemsAndOrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":170,"end_line":185,"context_start_line":150,"context_end_line":205,"code":" db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=self.requested_item_sys_id,\n )\n user_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.created_user_sys_id}\"},\n )[\"result\"]\n if user_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.created_user_sys_id,\n )\n\n super().teardown()\n\n\nclass FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Developer Laptop (Mac)\",\n level=level,\n order_task_class=OrderDeveloperLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderIpadMiniTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"iPad mini\",\n level=level,\n order_task_class=OrderIpadMiniTask,\n )\n\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderIpadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderIpadMiniTask#L188-L203","kind":"class","name":"FilterRequestedItemsAndOrderIpadMiniTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":188,"end_line":203,"context_start_line":168,"context_end_line":223,"code":"\n\nclass FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Developer Laptop (Mac)\",\n level=level,\n order_task_class=OrderDeveloperLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderIpadMiniTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"iPad mini\",\n level=level,\n order_task_class=OrderIpadMiniTask,\n )\n\n\nclass FilterRequestedItemsAndOrderIpadProTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"iPad pro\",\n level=level,\n order_task_class=OrderIpadProTask,\n )\n\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderIpadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderIpadProTask#L206-L221","kind":"class","name":"FilterRequestedItemsAndOrderIpadProTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":206,"end_line":221,"context_start_line":186,"context_end_line":241,"code":"\n\nclass FilterRequestedItemsAndOrderIpadMiniTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"iPad mini\",\n level=level,\n order_task_class=OrderIpadMiniTask,\n )\n\n\nclass FilterRequestedItemsAndOrderIpadProTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"iPad pro\",\n level=level,\n order_task_class=OrderIpadProTask,\n )\n\n\nclass FilterRequestedItemsAndOrderSalesLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Sales Laptop\",\n level=level,\n order_task_class=OrderSalesLaptopTask,\n )\n\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderSalesLaptopTask#L224-L239","kind":"class","name":"FilterRequestedItemsAndOrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":224,"end_line":239,"context_start_line":204,"context_end_line":259,"code":"\n\nclass FilterRequestedItemsAndOrderIpadProTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"iPad pro\",\n level=level,\n order_task_class=OrderIpadProTask,\n )\n\n\nclass FilterRequestedItemsAndOrderSalesLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Sales Laptop\",\n level=level,\n order_task_class=OrderSalesLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderStandardLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Standard Laptop\",\n level=level,\n order_task_class=OrderStandardLaptopTask,\n )\n\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderStandardLaptopTask#L242-L257","kind":"class","name":"FilterRequestedItemsAndOrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":242,"end_line":257,"context_start_line":222,"context_end_line":277,"code":"\n\nclass FilterRequestedItemsAndOrderSalesLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Sales Laptop\",\n level=level,\n order_task_class=OrderSalesLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderStandardLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Standard Laptop\",\n level=level,\n order_task_class=OrderStandardLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderAppleWatchTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Apple Watch\",\n level=level,\n order_task_class=OrderAppleWatchTask,\n )\n\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderAppleWatchTask#L260-L275","kind":"class","name":"FilterRequestedItemsAndOrderAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":260,"end_line":275,"context_start_line":240,"context_end_line":295,"code":"\n\nclass FilterRequestedItemsAndOrderStandardLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Standard Laptop\",\n level=level,\n order_task_class=OrderStandardLaptopTask,\n )\n\n\nclass FilterRequestedItemsAndOrderAppleWatchTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Apple Watch\",\n level=level,\n order_task_class=OrderAppleWatchTask,\n )\n\n\nclass FilterRequestedItemsAndOrderAppleMacBookPro15Task(\n FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item='Apple MacBook Pro 15\"',\n level=level,\n order_task_class=OrderAppleMacBookPro15Task,\n )","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderAppleMacBookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderAppleMacBookPro15Task#L278-L295","kind":"class","name":"FilterRequestedItemsAndOrderAppleMacBookPro15Task","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":278,"end_line":295,"context_start_line":258,"context_end_line":315,"code":"\n\nclass FilterRequestedItemsAndOrderAppleWatchTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Apple Watch\",\n level=level,\n order_task_class=OrderAppleWatchTask,\n )\n\n\nclass FilterRequestedItemsAndOrderAppleMacBookPro15Task(\n FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item='Apple MacBook Pro 15\"',\n level=level,\n order_task_class=OrderAppleMacBookPro15Task,\n )\n\n\nclass FilterRequestedItemsAndOrderDevelopmentLaptopPCTask(\n FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Development Laptop (PC)\",\n level=level,\n order_task_class=OrderDevelopmentLaptopPCTask,\n )","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderDevelopmentLaptopPCTask#L298-L315","kind":"class","name":"FilterRequestedItemsAndOrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":298,"end_line":315,"context_start_line":278,"context_end_line":335,"code":"class FilterRequestedItemsAndOrderAppleMacBookPro15Task(\n FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item='Apple MacBook Pro 15\"',\n level=level,\n order_task_class=OrderAppleMacBookPro15Task,\n )\n\n\nclass FilterRequestedItemsAndOrderDevelopmentLaptopPCTask(\n FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Development Laptop (PC)\",\n level=level,\n order_task_class=OrderDevelopmentLaptopPCTask,\n )\n\n\nclass FilterRequestedItemsAndOrderLoanerLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Notebook Computer Loaner\",\n level=level,\n order_task_class=OrderLoanerLaptopTask,\n )\n\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.find_and_order_item.FilterRequestedItemsAndOrderLoanerLaptopTask#L318-L333","kind":"class","name":"FilterRequestedItemsAndOrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":318,"end_line":333,"context_start_line":298,"context_end_line":345,"code":"class FilterRequestedItemsAndOrderDevelopmentLaptopPCTask(\n FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Development Laptop (PC)\",\n level=level,\n order_task_class=OrderDevelopmentLaptopPCTask,\n )\n\n\nclass FilterRequestedItemsAndOrderLoanerLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Notebook Computer Loaner\",\n level=level,\n order_task_class=OrderLoanerLaptopTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not FilterRequestedItemsAndOrderCatalogItemTask\n]","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.find_and_order_item.__init__#L319-L333","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":319,"end_line":333,"context_start_line":299,"context_end_line":345,"code":" FilterRequestedItemsAndOrderCatalogItemTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Development Laptop (PC)\",\n level=level,\n order_task_class=OrderDevelopmentLaptopPCTask,\n )\n\n\nclass FilterRequestedItemsAndOrderLoanerLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Notebook Computer Loaner\",\n level=level,\n order_task_class=OrderLoanerLaptopTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not FilterRequestedItemsAndOrderCatalogItemTask\n]","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item._setup_list","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.find_and_order_item._setup_list#L81-L140","kind":"function","name":"_setup_list","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":81,"end_line":140,"context_start_line":61,"context_end_line":160,"code":" protocol_name=\"\",\n )\n self.fixed_request_item = fixed_request_item\n self.order_task_class = order_task_class\n # name of the user the item will be assigned to\n self.user_full_name = (\n fake.first_name()\n + \"-\"\n + fake.first_name()\n + \" \"\n + fake.last_name()\n + \"-\"\n + fake.last_name()\n )\n self.short_description = f\"Order same item as {self.user_full_name}\"\n self.task_description = f'{self.user_full_name} has recently requested an item from the service catalog. You need to order the same. Find what it is from the \"Requested Items\" list and order it from the service catalog. If possible, set the item\\'s configuration to match the following: \\n'\n self.created_user_sys_id = None # sys_id of the user to assign the item to\n self.requested_item_sys_id = None # sys_id of the requested item to order\n self.tasks = []\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n \"expected_fields_path\": EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,\n \"filter_columns\": [\n \"requested_for\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.user_full_name}\",\n ],\n }\n # Create a new user to assign the item to\n first_name = self.user_full_name.split(\" \")[0]\n last_name = self.user_full_name.split(\" \")[1]\n _, _, self.created_user_sys_id = create_user(\n self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n # Create a new requested item to order\n self.requested_item_sys_id, _ = create_requested_item(\n self.instance,\n system_name=self.fixed_request_item,\n user_sys_id=self.created_user_sys_id,\n )\n self.tasks.append(\n # After the filter has been made and the information retrieved, navigate to the catalog\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"module\": \"Service Catalog\",\n \"application\": \"Self-Service\",\n },\n used_in_level_2=True,\n is_validated=False,\n )\n )\n self.tasks.append(\n SendChatMessageGenericTask(\n instance=self.instance,\n message=\"a\",\n answer_format=\"a\",\n level=self.level,\n description=f\"Clear the existing filters on the page. \\n\",\n is_validated=False,\n use_description_in_l3=True,\n used_in_level_2=True,\n )\n )\n order_task_config = self.random.choice(self.order_task_class.all_configs())\n # task to order the item\n item_order_task = self.order_task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=order_task_config,\n used_in_level_2=True,\n is_validated=True,\n config_only_in_desc=True,\n )\n self.tasks.append(item_order_task)\n\n def teardown(self) -> None:\n # Delete the requested item and the user if they exist\n requested_item_exists = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\"sysparm_query\": f\"sys_id={self.requested_item_sys_id}\"},\n )[\"result\"]\n if requested_item_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=self.requested_item_sys_id,\n )\n user_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.created_user_sys_id}\"},\n )[\"result\"]\n if user_exists:","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.find_and_order_item.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.find_and_order_item.teardown#L142-L167","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":142,"end_line":167,"context_start_line":122,"context_end_line":187,"code":" answer_format=\"a\",\n level=self.level,\n description=f\"Clear the existing filters on the page. \\n\",\n is_validated=False,\n use_description_in_l3=True,\n used_in_level_2=True,\n )\n )\n order_task_config = self.random.choice(self.order_task_class.all_configs())\n # task to order the item\n item_order_task = self.order_task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=order_task_config,\n used_in_level_2=True,\n is_validated=True,\n config_only_in_desc=True,\n )\n self.tasks.append(item_order_task)\n\n def teardown(self) -> None:\n # Delete the requested item and the user if they exist\n requested_item_exists = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\"sysparm_query\": f\"sys_id={self.requested_item_sys_id}\"},\n )[\"result\"]\n if requested_item_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=self.requested_item_sys_id,\n )\n user_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.created_user_sys_id}\"},\n )[\"result\"]\n if user_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.created_user_sys_id,\n )\n\n super().teardown()\n\n\nclass FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n fixed_request_item=\"Developer Laptop (Mac)\",\n level=level,\n order_task_class=OrderDeveloperLaptopTask,\n )\n\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.maximize_investment_return#L1-L1763","kind":"module","name":"src.browsergym.workarena.tasks.compositional.maximize_investment_return","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1,"end_line":1763,"context_start_line":1,"context_end_line":1763,"code":"import re\n\nfrom faker import Faker\nfrom typing import List, Tuple\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.send_chat_message import SendChatMessageForBudgetAllocationTask\n\nfrom .base import HumanEvalTask\nfrom .delete_record import DeleteExpenseLineKnapsack\nfrom .filter_and_do import FilterAndDoTask\nfrom .utils.knapsack import KnapsackInstanceGenarator\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.expense_line import create_expense_line\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass FilterExpensesAndAllocateInvestmentsTask(FilterAndDoTask):\n \"\"\"Task to filter expenses and allocate investments.\n Args:\n num_expenses: list[int]\n The range to choose the number of expenses from\n budget: int\n The budget to allocate to the expenses\n mode: str\n Mode of generation. Choice of \"random\", \"trivial\", \"single_item\", \"single_item_uniform\", \"n_items\"\n - random: Randomly generate the instance and return it; guaranteed to have a unique optimal solution\n - trivial: Generate a trivial instance with all items fitting in the knapsack; return the instance\n - single_item: Generate an instance where the optimal solution has only one item\n - n_items: Generate an instance with all items having uniform weight and value; n items fitting in the knapsack\n - single_item_uniform: Generate an instance with all items having uniform weight and value; optimal solution has only one item and it can be any\n answer_format: str\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n num_items_uniform: int\n The number of items to generate in the \"n_items\" mode\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n num_items_uniform: int = None,\n answer_format: str = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Expense Lines\",\n \"application\": \"Cost\",\n },\n level=level,\n protocol_name=\"Maximizing total investment return\",\n )\n self.num_expenses = self.random.randint(num_expenses[0], num_expenses[1] + 1)\n # In these settings, we need to vary the budget\n if mode in [\"single_item_uniform\", \"n_items\"]:\n min_budget = budget / 5\n max_budget = budget * 5\n self.budget = self.random.randint(min_budget, max_budget)\n else:\n self.budget = budget\n self.mode = mode\n self.answer_format = answer_format\n self.num_items_uniform = 1 if mode == \"single_item_uniform\" else num_items_uniform\n\n self.expense_hashtag = \"#\" + self.unique_id[:10]\n self.short_description = f\"Allocate investments to maximize returns\"\n self.expense_line_sys_ids = []\n self.expense_line_numbers = []\n self.correct_investments = (\n []\n ) # List of correct investments to check for in the chat messages\n self.incorrect_investments = (\n []\n ) # List of incorrect investments to check for in the chat messages\n self.potential_investments = None # List of tuples (cost, return) of potential investments\n self.max_return = None # Maximum return possible with optimal solution\n self.alternative_max_return_formats = (\n []\n ) # List of alternative formats for the maximum return to check for in the chat messages\n self.selected_investment_indices = (\n None # Indices of the selected investments in the optimal solution\n )\n # flag to check if the investments are correctly selected and total return is correct\n self.investments_correctly_selected = False\n self.total_return_correct = False\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n \"expected_fields_path\": EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.expense_hashtag}\",\n ],\n }\n knapsack = KnapsackInstanceGenarator(\n random=self.random,\n num_items=self.num_expenses,\n max_capacity=self.budget,\n mode=self.mode,\n num_items_in_solution=self.num_items_uniform,\n )\n # investments is a list of tuples, where each tuple is (cost, return)\n self.potential_investments, self.max_return, self.selected_investment_indices = (\n knapsack.get_instance()\n )\n # Accepted answer formats for the maximum return\n self.alternative_max_return_formats = [\n str(self.max_return), # No comma\n \"{:,}\".format(self.max_return), # Comma as thousand separator\n \"{:,}\".format(self.max_return).replace(\n \",\", \", \"\n ), # Comma as thousand separator with space after\n \"{:,}\".format(self.max_return).replace(\",\", \" \"), # Space as thousand separator\n ]\n\n for i, investment in enumerate(self.potential_investments):\n expense_number = f\"EXP-{i}{self.unique_id[:10]}\"\n # Include the return inside the short description\n short_description = f\"Build {fake.sentence(2)} - Return: {investment[1]}$ \"\n expense_sys_id, expense_number = create_expense_line(\n instance=self.instance,\n amount=investment[0],\n number=expense_number,\n date=str(fake.date_this_year(before_today=True, after_today=False)),\n short_description=short_description,\n expense_hashtag=self.expense_hashtag,\n user_sys_id=self._base_user_sysid,\n )\n self.expense_line_sys_ids.append(expense_sys_id)\n self.expense_line_numbers.append(expense_number)\n\n # In this setting there is only one valid answer\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n for i, investment in enumerate(self.potential_investments):\n if i in self.selected_investment_indices:\n self.correct_investments.append(self.expense_line_numbers[i])\n else:\n self.incorrect_investments.append(self.expense_line_numbers[i])\n # In this setting, many answers are possible, it's only a matter of respecting the number of items in the solution\n # We store values here just so the cheat function can work uniformly\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n for i, investment in enumerate(self.potential_investments):\n if i < self.num_items_uniform:\n self.correct_investments.append(self.expense_line_numbers[i])\n else:\n self.incorrect_investments.append(self.expense_line_numbers[i])\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n def check_total_return(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Simple check that validates that the total return is correct.\"\"\"\n if self.total_return_correct:\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct total return.\"},\n )\n\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n for format in self.alternative_max_return_formats:\n if format in answer:\n self.total_return_correct = True\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct answer.\"},\n )\n\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect answer.\"},\n )\n\n def check_correct_investments_sent_in_chat(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Check that the correct investments have been selected and their numbers have been sent in the chat\"\"\"\n if not self.investments_correctly_selected:\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n\n # In these settings, there is only one valid answer\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n # Check that the correct investments have been selected\n for investment in self.correct_investments:\n if investment not in answer:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Investment missing from selected list.\"},\n )\n # Check that the incorrect investments have not been selected\n for investment in self.incorrect_investments:\n if investment in answer:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect investment selected.\"},\n )\n # In those settings, many answers are possible, it's only a matter of respecting the number of items in the solution\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n # Extract the expense line numbers from the answer\n pattern = r\"EXP-\\w+-\\w+\"\n matches = re.findall(pattern, answer)\n if len(matches) != self.num_items_uniform:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect number of investments selected.\"},\n )\n self.correct_investments_selected = True\n\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct investments selected.\"},\n )\n\n def check_only_right_investment_kept(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Checks that only the expected investments were kept; i.e. the others were deleted\"\"\"\n for i, investment_sys_id in enumerate(self.expense_line_sys_ids):\n record_expected = i in self.selected_investment_indices\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={investment_sys_id}\"},\n )[\"result\"]\n # Missing investment that should be kept\n if record_expected and not record_exists:\n return (\n 0,\n True,\n \"\",\n {\"message\": \"Expected investment has been deleted.\"},\n )\n # Unexpected investment that should be deleted\n if not record_expected and record_exists:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Unexpected investment is present.\"},\n )\n\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct investments kept.\"},\n )\n\n def teardown(self) -> None:\n for expense_sys_id in self.expense_line_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={expense_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n super().teardown()\n\n\nclass FilterExpensesAndFindTotalReturnTask(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n answer_format: str = \"total_return_only\",\n num_items_uniform: int = 1,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=num_expenses,\n budget=budget,\n mode=mode,\n num_items_uniform=num_items_uniform,\n answer_format=answer_format,\n level=level,\n )\n self.task_description = f'Follow protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) to allocate investments to the expenses with short description containing {self.expense_hashtag} to maximize returns while fitting inside the budget of {self.budget}$. Give total return of selected investments only. '\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SendChatMessageForBudgetAllocationTask(\n instance=self.instance,\n message=f\"The total value of the investments is {self.max_return}$\",\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n )\n ]\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n reward, done, message, info = self.check_total_return(page, chat_messages)\n if reward == 1 and done:\n return FilterAndDoTask.validate(self, page, chat_messages)\n else:\n return reward, done, message, info\n\n\nclass FilterRandomExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[Abst\n# ... truncated ...","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpensesAndAllocateInvestmentsTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpensesAndAllocateInvestmentsTask#L28-L316","kind":"class","name":"FilterExpensesAndAllocateInvestmentsTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":28,"end_line":316,"context_start_line":8,"context_end_line":336,"code":"from playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.send_chat_message import SendChatMessageForBudgetAllocationTask\n\nfrom .base import HumanEvalTask\nfrom .delete_record import DeleteExpenseLineKnapsack\nfrom .filter_and_do import FilterAndDoTask\nfrom .utils.knapsack import KnapsackInstanceGenarator\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.expense_line import create_expense_line\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass FilterExpensesAndAllocateInvestmentsTask(FilterAndDoTask):\n \"\"\"Task to filter expenses and allocate investments.\n Args:\n num_expenses: list[int]\n The range to choose the number of expenses from\n budget: int\n The budget to allocate to the expenses\n mode: str\n Mode of generation. Choice of \"random\", \"trivial\", \"single_item\", \"single_item_uniform\", \"n_items\"\n - random: Randomly generate the instance and return it; guaranteed to have a unique optimal solution\n - trivial: Generate a trivial instance with all items fitting in the knapsack; return the instance\n - single_item: Generate an instance where the optimal solution has only one item\n - n_items: Generate an instance with all items having uniform weight and value; n items fitting in the knapsack\n - single_item_uniform: Generate an instance with all items having uniform weight and value; optimal solution has only one item and it can be any\n answer_format: str\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n num_items_uniform: int\n The number of items to generate in the \"n_items\" mode\n \"\"\"\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n num_items_uniform: int = None,\n answer_format: str = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Expense Lines\",\n \"application\": \"Cost\",\n },\n level=level,\n protocol_name=\"Maximizing total investment return\",\n )\n self.num_expenses = self.random.randint(num_expenses[0], num_expenses[1] + 1)\n # In these settings, we need to vary the budget\n if mode in [\"single_item_uniform\", \"n_items\"]:\n min_budget = budget / 5\n max_budget = budget * 5\n self.budget = self.random.randint(min_budget, max_budget)\n else:\n self.budget = budget\n self.mode = mode\n self.answer_format = answer_format\n self.num_items_uniform = 1 if mode == \"single_item_uniform\" else num_items_uniform\n\n self.expense_hashtag = \"#\" + self.unique_id[:10]\n self.short_description = f\"Allocate investments to maximize returns\"\n self.expense_line_sys_ids = []\n self.expense_line_numbers = []\n self.correct_investments = (\n []\n ) # List of correct investments to check for in the chat messages\n self.incorrect_investments = (\n []\n ) # List of incorrect investments to check for in the chat messages\n self.potential_investments = None # List of tuples (cost, return) of potential investments\n self.max_return = None # Maximum return possible with optimal solution\n self.alternative_max_return_formats = (\n []\n ) # List of alternative formats for the maximum return to check for in the chat messages\n self.selected_investment_indices = (\n None # Indices of the selected investments in the optimal solution\n )\n # flag to check if the investments are correctly selected and total return is correct\n self.investments_correctly_selected = False\n self.total_return_correct = False\n\n def _setup_list(self) -> None:\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n \"expected_fields_path\": EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.expense_hashtag}\",\n ],\n }\n knapsack = KnapsackInstanceGenarator(\n random=self.random,\n num_items=self.num_expenses,\n max_capacity=self.budget,\n mode=self.mode,\n num_items_in_solution=self.num_items_uniform,\n )\n # investments is a list of tuples, where each tuple is (cost, return)\n self.potential_investments, self.max_return, self.selected_investment_indices = (\n knapsack.get_instance()\n )\n # Accepted answer formats for the maximum return\n self.alternative_max_return_formats = [\n str(self.max_return), # No comma\n \"{:,}\".format(self.max_return), # Comma as thousand separator\n \"{:,}\".format(self.max_return).replace(\n \",\", \", \"\n ), # Comma as thousand separator with space after\n \"{:,}\".format(self.max_return).replace(\",\", \" \"), # Space as thousand separator\n ]\n\n for i, investment in enumerate(self.potential_investments):\n expense_number = f\"EXP-{i}{self.unique_id[:10]}\"\n # Include the return inside the short description\n short_description = f\"Build {fake.sentence(2)} - Return: {investment[1]}$ \"\n expense_sys_id, expense_number = create_expense_line(\n instance=self.instance,\n amount=investment[0],\n number=expense_number,\n date=str(fake.date_this_year(before_today=True, after_today=False)),\n short_description=short_description,\n expense_hashtag=self.expense_hashtag,\n user_sys_id=self._base_user_sysid,\n )\n self.expense_line_sys_ids.append(expense_sys_id)\n self.expense_line_numbers.append(expense_number)\n\n # In this setting there is only one valid answer\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n for i, investment in enumerate(self.potential_investments):\n if i in self.selected_investment_indices:\n self.correct_investments.append(self.expense_line_numbers[i])\n else:\n self.incorrect_investments.append(self.expense_line_numbers[i])\n # In this setting, many answers are possible, it's only a matter of respecting the number of items in the solution\n # We store values here just so the cheat function can work uniformly\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n for i, investment in enumerate(self.potential_investments):\n if i < self.num_items_uniform:\n self.correct_investments.append(self.expense_line_numbers[i])\n else:\n self.incorrect_investments.append(self.expense_line_numbers[i])\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n def check_total_return(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Simple check that validates that the total return is correct.\"\"\"\n if self.total_return_correct:\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct total return.\"},\n )\n\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n for format in self.alternative_max_return_formats:\n if format in answer:\n self.total_return_correct = True\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct answer.\"},\n )\n\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect answer.\"},\n )\n\n def check_correct_investments_sent_in_chat(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Check that the correct investments have been selected and their numbers have been sent in the chat\"\"\"\n if not self.investments_correctly_selected:\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n\n # In these settings, there is only one valid answer\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n # Check that the correct investments have been selected\n for investment in self.correct_investments:\n if investment not in answer:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Investment missing from selected list.\"},\n )\n # Check that the incorrect investments have not been selected\n for investment in self.incorrect_investments:\n if investment in answer:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect investment selected.\"},\n )\n # In those settings, many answers are possible, it's only a matter of respecting the number of items in the solution\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n # Extract the expense line numbers from the answer\n pattern = r\"EXP-\\w+-\\w+\"\n matches = re.findall(pattern, answer)\n if len(matches) != self.num_items_uniform:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect number of investments selected.\"},\n )\n self.correct_investments_selected = True\n\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct investments selected.\"},\n )\n\n def check_only_right_investment_kept(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Checks that only the expected investments were kept; i.e. the others were deleted\"\"\"\n for i, investment_sys_id in enumerate(self.expense_line_sys_ids):\n record_expected = i in self.selected_investment_indices\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={investment_sys_id}\"},\n )[\"result\"]\n # Missing investment that should be kept\n if record_expected and not record_exists:\n return (\n 0,\n True,\n \"\",\n {\"message\": \"Expected investment has been deleted.\"},\n )\n # Unexpected investment that should be deleted\n if not record_expected and record_exists:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Unexpected investment is present.\"},\n )\n\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct investments kept.\"},\n )\n\n def teardown(self) -> None:\n for expense_sys_id in self.expense_line_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={expense_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n super().teardown()\n\n\nclass FilterExpensesAndFindTotalReturnTask(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n answer_format: str = \"total_return_only\",\n num_items_uniform: int = 1,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=num_expenses,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpensesAndFindTotalReturnTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpensesAndFindTotalReturnTask#L319-L364","kind":"class","name":"FilterExpensesAndFindTotalReturnTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":319,"end_line":364,"context_start_line":299,"context_end_line":384,"code":" \"That is correct, thank you!\",\n {\"message\": \"Correct investments kept.\"},\n )\n\n def teardown(self) -> None:\n for expense_sys_id in self.expense_line_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={expense_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n super().teardown()\n\n\nclass FilterExpensesAndFindTotalReturnTask(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n answer_format: str = \"total_return_only\",\n num_items_uniform: int = 1,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=num_expenses,\n budget=budget,\n mode=mode,\n num_items_uniform=num_items_uniform,\n answer_format=answer_format,\n level=level,\n )\n self.task_description = f'Follow protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) to allocate investments to the expenses with short description containing {self.expense_hashtag} to maximize returns while fitting inside the budget of {self.budget}$. Give total return of selected investments only. '\n\n def _setup_list(self) -> None:\n super()._setup_list()\n self.tasks = [\n SendChatMessageForBudgetAllocationTask(\n instance=self.instance,\n message=f\"The total value of the investments is {self.max_return}$\",\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n )\n ]\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n reward, done, message, info = self.check_total_return(page, chat_messages)\n if reward == 1 and done:\n return FilterAndDoTask.validate(self, page, chat_messages)\n else:\n return reward, done, message, info\n\n\nclass FilterRandomExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndFindTotalReturnSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndFindTotalReturnSmallTask#L367-L385","kind":"class","name":"FilterRandomExpensesAndFindTotalReturnSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":367,"end_line":385,"context_start_line":347,"context_end_line":405,"code":" self.tasks = [\n SendChatMessageForBudgetAllocationTask(\n instance=self.instance,\n message=f\"The total value of the investments is {self.max_return}$\",\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n )\n ]\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n reward, done, message, info = self.check_total_return(page, chat_messages)\n if reward == 1 and done:\n return FilterAndDoTask.validate(self, page, chat_messages)\n else:\n return reward, done, message, info\n\n\nclass FilterRandomExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndFindTotalReturnMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndFindTotalReturnMediumTask#L388-L404","kind":"class","name":"FilterRandomExpensesAndFindTotalReturnMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":388,"end_line":404,"context_start_line":368,"context_end_line":424,"code":" FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndFindTotalReturnLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndFindTotalReturnLargeTask#L407-L423","kind":"class","name":"FilterRandomExpensesAndFindTotalReturnLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":407,"end_line":423,"context_start_line":387,"context_end_line":443,"code":"\nclass FilterRandomExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndFindTotalReturnSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndFindTotalReturnSmallTask#L426-L444","kind":"class","name":"FilterTrivialExpensesAndFindTotalReturnSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":426,"end_line":444,"context_start_line":406,"context_end_line":464,"code":"\nclass FilterRandomExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndFindTotalReturnMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndFindTotalReturnMediumTask#L447-L463","kind":"class","name":"FilterTrivialExpensesAndFindTotalReturnMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":447,"end_line":463,"context_start_line":427,"context_end_line":483,"code":" FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndFindTotalReturnLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndFindTotalReturnLargeTask#L466-L482","kind":"class","name":"FilterTrivialExpensesAndFindTotalReturnLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":466,"end_line":482,"context_start_line":446,"context_end_line":502,"code":"\nclass FilterTrivialExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndFindTotalReturnSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndFindTotalReturnSmallTask#L485-L503","kind":"class","name":"FilterSingleItemExpensesAndFindTotalReturnSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":485,"end_line":503,"context_start_line":465,"context_end_line":523,"code":"\nclass FilterTrivialExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndFindTotalReturnMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndFindTotalReturnMediumTask#L506-L522","kind":"class","name":"FilterSingleItemExpensesAndFindTotalReturnMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":506,"end_line":522,"context_start_line":486,"context_end_line":542,"code":" FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndFindTotalReturnLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndFindTotalReturnLargeTask#L525-L541","kind":"class","name":"FilterSingleItemExpensesAndFindTotalReturnLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":525,"end_line":541,"context_start_line":505,"context_end_line":561,"code":"\nclass FilterSingleItemExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndFindTotalReturnSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndFindTotalReturnSmallTask#L544-L562","kind":"class","name":"FilterSingleItemUniformExpensesAndFindTotalReturnSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":544,"end_line":562,"context_start_line":524,"context_end_line":582,"code":"\nclass FilterSingleItemExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndFindTotalReturnMediumTask(\n FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndFindTotalReturnMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndFindTotalReturnMediumTask#L565-L583","kind":"class","name":"FilterSingleItemUniformExpensesAndFindTotalReturnMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":565,"end_line":583,"context_start_line":545,"context_end_line":603,"code":" FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndFindTotalReturnMediumTask(\n FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndFindTotalReturnLargeTask(\n FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndFindTotalReturnLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndFindTotalReturnLargeTask#L586-L604","kind":"class","name":"FilterSingleItemUniformExpensesAndFindTotalReturnLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":586,"end_line":604,"context_start_line":566,"context_end_line":624,"code":" FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndFindTotalReturnLargeTask(\n FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterTwoItemsUniformExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTwoItemsUniformExpensesAndFindTotalReturnSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTwoItemsUniformExpensesAndFindTotalReturnSmallTask#L607-L626","kind":"class","name":"FilterTwoItemsUniformExpensesAndFindTotalReturnSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":607,"end_line":626,"context_start_line":587,"context_end_line":646,"code":" FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterTwoItemsUniformExpensesAndFindTotalReturnSmallTask(\n FilterExpensesAndFindTotalReturnTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=2,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndFindTotalReturnMediumTask(\n FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndFindTotalReturnMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndFindTotalReturnMediumTask#L629-L648","kind":"class","name":"FilterThreeItemsUniformExpensesAndFindTotalReturnMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":629,"end_line":648,"context_start_line":609,"context_end_line":668,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=2,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndFindTotalReturnMediumTask(\n FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndFindTotalReturnLargeTask(\n FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndFindTotalReturnLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndFindTotalReturnLargeTask#L651-L670","kind":"class","name":"FilterThreeItemsUniformExpensesAndFindTotalReturnLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":651,"end_line":670,"context_start_line":631,"context_end_line":690,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndFindTotalReturnLargeTask(\n FilterExpensesAndFindTotalReturnTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterExpensesAndSelectInvestmentsTask(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n num_items_uniform: int = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=num_expenses,\n budget=budget,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpensesAndSelectInvestmentsTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpensesAndSelectInvestmentsTask#L673-L720","kind":"class","name":"FilterExpensesAndSelectInvestmentsTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":673,"end_line":720,"context_start_line":653,"context_end_line":740,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterExpensesAndSelectInvestmentsTask(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n num_items_uniform: int = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=num_expenses,\n budget=budget,\n mode=mode,\n level=level,\n answer_format=\"investments_only\",\n num_items_uniform=num_items_uniform,\n )\n self.task_description = f'Follow protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) to allocate investments to the expenses with short description containing {self.expense_hashtag} to maximize returns while fitting inside the budget of {self.budget}$. Give selected investments only. '\n\n def _setup_list(self) -> None:\n super()._setup_list()\n message = f\"The correct investments to select are: {', '.join(self.correct_investments)}\"\n self.tasks.append(\n SendChatMessageForBudgetAllocationTask(\n instance=self.instance,\n message=message,\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n )\n )\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n reward, done, message, info = self.check_correct_investments_sent_in_chat(\n page, chat_messages\n )\n if reward == 1 and done:\n return FilterAndDoTask.validate(self, page, chat_messages)\n else:\n return reward, done, message, info\n\n\nclass FilterRandomExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndSelectInvestmentsSmallTask#L723-L741","kind":"class","name":"FilterRandomExpensesAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":723,"end_line":741,"context_start_line":703,"context_end_line":761,"code":" instance=self.instance,\n message=message,\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n )\n )\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n reward, done, message, info = self.check_correct_investments_sent_in_chat(\n page, chat_messages\n )\n if reward == 1 and done:\n return FilterAndDoTask.validate(self, page, chat_messages)\n else:\n return reward, done, message, info\n\n\nclass FilterRandomExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndSelectInvestmentsMediumTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndSelectInvestmentsMediumTask#L744-L760","kind":"class","name":"FilterRandomExpensesAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":744,"end_line":760,"context_start_line":724,"context_end_line":780,"code":" FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndSelectInvestmentsMediumTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndSelectInvestmentsLargeTask#L763-L779","kind":"class","name":"FilterRandomExpensesAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":763,"end_line":779,"context_start_line":743,"context_end_line":799,"code":"\nclass FilterRandomExpensesAndSelectInvestmentsMediumTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndSelectInvestmentsSmallTask#L782-L800","kind":"class","name":"FilterTrivialExpensesAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":782,"end_line":800,"context_start_line":762,"context_end_line":820,"code":"\nclass FilterRandomExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndSelectInvestmentsMediumTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndSelectInvestmentsMediumTask#L803-L819","kind":"class","name":"FilterTrivialExpensesAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":803,"end_line":819,"context_start_line":783,"context_end_line":839,"code":" FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndSelectInvestmentsMediumTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesAndSelectInvestmentsLargeTask#L822-L838","kind":"class","name":"FilterTrivialExpensesAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":822,"end_line":838,"context_start_line":802,"context_end_line":858,"code":"\nclass FilterTrivialExpensesAndSelectInvestmentsMediumTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndSelectInvestmentsSmallTask#L841-L859","kind":"class","name":"FilterSingleItemExpensesAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":841,"end_line":859,"context_start_line":821,"context_end_line":879,"code":"\nclass FilterTrivialExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndSelectInvestmentsMediumTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndSelectInvestmentsMediumTask#L862-L880","kind":"class","name":"FilterSingleItemExpensesAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":862,"end_line":880,"context_start_line":842,"context_end_line":900,"code":" FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndSelectInvestmentsMediumTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndSelectInvestmentsLargeTask#L883-L899","kind":"class","name":"FilterSingleItemExpensesAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":883,"end_line":899,"context_start_line":863,"context_end_line":919,"code":" FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndSelectInvestmentsSmallTask#L902-L920","kind":"class","name":"FilterSingleItemUniformExpensesAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":902,"end_line":920,"context_start_line":882,"context_end_line":940,"code":"\nclass FilterSingleItemExpensesAndSelectInvestmentsLargeTask(FilterExpensesAndSelectInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndSelectInvestmentsMediumTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndSelectInvestmentsMediumTask#L923-L941","kind":"class","name":"FilterSingleItemUniformExpensesAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":923,"end_line":941,"context_start_line":903,"context_end_line":961,"code":" FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndSelectInvestmentsMediumTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndSelectInvestmentsLargeTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndSelectInvestmentsLargeTask#L944-L962","kind":"class","name":"FilterSingleItemUniformExpensesAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":944,"end_line":962,"context_start_line":924,"context_end_line":982,"code":" FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndSelectInvestmentsLargeTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterTwoItemsUniformExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTwoItemsUniformExpensesAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTwoItemsUniformExpensesAndSelectInvestmentsSmallTask#L965-L984","kind":"class","name":"FilterTwoItemsUniformExpensesAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":965,"end_line":984,"context_start_line":945,"context_end_line":1004,"code":" FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterTwoItemsUniformExpensesAndSelectInvestmentsSmallTask(\n FilterExpensesAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=2,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndSelectInvestmentsMediumTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndSelectInvestmentsMediumTask#L987-L1006","kind":"class","name":"FilterThreeItemsUniformExpensesAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":987,"end_line":1006,"context_start_line":967,"context_end_line":1026,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=2,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndSelectInvestmentsMediumTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndSelectInvestmentsLargeTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndSelectInvestmentsLargeTask#L1009-L1028","kind":"class","name":"FilterThreeItemsUniformExpensesAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1009,"end_line":1028,"context_start_line":989,"context_end_line":1048,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndSelectInvestmentsLargeTask(\n FilterExpensesAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterExpensesFindTotalReturnAndSelectInvestmentsTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode=\"random\",\n num_items_uniform: int = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=num_expenses,\n budget=budget,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpensesFindTotalReturnAndSelectInvestmentsTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpensesFindTotalReturnAndSelectInvestmentsTask#L1031-L1082","kind":"class","name":"FilterExpensesFindTotalReturnAndSelectInvestmentsTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1031,"end_line":1082,"context_start_line":1011,"context_end_line":1102,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterExpensesFindTotalReturnAndSelectInvestmentsTask(FilterExpensesAndFindTotalReturnTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode=\"random\",\n num_items_uniform: int = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=num_expenses,\n budget=budget,\n mode=mode,\n num_items_uniform=num_items_uniform,\n answer_format=\"total_return_and_investments\",\n level=level,\n )\n self.task_description = f'Follow protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) to allocate investments to the expenses with short description containing {self.expense_hashtag} to maximize returns while fitting inside the budget of {self.budget}$. Give selected investments and total return. '\n\n def _setup_list(self) -> None:\n super()._setup_list()\n message = f\"The correct investments to select are: {', '.join(self.correct_investments)} and their total return is {self.max_return}$\"\n self.tasks = [\n SendChatMessageForBudgetAllocationTask(\n instance=self.instance,\n message=message,\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n )\n ]\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n reward, done, message, info = self.check_correct_investments_sent_in_chat(\n page, chat_messages\n )\n if not (reward == 1 and done):\n return reward, done, message, info\n\n reward, done, message, info = self.check_total_return(page, chat_messages)\n if not (reward == 1 and done):\n return reward, done, message, info\n\n return FilterAndDoTask.validate(self, page, chat_messages)\n\n\nclass FilterRandomExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesFindTotalReturnAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesFindTotalReturnAndSelectInvestmentsSmallTask#L1085-L1103","kind":"class","name":"FilterRandomExpensesFindTotalReturnAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1085,"end_line":1103,"context_start_line":1065,"context_end_line":1123,"code":" budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n )\n ]\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n reward, done, message, info = self.check_correct_investments_sent_in_chat(\n page, chat_messages\n )\n if not (reward == 1 and done):\n return reward, done, message, info\n\n reward, done, message, info = self.check_total_return(page, chat_messages)\n if not (reward == 1 and done):\n return reward, done, message, info\n\n return FilterAndDoTask.validate(self, page, chat_messages)\n\n\nclass FilterRandomExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesFindTotalReturnAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesFindTotalReturnAndSelectInvestmentsMediumTask#L1106-L1124","kind":"class","name":"FilterRandomExpensesFindTotalReturnAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1106,"end_line":1124,"context_start_line":1086,"context_end_line":1144,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesFindTotalReturnAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesFindTotalReturnAndSelectInvestmentsLargeTask#L1127-L1145","kind":"class","name":"FilterRandomExpensesFindTotalReturnAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1127,"end_line":1145,"context_start_line":1107,"context_end_line":1165,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsSmallTask#L1148-L1166","kind":"class","name":"FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1148,"end_line":1166,"context_start_line":1128,"context_end_line":1186,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsMediumTask#L1169-L1187","kind":"class","name":"FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1169,"end_line":1187,"context_start_line":1149,"context_end_line":1207,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsLargeTask#L1190-L1208","kind":"class","name":"FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1190,"end_line":1208,"context_start_line":1170,"context_end_line":1228,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterTrivialExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsSmallTask#L1211-L1229","kind":"class","name":"FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1211,"end_line":1229,"context_start_line":1191,"context_end_line":1249,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"trivial\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsMediumTask#L1232-L1250","kind":"class","name":"FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1232,"end_line":1250,"context_start_line":1212,"context_end_line":1270,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsLargeTask#L1253-L1271","kind":"class","name":"FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1253,"end_line":1271,"context_start_line":1233,"context_end_line":1291,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask#L1274-L1292","kind":"class","name":"FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1274,"end_line":1292,"context_start_line":1254,"context_end_line":1312,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask#L1295-L1313","kind":"class","name":"FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1295,"end_line":1313,"context_start_line":1275,"context_end_line":1333,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask#L1316-L1334","kind":"class","name":"FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1316,"end_line":1334,"context_start_line":1296,"context_end_line":1354,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterTwoItemsUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTwoItemsUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTwoItemsUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask#L1337-L1356","kind":"class","name":"FilterTwoItemsUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1337,"end_line":1356,"context_start_line":1317,"context_end_line":1376,"code":" FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterTwoItemsUniformExpensesFindTotalReturnAndSelectInvestmentsSmallTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=2,\n )\n\n\nclass FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask#L1359-L1378","kind":"class","name":"FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1359,"end_line":1378,"context_start_line":1339,"context_end_line":1398,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=2,\n )\n\n\nclass FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsMediumTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask#L1381-L1400","kind":"class","name":"FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1381,"end_line":1400,"context_start_line":1361,"context_end_line":1420,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesFindTotalReturnAndSelectInvestmentsLargeTask(\n FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterExpenseLinesAndDeleteWrongInvestments(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_expenses: List[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n num_items_uniform: int = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_expenses=num_expenses,\n budget=budget,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpenseLinesAndDeleteWrongInvestments","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterExpenseLinesAndDeleteWrongInvestments#L1403-L1492","kind":"class","name":"FilterExpenseLinesAndDeleteWrongInvestments","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1403,"end_line":1492,"context_start_line":1383,"context_end_line":1512,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterExpenseLinesAndDeleteWrongInvestments(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_expenses: List[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n num_items_uniform: int = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_expenses=num_expenses,\n budget=budget,\n mode=mode,\n answer_format=\"cleanup\",\n num_items_uniform=num_items_uniform,\n level=level,\n )\n self.task_description = f'Follow protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) to allocate investments to the expenses with short description containing {self.expense_hashtag} to maximize returns while fitting inside the budget of {self.budget}$. Delete the investments that were not selected. '\n\n def _setup_list(self) -> None:\n super()._setup_list()\n # in modes \"n_items\", \"single_item_uniform\", this yields one of many valid solutions\n for i, expense_line_number in enumerate(self.incorrect_investments):\n skip_description = i > 0\n expense_line_sys_id = self.expense_line_sys_ids[i]\n self.tasks.append(\n DeleteExpenseLineKnapsack(\n instance=self.instance,\n record_number=expense_line_number,\n record_sys_id=expense_line_sys_id,\n fixed_config={\n \"field_name\": \"number\",\n \"field_value\": f\"{expense_line_number}\",\n },\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n skip_description=skip_description,\n )\n )\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n # Check that the correct investments have been selected\n for investment in self.correct_investments:\n if investment not in [expense[\"number\"] for expense in expenses]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Investment missing from selected list.\"},\n )\n # Check that the incorrect investments have not been selected\n for investment in self.incorrect_investments:\n if investment in [expense[\"number\"] for expense in expenses]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect investment selected.\"},\n )\n # In those settings, many answers are possible, it's only a matter of respecting the number of items in the solution\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n if len(expenses) != self.num_items_uniform:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect number of investments selected.\"},\n )\n reward, done, message, info = FilterAndDoTask.validate(self, page, chat_messages)\n\n return reward, done, message, info\n\n\nclass FilterRandomExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndDeleteWrongInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndDeleteWrongInvestmentsSmallTask#L1495-L1513","kind":"class","name":"FilterRandomExpensesAndDeleteWrongInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1495,"end_line":1513,"context_start_line":1475,"context_end_line":1533,"code":" return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect investment selected.\"},\n )\n # In those settings, many answers are possible, it's only a matter of respecting the number of items in the solution\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n if len(expenses) != self.num_items_uniform:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect number of investments selected.\"},\n )\n reward, done, message, info = FilterAndDoTask.validate(self, page, chat_messages)\n\n return reward, done, message, info\n\n\nclass FilterRandomExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndDeleteWrongInvestmentsMediumTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndDeleteWrongInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndDeleteWrongInvestmentsMediumTask#L1516-L1534","kind":"class","name":"FilterRandomExpensesAndDeleteWrongInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1516,"end_line":1534,"context_start_line":1496,"context_end_line":1554,"code":" FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndDeleteWrongInvestmentsMediumTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndDeleteWrongInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterRandomExpensesAndDeleteWrongInvestmentsLargeTask#L1537-L1555","kind":"class","name":"FilterRandomExpensesAndDeleteWrongInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1537,"end_line":1555,"context_start_line":1517,"context_end_line":1575,"code":" FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterRandomExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndDeleteWrongInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndDeleteWrongInvestmentsSmallTask#L1558-L1576","kind":"class","name":"FilterSingleItemExpensesAndDeleteWrongInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1558,"end_line":1576,"context_start_line":1538,"context_end_line":1596,"code":" FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"random\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndDeleteWrongInvestmentsMediumTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndDeleteWrongInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndDeleteWrongInvestmentsMediumTask#L1579-L1597","kind":"class","name":"FilterSingleItemExpensesAndDeleteWrongInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1579,"end_line":1597,"context_start_line":1559,"context_end_line":1617,"code":" FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndDeleteWrongInvestmentsMediumTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndDeleteWrongInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemExpensesAndDeleteWrongInvestmentsLargeTask#L1600-L1618","kind":"class","name":"FilterSingleItemExpensesAndDeleteWrongInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1600,"end_line":1618,"context_start_line":1580,"context_end_line":1638,"code":" FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsSmallTask#L1621-L1639","kind":"class","name":"FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1621,"end_line":1639,"context_start_line":1601,"context_end_line":1659,"code":" FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsMediumTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsMediumTask#L1642-L1660","kind":"class","name":"FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1642,"end_line":1660,"context_start_line":1622,"context_end_line":1680,"code":" FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsMediumTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsLargeTask#L1663-L1681","kind":"class","name":"FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1663,"end_line":1681,"context_start_line":1643,"context_end_line":1701,"code":" FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterSingleItemUniformExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterTwoItemsUniformExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTwoItemsUniformExpensesAndDeleteWrongInvestmentsSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterTwoItemsUniformExpensesAndDeleteWrongInvestmentsSmallTask#L1684-L1703","kind":"class","name":"FilterTwoItemsUniformExpensesAndDeleteWrongInvestmentsSmallTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1684,"end_line":1703,"context_start_line":1664,"context_end_line":1723,"code":" FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"single_item_uniform\",\n level=level,\n )\n\n\nclass FilterTwoItemsUniformExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=2,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsMediumTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsMediumTask#L1706-L1725","kind":"class","name":"FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsMediumTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1706,"end_line":1725,"context_start_line":1686,"context_end_line":1745,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=2,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsMediumTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.maximize_investment_return.FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsLargeTask#L1728-L1747","kind":"class","name":"FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsLargeTask","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1728,"end_line":1747,"context_start_line":1708,"context_end_line":1763,"code":"):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not FilterExpensesAndAllocateInvestmentsTask\n and var is not FilterExpensesAndFindTotalReturnTask\n and var is not FilterExpenseLinesAndDeleteWrongInvestments\n and var is not FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n and var is not FilterExpensesAndSelectInvestmentsTask\n]","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.maximize_investment_return.__init__#L1731-L1747","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1731,"end_line":1747,"context_start_line":1711,"context_end_line":1763,"code":" seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[6, 8],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nclass FilterThreeItemsUniformExpensesAndDeleteWrongInvestmentsLargeTask(\n FilterExpenseLinesAndDeleteWrongInvestments\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[9, 12],\n budget=150000,\n mode=\"n_items\",\n level=level,\n num_items_uniform=3,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not FilterExpensesAndAllocateInvestmentsTask\n and var is not FilterExpensesAndFindTotalReturnTask\n and var is not FilterExpenseLinesAndDeleteWrongInvestments\n and var is not FilterExpensesFindTotalReturnAndSelectInvestmentsTask\n and var is not FilterExpensesAndSelectInvestmentsTask\n]","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return._setup_list","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.maximize_investment_return._setup_list#L1428-L1450","kind":"function","name":"_setup_list","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1428,"end_line":1450,"context_start_line":1408,"context_end_line":1470,"code":" fixed_config: List[AbstractServiceNowTask] = None,\n num_expenses: List[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n num_items_uniform: int = None,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_expenses=num_expenses,\n budget=budget,\n mode=mode,\n answer_format=\"cleanup\",\n num_items_uniform=num_items_uniform,\n level=level,\n )\n self.task_description = f'Follow protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) to allocate investments to the expenses with short description containing {self.expense_hashtag} to maximize returns while fitting inside the budget of {self.budget}$. Delete the investments that were not selected. '\n\n def _setup_list(self) -> None:\n super()._setup_list()\n # in modes \"n_items\", \"single_item_uniform\", this yields one of many valid solutions\n for i, expense_line_number in enumerate(self.incorrect_investments):\n skip_description = i > 0\n expense_line_sys_id = self.expense_line_sys_ids[i]\n self.tasks.append(\n DeleteExpenseLineKnapsack(\n instance=self.instance,\n record_number=expense_line_number,\n record_sys_id=expense_line_sys_id,\n fixed_config={\n \"field_name\": \"number\",\n \"field_value\": f\"{expense_line_number}\",\n },\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n skip_description=skip_description,\n )\n )\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n # Check that the correct investments have been selected\n for investment in self.correct_investments:\n if investment not in [expense[\"number\"] for expense in expenses]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Investment missing from selected list.\"},","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.maximize_investment_return.validate#L1452-L1492","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1452,"end_line":1492,"context_start_line":1432,"context_end_line":1512,"code":" skip_description = i > 0\n expense_line_sys_id = self.expense_line_sys_ids[i]\n self.tasks.append(\n DeleteExpenseLineKnapsack(\n instance=self.instance,\n record_number=expense_line_number,\n record_sys_id=expense_line_sys_id,\n fixed_config={\n \"field_name\": \"number\",\n \"field_value\": f\"{expense_line_number}\",\n },\n used_in_level_2=True,\n is_validated=False,\n budget=self.budget,\n answer_format=self.answer_format,\n level=self.level,\n skip_description=skip_description,\n )\n )\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n # Check that the correct investments have been selected\n for investment in self.correct_investments:\n if investment not in [expense[\"number\"] for expense in expenses]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Investment missing from selected list.\"},\n )\n # Check that the incorrect investments have not been selected\n for investment in self.incorrect_investments:\n if investment in [expense[\"number\"] for expense in expenses]:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect investment selected.\"},\n )\n # In those settings, many answers are possible, it's only a matter of respecting the number of items in the solution\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n if len(expenses) != self.num_items_uniform:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect number of investments selected.\"},\n )\n reward, done, message, info = FilterAndDoTask.validate(self, page, chat_messages)\n\n return reward, done, message, info\n\n\nclass FilterRandomExpensesAndDeleteWrongInvestmentsSmallTask(\n FilterExpenseLinesAndDeleteWrongInvestments, HumanEvalTask\n):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=[3, 5],\n budget=150000,\n mode=\"random\",\n level=level,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.check_total_return","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.maximize_investment_return.check_total_return#L174-L210","kind":"function","name":"check_total_return","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":174,"end_line":210,"context_start_line":154,"context_end_line":230,"code":"\n # In this setting there is only one valid answer\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n for i, investment in enumerate(self.potential_investments):\n if i in self.selected_investment_indices:\n self.correct_investments.append(self.expense_line_numbers[i])\n else:\n self.incorrect_investments.append(self.expense_line_numbers[i])\n # In this setting, many answers are possible, it's only a matter of respecting the number of items in the solution\n # We store values here just so the cheat function can work uniformly\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n for i, investment in enumerate(self.potential_investments):\n if i < self.num_items_uniform:\n self.correct_investments.append(self.expense_line_numbers[i])\n else:\n self.incorrect_investments.append(self.expense_line_numbers[i])\n\n def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:\n super().validate(page, chat_messages)\n\n def check_total_return(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Simple check that validates that the total return is correct.\"\"\"\n if self.total_return_correct:\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct total return.\"},\n )\n\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n for format in self.alternative_max_return_formats:\n if format in answer:\n self.total_return_correct = True\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct answer.\"},\n )\n\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect answer.\"},\n )\n\n def check_correct_investments_sent_in_chat(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Check that the correct investments have been selected and their numbers have been sent in the chat\"\"\"\n if not self.investments_correctly_selected:\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n\n # In these settings, there is only one valid answer\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n # Check that the correct investments have been selected\n for investment in self.correct_investments:","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.check_correct_investments_sent_in_chat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.maximize_investment_return.check_correct_investments_sent_in_chat#L212-L266","kind":"function","name":"check_correct_investments_sent_in_chat","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":212,"end_line":266,"context_start_line":192,"context_end_line":286,"code":" \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n for format in self.alternative_max_return_formats:\n if format in answer:\n self.total_return_correct = True\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct answer.\"},\n )\n\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect answer.\"},\n )\n\n def check_correct_investments_sent_in_chat(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Check that the correct investments have been selected and their numbers have been sent in the chat\"\"\"\n if not self.investments_correctly_selected:\n if chat_messages and chat_messages[-1][\"role\"] == \"assistant\":\n answer = chat_messages[-1][\"message\"]\n else:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The assistant did not provide an answer.\"},\n )\n\n # In these settings, there is only one valid answer\n if self.mode in [\"random\", \"trivial\", \"single_item\"]:\n # Check that the correct investments have been selected\n for investment in self.correct_investments:\n if investment not in answer:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Investment missing from selected list.\"},\n )\n # Check that the incorrect investments have not been selected\n for investment in self.incorrect_investments:\n if investment in answer:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect investment selected.\"},\n )\n # In those settings, many answers are possible, it's only a matter of respecting the number of items in the solution\n elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n # Extract the expense line numbers from the answer\n pattern = r\"EXP-\\w+-\\w+\"\n matches = re.findall(pattern, answer)\n if len(matches) != self.num_items_uniform:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect number of investments selected.\"},\n )\n self.correct_investments_selected = True\n\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct investments selected.\"},\n )\n\n def check_only_right_investment_kept(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Checks that only the expected investments were kept; i.e. the others were deleted\"\"\"\n for i, investment_sys_id in enumerate(self.expense_line_sys_ids):\n record_expected = i in self.selected_investment_indices\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={investment_sys_id}\"},\n )[\"result\"]\n # Missing investment that should be kept\n if record_expected and not record_exists:\n return (\n 0,\n True,\n \"\",\n {\"message\": \"Expected investment has been deleted.\"},\n )","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.check_only_right_investment_kept","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.maximize_investment_return.check_only_right_investment_kept#L268-L301","kind":"function","name":"check_only_right_investment_kept","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":268,"end_line":301,"context_start_line":248,"context_end_line":321,"code":" elif self.mode in [\"n_items\", \"single_item_uniform\"]:\n # Extract the expense line numbers from the answer\n pattern = r\"EXP-\\w+-\\w+\"\n matches = re.findall(pattern, answer)\n if len(matches) != self.num_items_uniform:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Incorrect number of investments selected.\"},\n )\n self.correct_investments_selected = True\n\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct investments selected.\"},\n )\n\n def check_only_right_investment_kept(\n self, page: Page, chat_messages: List[str]\n ) -> Tuple[float, bool, str, dict]:\n \"\"\"Checks that only the expected investments were kept; i.e. the others were deleted\"\"\"\n for i, investment_sys_id in enumerate(self.expense_line_sys_ids):\n record_expected = i in self.selected_investment_indices\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={investment_sys_id}\"},\n )[\"result\"]\n # Missing investment that should be kept\n if record_expected and not record_exists:\n return (\n 0,\n True,\n \"\",\n {\"message\": \"Expected investment has been deleted.\"},\n )\n # Unexpected investment that should be deleted\n if not record_expected and record_exists:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Unexpected investment is present.\"},\n )\n\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct investments kept.\"},\n )\n\n def teardown(self) -> None:\n for expense_sys_id in self.expense_line_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={expense_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n super().teardown()\n\n\nclass FilterExpensesAndFindTotalReturnTask(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.maximize_investment_return.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.maximize_investment_return.teardown#L303-L316","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":303,"end_line":316,"context_start_line":283,"context_end_line":336,"code":" True,\n \"\",\n {\"message\": \"Expected investment has been deleted.\"},\n )\n # Unexpected investment that should be deleted\n if not record_expected and record_exists:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Unexpected investment is present.\"},\n )\n\n return (\n 1,\n True,\n \"That is correct, thank you!\",\n {\"message\": \"Correct investments kept.\"},\n )\n\n def teardown(self) -> None:\n for expense_sys_id in self.expense_line_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={expense_sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n super().teardown()\n\n\nclass FilterExpensesAndFindTotalReturnTask(FilterExpensesAndAllocateInvestmentsTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_expenses: list[int] = [3, 4],\n budget: int = 150000,\n mode: str = \"random\",\n answer_format: str = \"total_return_only\",\n num_items_uniform: int = 1,\n level: int = 2,\n ):\n super().__init__(\n seed,\n instance,\n fixed_config,\n num_expenses=num_expenses,","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible#L1-L235","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":1,"end_line":235,"context_start_line":1,"context_end_line":235,"code":"from playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateProblemTask\n\n\nclass DashboardRetrieveIncidentAndCreateProblemInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n self.task_description = \"\"\n self.short_description = \"Create a problem for the worst performing employee from the list.\"\n self.attribute_name = \"assigned_to\"\n self.filter_than = \"lesser\"\n self.prefix = \"ICP\"\n\n def set_compositional_task(self) -> None:\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n create_problem_subtasks = []\n for agent_full_name in agent_full_names:\n problem_config = {\n \"fields\": {\n \"short_description\": \"Problem statement\",\n \"description\": \"Description\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n \"impact\": \"Impact\",\n },\n \"task_fields\": [\n \"short_description\",\n \"description\",\n \"urgency\",\n \"assigned_to\",\n \"impact\",\n ],\n \"template_record\": {\n \"description\": \"Compulsory training for employee in probation\",\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1 - High\",\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n \"infeasible_task_fields\": [\"short_description\", \"description\", \"urgency\", \"impact\"],\n }\n problem_config, self.infeasible_reasons = self.function(\n config=problem_config, random=self.random\n )\n\n create_problem_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a problem\n CreateProblemTask(\n instance=self.instance,\n fixed_config=problem_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_problem_subtasks += create_problem_subtask\n\n self.compositional_task = create_problem_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report(\n user_roles=[\n \"itil\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ]\n )\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create problems with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation'.\\n\"\n + f\"Assign the problems you create to the agents mentioned above.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the agents with number of incidents less than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"\\n3. Navigate to All > Problems. \\n\"\n + f\"\\n4. Create new problems with the following field values:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation' and assign them to each of the agents.\"\n + \"\\nYou will create as many problems as there are agents.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndCreateProblemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemInfeasibleTask(\n DashboardRetrieveIncidentAndCreateProblemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.DashboardRetrieveIncidentAndCreateProblemInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.DashboardRetrieveIncidentAndCreateProblemInfeasibleTask#L17-L166","kind":"class","name":"DashboardRetrieveIncidentAndCreateProblemInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":17,"end_line":166,"context_start_line":1,"context_end_line":186,"code":"from playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateProblemTask\n\n\nclass DashboardRetrieveIncidentAndCreateProblemInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n self.task_description = \"\"\n self.short_description = \"Create a problem for the worst performing employee from the list.\"\n self.attribute_name = \"assigned_to\"\n self.filter_than = \"lesser\"\n self.prefix = \"ICP\"\n\n def set_compositional_task(self) -> None:\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n create_problem_subtasks = []\n for agent_full_name in agent_full_names:\n problem_config = {\n \"fields\": {\n \"short_description\": \"Problem statement\",\n \"description\": \"Description\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n \"impact\": \"Impact\",\n },\n \"task_fields\": [\n \"short_description\",\n \"description\",\n \"urgency\",\n \"assigned_to\",\n \"impact\",\n ],\n \"template_record\": {\n \"description\": \"Compulsory training for employee in probation\",\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1 - High\",\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n \"infeasible_task_fields\": [\"short_description\", \"description\", \"urgency\", \"impact\"],\n }\n problem_config, self.infeasible_reasons = self.function(\n config=problem_config, random=self.random\n )\n\n create_problem_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a problem\n CreateProblemTask(\n instance=self.instance,\n fixed_config=problem_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_problem_subtasks += create_problem_subtask\n\n self.compositional_task = create_problem_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report(\n user_roles=[\n \"itil\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ]\n )\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create problems with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation'.\\n\"\n + f\"Assign the problems you create to the agents mentioned above.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the agents with number of incidents less than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"\\n3. Navigate to All > Problems. \\n\"\n + f\"\\n4. Create new problems with the following field values:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation' and assign them to each of the agents.\"\n + \"\\nYou will create as many problems as there are agents.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndCreateProblemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.DashboardRetrieveIncidentAndMinCreateProblemInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.DashboardRetrieveIncidentAndMinCreateProblemInfeasibleWithReasonTask#L169-L196","kind":"class","name":"DashboardRetrieveIncidentAndMinCreateProblemInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":169,"end_line":196,"context_start_line":149,"context_end_line":216,"code":"\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndCreateProblemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemInfeasibleTask(\n DashboardRetrieveIncidentAndCreateProblemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.DashboardRetrieveIncidentAndMinCreateProblemInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.DashboardRetrieveIncidentAndMinCreateProblemInfeasibleTask#L199-L226","kind":"class","name":"DashboardRetrieveIncidentAndMinCreateProblemInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":199,"end_line":226,"context_start_line":179,"context_end_line":235,"code":" \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemInfeasibleTask(\n DashboardRetrieveIncidentAndCreateProblemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.__init__#L202-L226","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":202,"end_line":226,"context_start_line":182,"context_end_line":235,"code":" -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemInfeasibleTask(\n DashboardRetrieveIncidentAndCreateProblemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.set_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.set_compositional_task#L55-L113","kind":"function","name":"set_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":55,"end_line":113,"context_start_line":35,"context_end_line":133,"code":" The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n self.task_description = \"\"\n self.short_description = \"Create a problem for the worst performing employee from the list.\"\n self.attribute_name = \"assigned_to\"\n self.filter_than = \"lesser\"\n self.prefix = \"ICP\"\n\n def set_compositional_task(self) -> None:\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n create_problem_subtasks = []\n for agent_full_name in agent_full_names:\n problem_config = {\n \"fields\": {\n \"short_description\": \"Problem statement\",\n \"description\": \"Description\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n \"impact\": \"Impact\",\n },\n \"task_fields\": [\n \"short_description\",\n \"description\",\n \"urgency\",\n \"assigned_to\",\n \"impact\",\n ],\n \"template_record\": {\n \"description\": \"Compulsory training for employee in probation\",\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1 - High\",\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n \"infeasible_task_fields\": [\"short_description\", \"description\", \"urgency\", \"impact\"],\n }\n problem_config, self.infeasible_reasons = self.function(\n config=problem_config, random=self.random\n )\n\n create_problem_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a problem\n CreateProblemTask(\n instance=self.instance,\n fixed_config=problem_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_problem_subtasks += create_problem_subtask\n\n self.compositional_task = create_problem_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report(\n user_roles=[\n \"itil\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ]\n )\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create problems with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation'.\\n\"\n + f\"Assign the problems you create to the agents mentioned above.\"","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.setup_goal#L115-L148","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":115,"end_line":148,"context_start_line":95,"context_end_line":168,"code":" \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a problem\n CreateProblemTask(\n instance=self.instance,\n fixed_config=problem_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_problem_subtasks += create_problem_subtask\n\n self.compositional_task = create_problem_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report(\n user_roles=[\n \"itil\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ]\n )\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create problems with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation'.\\n\"\n + f\"Assign the problems you create to the agents mentioned above.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the agents with number of incidents less than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"\\n3. Navigate to All > Problems. \\n\"\n + f\"\\n4. Create new problems with the following field values:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation' and assign them to each of the agents.\"\n + \"\\nYou will create as many problems as there are agents.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem_infeasible.teardown#L150-L166","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":150,"end_line":166,"context_start_line":130,"context_end_line":186,"code":" + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create problems with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation'.\\n\"\n + f\"Assign the problems you create to the agents mentioned above.\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the agents with number of incidents less than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"\\n3. Navigate to All > Problems. \\n\"\n + f\"\\n4. Create new problems with the following field values:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation' and assign them to each of the agents.\"\n + \"\\nYou will create as many problems as there are agents.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndCreateProblemInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.workload_balancing#L1-L396","kind":"module","name":"src.browsergym.workarena.tasks.compositional.workload_balancing","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":1,"end_line":396,"context_start_line":1,"context_end_line":396,"code":"import faker\n\nfake = faker.Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import WorkLoadBalancingMinMaxRetrievalTask\nfrom ..form import EditProblemTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import FilterProblemListForWorkLoadBalancingTask\nfrom ..navigation import AllMenuTask\nfrom ..send_chat_message import SendChatMessageGenericTask\n\nfrom ...api.problem import create_problem\nfrom ...api.report import create_report\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...instance import SNowInstance\n\n\nclass WorkloadBalancingTask(CompositionalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n min_users: int = 2,\n max_users: int = 4,\n # Ranges to randomly choose from\n max_problem_range: int = [3, 4],\n mid_problem_range: int = [2, 3],\n min_problem_range: int = [1, 2],\n ) -> None:\n \"\"\"\n Workload balancing task:\n - Navigate to the KB\n - Find the protocol for re-distributing work\n - Find the user who has the greatest number of problems assigned to them\n - Re-assign the problems to the user having the least number of problems assigned to them\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n min_users: int\n The minimum number of users to create and to distribute the problems to\n max_users: int\n The maximum number of users to create and to distribute the problems to\n max_problem_range: list[int, int]\n The range of the number of problems to assign to the user with the most problems\n mid_problem_range: list[int, int]\n The range of the number of problems to assign to all users but the ones with the least/most problems\n min_problem_range: list[int, int]\n The range of the number of problems to assign to the user with the least problems\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Agent Workload Balancing', re-distribute the problems with description containing {self.problem_hashtag}\"\n short_description: str\n A short description of the task to be completed. e.g. \"Balance the workload for problems with description containing {self.problem_hashtag}\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Agent Workload Balancing\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n\n self.problem_hashtag = (\n f\"#PRB{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems\n )\n self.task_description = None\n self.short_description = None\n self.min_users = min_users\n self.max_users = max_users\n self.max_problem_range = max_problem_range\n self.mid_problem_range = mid_problem_range\n self.min_problem_range = min_problem_range\n\n # In this case, there will only be 2 users as the values are bound and the top value is excluded in the randint function\n if self.min_users == 2 and self.max_users == 3:\n assert (\n self.min_problem_range[1] <= self.max_problem_range[0]\n ), \"The problem ranges should not overlap\"\n # In this case, there will be 3 users\n else:\n assert (\n self.min_problem_range[1] <= self.mid_problem_range[0]\n and self.mid_problem_range[1] <= self.max_problem_range[0]\n ), \"The problem ranges should not overlap\"\n assert self.max_problem_range[1] <= 6, \"The maximum number of problems should not exceed 6\"\n\n self.plot_title = None # The title of the plot created for the report\n self.lowest_priority = 0 # The lowest priority of the problems; a high number indicates a low priority. Set in the setup_goal method\n\n self.category_name = (\n fake.word() + \"-\" + fake.word()\n ) # The category of the problems to re-distribute\n self.category_sys_id = (\n None # The sys_id of the category created for the task; create in the setup_goal method\n )\n self.user_sys_ids = [] # The sys_ids of the users created for the task\n self.problem_sys_ids = [] # The sys_ids of the problems created for the task\n self.report_sys_id = None # The sys_id of the report created for the task\n self.user_with_most_problems = None # The name of the user that has the most problems assigned; defined in the setup_goal method\n self.user_with_least_problems = None # The name of the user that has the least problems assigned; defined in the setup_goal method\n self.problem_to_edit_sys_id = (\n None # The sys_id of the problem to re-assign; defined in the setup_goal method\n )\n self.problem_to_edit_number = (\n None # The number of the problem to re-assign; defined in the setup_goal method\n )\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n num_users = self.random.randint(self.min_users, self.max_users)\n max_problems = self.random.randint(*self.max_problem_range)\n min_problems = self.random.randint(*self.min_problem_range)\n\n # Create users, create problems and assign problems to users\n for i in range(num_users):\n if i == 0:\n num_problems = max_problems\n elif i == num_users - 1:\n num_problems = min_problems\n else:\n num_problems = self.random.randint(*self.mid_problem_range)\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n user_full_name = first_name + \" \" + last_name\n _, _, user_sys_id = create_user(\n instance=self.instance,\n first_name=first_name,\n last_name=last_name,\n user_roles=[\n \"admin\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ],\n random=self.random,\n )\n self.user_sys_ids.append(user_sys_id)\n\n if i == 0:\n self.user_with_most_problems = user_full_name\n elif i == num_users - 1:\n self.user_with_least_problems = user_full_name\n\n # Create problems assigned to current user\n for j in range(num_problems):\n # Assign a priority to the problem; 1 being highest priority and 5 being lowest\n # the use of j % 5 is to ensure that the priority is between 1 and 5 and that there is\n # only one problem with the lowest priority\n priority = (j % 5) + 1\n self.lowest_priority = max(self.lowest_priority, priority)\n problem_sys_id, problem_number = create_problem(\n instance=self.instance,\n user_sys_id=user_sys_id,\n priority=priority,\n problem_hashtag=self.problem_hashtag,\n return_number=True,\n )\n # The last problem created is the one to re-assign as it will be the one with the lowest priority (highest priority value)\n # and the first user will be the one with the most problems assigned\n if i == 0 and j == num_problems - 1:\n self.problem_to_edit_sys_id = problem_sys_id\n self.problem_to_edit_number = problem_number\n self.problem_sys_ids.append(problem_sys_id)\n\n # Create a report for problems of the current category\n self.report_sys_id, plot_title = create_report(\n instance=self.instance,\n table=\"problem\",\n filter_hashtag=self.problem_hashtag,\n field=\"assigned_to\",\n plot_title=f\"Problems for with hashtag {self.problem_hashtag}\",\n random=self.random,\n )\n self.plot_title = plot_title\n\n # Sample a configuration\n config = self._get_config()\n # Get the task description\n self.short_description = (\n f\"Balance the workload for problems with hashtag {self.problem_hashtag}\"\n )\n self.task_description = f\"Referring to company protocol '{self.protocol_name}' (located in the \\\"Company Protocols\\\" knowledge base) re-distribute the problems with hashtag={self.problem_hashtag}.\"\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\" \"\"\"\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n find_most_and_least_busy_users_subtask = [\n # Navigate to the reports list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Reports\",\n \"module\": \"Administration > All\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_report_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n WorkLoadBalancingMinMaxRetrievalTask(\n instance=self.instance,\n fixed_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.plot_title,\n \"chart_series\": \"\",\n \"question\": \"min\",\n },\n is_validated=False,\n used_in_level_2=True,\n problem_hashtag=self.problem_hashtag,\n ),\n ]\n\n reassign_problem_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the problems by assignee, and priority = lowest priority\n # The existence of a lower priority problem is guaranteed\n FilterProblemListForWorkLoadBalancingTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\", \"priority\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n f\"{self.user_with_most_problems}\",\n f\"{self.lowest_priority}\",\n ],\n },\n is_validated=False,\n used_in_level_2=True,\n goal=f'Create a filter to find problems where \\n - \"Assigned to\" is the user with the most problems assigned and \\n - \"Priority\" is \"{self.lowest_priority}\".',\n ),\n # Assign a problem to the user with the least problems assigned to them\n EditProblemTask(\n instance=self.instance,\n new_values={\"assigned_to\": f\"{self.user_with_least_problems}\"},\n record_sys_id=self.problem_to_edit_sys_id,\n record_number=self.problem_to_edit_number,\n is_validated=True,\n used_in_level_2=True,\n level=self.level,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + find_most_and_least_busy_users_subtask\n + reassign_problem_subtask\n )\n\n return config\n\n def teardown(self) -> None:\n # Delete the users\n for user_sys_id in self.user_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={user_sys_id}\"},\n )\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=user_sys_id,\n )\n # Delete the problems\n for problem_sys_id in self.problem_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"sys_id={problem_sys_id}\"},\n )\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem_sys_id,\n )\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n super().teardown()\n\n\nclass WorkloadBalancingSmallTask(WorkloadBalancingTask, HumanEvalTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=2,\n max_users=4,\n max_problem_range=[4, 6],\n mid_problem_range=[3, 4],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingMediumTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=5,\n max_users=7,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingLargeTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=8,\n max_users=10,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, WorkloadBalancingTask)\n and var is not WorkloadBalancingTask\n]","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing.WorkloadBalancingTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.workload_balancing.WorkloadBalancingTask#L24-L343","kind":"class","name":"WorkloadBalancingTask","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":24,"end_line":343,"context_start_line":4,"context_end_line":363,"code":"\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import WorkLoadBalancingMinMaxRetrievalTask\nfrom ..form import EditProblemTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import FilterProblemListForWorkLoadBalancingTask\nfrom ..navigation import AllMenuTask\nfrom ..send_chat_message import SendChatMessageGenericTask\n\nfrom ...api.problem import create_problem\nfrom ...api.report import create_report\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...instance import SNowInstance\n\n\nclass WorkloadBalancingTask(CompositionalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n min_users: int = 2,\n max_users: int = 4,\n # Ranges to randomly choose from\n max_problem_range: int = [3, 4],\n mid_problem_range: int = [2, 3],\n min_problem_range: int = [1, 2],\n ) -> None:\n \"\"\"\n Workload balancing task:\n - Navigate to the KB\n - Find the protocol for re-distributing work\n - Find the user who has the greatest number of problems assigned to them\n - Re-assign the problems to the user having the least number of problems assigned to them\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n min_users: int\n The minimum number of users to create and to distribute the problems to\n max_users: int\n The maximum number of users to create and to distribute the problems to\n max_problem_range: list[int, int]\n The range of the number of problems to assign to the user with the most problems\n mid_problem_range: list[int, int]\n The range of the number of problems to assign to all users but the ones with the least/most problems\n min_problem_range: list[int, int]\n The range of the number of problems to assign to the user with the least problems\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Agent Workload Balancing', re-distribute the problems with description containing {self.problem_hashtag}\"\n short_description: str\n A short description of the task to be completed. e.g. \"Balance the workload for problems with description containing {self.problem_hashtag}\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Agent Workload Balancing\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n\n self.problem_hashtag = (\n f\"#PRB{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems\n )\n self.task_description = None\n self.short_description = None\n self.min_users = min_users\n self.max_users = max_users\n self.max_problem_range = max_problem_range\n self.mid_problem_range = mid_problem_range\n self.min_problem_range = min_problem_range\n\n # In this case, there will only be 2 users as the values are bound and the top value is excluded in the randint function\n if self.min_users == 2 and self.max_users == 3:\n assert (\n self.min_problem_range[1] <= self.max_problem_range[0]\n ), \"The problem ranges should not overlap\"\n # In this case, there will be 3 users\n else:\n assert (\n self.min_problem_range[1] <= self.mid_problem_range[0]\n and self.mid_problem_range[1] <= self.max_problem_range[0]\n ), \"The problem ranges should not overlap\"\n assert self.max_problem_range[1] <= 6, \"The maximum number of problems should not exceed 6\"\n\n self.plot_title = None # The title of the plot created for the report\n self.lowest_priority = 0 # The lowest priority of the problems; a high number indicates a low priority. Set in the setup_goal method\n\n self.category_name = (\n fake.word() + \"-\" + fake.word()\n ) # The category of the problems to re-distribute\n self.category_sys_id = (\n None # The sys_id of the category created for the task; create in the setup_goal method\n )\n self.user_sys_ids = [] # The sys_ids of the users created for the task\n self.problem_sys_ids = [] # The sys_ids of the problems created for the task\n self.report_sys_id = None # The sys_id of the report created for the task\n self.user_with_most_problems = None # The name of the user that has the most problems assigned; defined in the setup_goal method\n self.user_with_least_problems = None # The name of the user that has the least problems assigned; defined in the setup_goal method\n self.problem_to_edit_sys_id = (\n None # The sys_id of the problem to re-assign; defined in the setup_goal method\n )\n self.problem_to_edit_number = (\n None # The number of the problem to re-assign; defined in the setup_goal method\n )\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n num_users = self.random.randint(self.min_users, self.max_users)\n max_problems = self.random.randint(*self.max_problem_range)\n min_problems = self.random.randint(*self.min_problem_range)\n\n # Create users, create problems and assign problems to users\n for i in range(num_users):\n if i == 0:\n num_problems = max_problems\n elif i == num_users - 1:\n num_problems = min_problems\n else:\n num_problems = self.random.randint(*self.mid_problem_range)\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n user_full_name = first_name + \" \" + last_name\n _, _, user_sys_id = create_user(\n instance=self.instance,\n first_name=first_name,\n last_name=last_name,\n user_roles=[\n \"admin\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ],\n random=self.random,\n )\n self.user_sys_ids.append(user_sys_id)\n\n if i == 0:\n self.user_with_most_problems = user_full_name\n elif i == num_users - 1:\n self.user_with_least_problems = user_full_name\n\n # Create problems assigned to current user\n for j in range(num_problems):\n # Assign a priority to the problem; 1 being highest priority and 5 being lowest\n # the use of j % 5 is to ensure that the priority is between 1 and 5 and that there is\n # only one problem with the lowest priority\n priority = (j % 5) + 1\n self.lowest_priority = max(self.lowest_priority, priority)\n problem_sys_id, problem_number = create_problem(\n instance=self.instance,\n user_sys_id=user_sys_id,\n priority=priority,\n problem_hashtag=self.problem_hashtag,\n return_number=True,\n )\n # The last problem created is the one to re-assign as it will be the one with the lowest priority (highest priority value)\n # and the first user will be the one with the most problems assigned\n if i == 0 and j == num_problems - 1:\n self.problem_to_edit_sys_id = problem_sys_id\n self.problem_to_edit_number = problem_number\n self.problem_sys_ids.append(problem_sys_id)\n\n # Create a report for problems of the current category\n self.report_sys_id, plot_title = create_report(\n instance=self.instance,\n table=\"problem\",\n filter_hashtag=self.problem_hashtag,\n field=\"assigned_to\",\n plot_title=f\"Problems for with hashtag {self.problem_hashtag}\",\n random=self.random,\n )\n self.plot_title = plot_title\n\n # Sample a configuration\n config = self._get_config()\n # Get the task description\n self.short_description = (\n f\"Balance the workload for problems with hashtag {self.problem_hashtag}\"\n )\n self.task_description = f\"Referring to company protocol '{self.protocol_name}' (located in the \\\"Company Protocols\\\" knowledge base) re-distribute the problems with hashtag={self.problem_hashtag}.\"\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\" \"\"\"\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n find_most_and_least_busy_users_subtask = [\n # Navigate to the reports list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Reports\",\n \"module\": \"Administration > All\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_report_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n WorkLoadBalancingMinMaxRetrievalTask(\n instance=self.instance,\n fixed_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.plot_title,\n \"chart_series\": \"\",\n \"question\": \"min\",\n },\n is_validated=False,\n used_in_level_2=True,\n problem_hashtag=self.problem_hashtag,\n ),\n ]\n\n reassign_problem_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the problems by assignee, and priority = lowest priority\n # The existence of a lower priority problem is guaranteed\n FilterProblemListForWorkLoadBalancingTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\", \"priority\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n f\"{self.user_with_most_problems}\",\n f\"{self.lowest_priority}\",\n ],\n },\n is_validated=False,\n used_in_level_2=True,\n goal=f'Create a filter to find problems where \\n - \"Assigned to\" is the user with the most problems assigned and \\n - \"Priority\" is \"{self.lowest_priority}\".',\n ),\n # Assign a problem to the user with the least problems assigned to them\n EditProblemTask(\n instance=self.instance,\n new_values={\"assigned_to\": f\"{self.user_with_least_problems}\"},\n record_sys_id=self.problem_to_edit_sys_id,\n record_number=self.problem_to_edit_number,\n is_validated=True,\n used_in_level_2=True,\n level=self.level,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + find_most_and_least_busy_users_subtask\n + reassign_problem_subtask\n )\n\n return config\n\n def teardown(self) -> None:\n # Delete the users\n for user_sys_id in self.user_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={user_sys_id}\"},\n )\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=user_sys_id,\n )\n # Delete the problems\n for problem_sys_id in self.problem_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"sys_id={problem_sys_id}\"},\n )\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem_sys_id,\n )\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n super().teardown()\n\n\nclass WorkloadBalancingSmallTask(WorkloadBalancingTask, HumanEvalTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=2,\n max_users=4,\n max_problem_range=[4, 6],\n mid_problem_range=[3, 4],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingMediumTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing.WorkloadBalancingSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.workload_balancing.WorkloadBalancingSmallTask#L346-L357","kind":"class","name":"WorkloadBalancingSmallTask","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":346,"end_line":357,"context_start_line":326,"context_end_line":377,"code":" record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"sys_id={problem_sys_id}\"},\n )\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem_sys_id,\n )\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n super().teardown()\n\n\nclass WorkloadBalancingSmallTask(WorkloadBalancingTask, HumanEvalTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=2,\n max_users=4,\n max_problem_range=[4, 6],\n mid_problem_range=[3, 4],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingMediumTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=5,\n max_users=7,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingLargeTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing.WorkloadBalancingMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.workload_balancing.WorkloadBalancingMediumTask#L360-L371","kind":"class","name":"WorkloadBalancingMediumTask","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":360,"end_line":371,"context_start_line":340,"context_end_line":391,"code":" table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n super().teardown()\n\n\nclass WorkloadBalancingSmallTask(WorkloadBalancingTask, HumanEvalTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=2,\n max_users=4,\n max_problem_range=[4, 6],\n mid_problem_range=[3, 4],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingMediumTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=5,\n max_users=7,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingLargeTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=8,\n max_users=10,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing.WorkloadBalancingLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.workload_balancing.WorkloadBalancingLargeTask#L374-L385","kind":"class","name":"WorkloadBalancingLargeTask","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":374,"end_line":385,"context_start_line":354,"context_end_line":396,"code":" max_problem_range=[4, 6],\n mid_problem_range=[3, 4],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingMediumTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=5,\n max_users=7,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingLargeTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=8,\n max_users=10,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, WorkloadBalancingTask)\n and var is not WorkloadBalancingTask\n]","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.workload_balancing.__init__#L375-L385","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":375,"end_line":385,"context_start_line":355,"context_end_line":396,"code":" mid_problem_range=[3, 4],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingMediumTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=5,\n max_users=7,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingLargeTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=8,\n max_users=10,\n max_problem_range=[5, 6],\n mid_problem_range=[3, 5],\n min_problem_range=[1, 3],\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, WorkloadBalancingTask)\n and var is not WorkloadBalancingTask\n]","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.workload_balancing.setup_goal#L128-L206","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":128,"end_line":206,"context_start_line":108,"context_end_line":226,"code":" self.lowest_priority = 0 # The lowest priority of the problems; a high number indicates a low priority. Set in the setup_goal method\n\n self.category_name = (\n fake.word() + \"-\" + fake.word()\n ) # The category of the problems to re-distribute\n self.category_sys_id = (\n None # The sys_id of the category created for the task; create in the setup_goal method\n )\n self.user_sys_ids = [] # The sys_ids of the users created for the task\n self.problem_sys_ids = [] # The sys_ids of the problems created for the task\n self.report_sys_id = None # The sys_id of the report created for the task\n self.user_with_most_problems = None # The name of the user that has the most problems assigned; defined in the setup_goal method\n self.user_with_least_problems = None # The name of the user that has the least problems assigned; defined in the setup_goal method\n self.problem_to_edit_sys_id = (\n None # The sys_id of the problem to re-assign; defined in the setup_goal method\n )\n self.problem_to_edit_number = (\n None # The number of the problem to re-assign; defined in the setup_goal method\n )\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n num_users = self.random.randint(self.min_users, self.max_users)\n max_problems = self.random.randint(*self.max_problem_range)\n min_problems = self.random.randint(*self.min_problem_range)\n\n # Create users, create problems and assign problems to users\n for i in range(num_users):\n if i == 0:\n num_problems = max_problems\n elif i == num_users - 1:\n num_problems = min_problems\n else:\n num_problems = self.random.randint(*self.mid_problem_range)\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n user_full_name = first_name + \" \" + last_name\n _, _, user_sys_id = create_user(\n instance=self.instance,\n first_name=first_name,\n last_name=last_name,\n user_roles=[\n \"admin\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ],\n random=self.random,\n )\n self.user_sys_ids.append(user_sys_id)\n\n if i == 0:\n self.user_with_most_problems = user_full_name\n elif i == num_users - 1:\n self.user_with_least_problems = user_full_name\n\n # Create problems assigned to current user\n for j in range(num_problems):\n # Assign a priority to the problem; 1 being highest priority and 5 being lowest\n # the use of j % 5 is to ensure that the priority is between 1 and 5 and that there is\n # only one problem with the lowest priority\n priority = (j % 5) + 1\n self.lowest_priority = max(self.lowest_priority, priority)\n problem_sys_id, problem_number = create_problem(\n instance=self.instance,\n user_sys_id=user_sys_id,\n priority=priority,\n problem_hashtag=self.problem_hashtag,\n return_number=True,\n )\n # The last problem created is the one to re-assign as it will be the one with the lowest priority (highest priority value)\n # and the first user will be the one with the most problems assigned\n if i == 0 and j == num_problems - 1:\n self.problem_to_edit_sys_id = problem_sys_id\n self.problem_to_edit_number = problem_number\n self.problem_sys_ids.append(problem_sys_id)\n\n # Create a report for problems of the current category\n self.report_sys_id, plot_title = create_report(\n instance=self.instance,\n table=\"problem\",\n filter_hashtag=self.problem_hashtag,\n field=\"assigned_to\",\n plot_title=f\"Problems for with hashtag {self.problem_hashtag}\",\n random=self.random,\n )\n self.plot_title = plot_title\n\n # Sample a configuration\n config = self._get_config()\n # Get the task description\n self.short_description = (\n f\"Balance the workload for problems with hashtag {self.problem_hashtag}\"\n )\n self.task_description = f\"Referring to company protocol '{self.protocol_name}' (located in the \\\"Company Protocols\\\" knowledge base) re-distribute the problems with hashtag={self.problem_hashtag}.\"\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\" \"\"\"\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.workload_balancing._get_config#L208-L308","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":208,"end_line":308,"context_start_line":188,"context_end_line":328,"code":" table=\"problem\",\n filter_hashtag=self.problem_hashtag,\n field=\"assigned_to\",\n plot_title=f\"Problems for with hashtag {self.problem_hashtag}\",\n random=self.random,\n )\n self.plot_title = plot_title\n\n # Sample a configuration\n config = self._get_config()\n # Get the task description\n self.short_description = (\n f\"Balance the workload for problems with hashtag {self.problem_hashtag}\"\n )\n self.task_description = f\"Referring to company protocol '{self.protocol_name}' (located in the \\\"Company Protocols\\\" knowledge base) re-distribute the problems with hashtag={self.problem_hashtag}.\"\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\" \"\"\"\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n find_most_and_least_busy_users_subtask = [\n # Navigate to the reports list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Reports\",\n \"module\": \"Administration > All\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_report_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n WorkLoadBalancingMinMaxRetrievalTask(\n instance=self.instance,\n fixed_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.plot_title,\n \"chart_series\": \"\",\n \"question\": \"min\",\n },\n is_validated=False,\n used_in_level_2=True,\n problem_hashtag=self.problem_hashtag,\n ),\n ]\n\n reassign_problem_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the problems by assignee, and priority = lowest priority\n # The existence of a lower priority problem is guaranteed\n FilterProblemListForWorkLoadBalancingTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\", \"priority\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [\n f\"{self.user_with_most_problems}\",\n f\"{self.lowest_priority}\",\n ],\n },\n is_validated=False,\n used_in_level_2=True,\n goal=f'Create a filter to find problems where \\n - \"Assigned to\" is the user with the most problems assigned and \\n - \"Priority\" is \"{self.lowest_priority}\".',\n ),\n # Assign a problem to the user with the least problems assigned to them\n EditProblemTask(\n instance=self.instance,\n new_values={\"assigned_to\": f\"{self.user_with_least_problems}\"},\n record_sys_id=self.problem_to_edit_sys_id,\n record_number=self.problem_to_edit_number,\n is_validated=True,\n used_in_level_2=True,\n level=self.level,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + find_most_and_least_busy_users_subtask\n + reassign_problem_subtask\n )\n\n return config\n\n def teardown(self) -> None:\n # Delete the users\n for user_sys_id in self.user_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={user_sys_id}\"},\n )\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=user_sys_id,\n )\n # Delete the problems\n for problem_sys_id in self.problem_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.workload_balancing.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.workload_balancing.teardown#L310-L343","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":310,"end_line":343,"context_start_line":290,"context_end_line":363,"code":" # Assign a problem to the user with the least problems assigned to them\n EditProblemTask(\n instance=self.instance,\n new_values={\"assigned_to\": f\"{self.user_with_least_problems}\"},\n record_sys_id=self.problem_to_edit_sys_id,\n record_number=self.problem_to_edit_number,\n is_validated=True,\n used_in_level_2=True,\n level=self.level,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + find_most_and_least_busy_users_subtask\n + reassign_problem_subtask\n )\n\n return config\n\n def teardown(self) -> None:\n # Delete the users\n for user_sys_id in self.user_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={user_sys_id}\"},\n )\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=user_sys_id,\n )\n # Delete the problems\n for problem_sys_id in self.problem_sys_ids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\"sysparm_query\": f\"sys_id={problem_sys_id}\"},\n )\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem_sys_id,\n )\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n super().teardown()\n\n\nclass WorkloadBalancingSmallTask(WorkloadBalancingTask, HumanEvalTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n level=level,\n min_users=2,\n max_users=4,\n max_problem_range=[4, 6],\n mid_problem_range=[3, 4],\n min_problem_range=[1, 3],\n )\n\n\nclass WorkloadBalancingMediumTask(WorkloadBalancingTask):\n def __init__(self, seed: int = None, instance: SNowInstance = None, level: int = 2) -> None:\n super().__init__(\n seed=seed,","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.onboard_user","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.onboard_user#L1-L226","kind":"module","name":"src.browsergym.workarena.tasks.compositional.onboard_user","path":"src/browsergym/workarena/tasks/compositional/onboard_user.py","language":"python","start_line":1,"end_line":226,"context_start_line":1,"context_end_line":226,"code":"import json\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..form import CreateUserTask, CreateHardwareAssetTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..navigation import AllMenuTask\nfrom ..service_catalog import OrderAppleMacBookPro15Task\n\nfrom ...instance import SNowInstance\nfrom ...config import CREATE_USER_CONFIG_PATH, CREATE_HARDWARE_CONFIG_PATH\n\n\nclass OnBoardUserTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Onboarding a new user', onboard user with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Onboard user John Doe\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Onboarding a new user\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n\n self.all_user_configs = CreateUserTask.all_configs()\n self.all_hardware_asset_configs = CreateHardwareAssetTask.all_configs()\n self.task_description = None\n self.short_description = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n user_name = (\n config[3].fixed_config[\"template_record\"][\"first_name\"]\n + \" \"\n + config[3].fixed_config[\"template_record\"][\"last_name\"]\n )\n # Get the task description\n self.short_description = f\"Onboard user {user_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) onboard user with the following information: \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n # Sample base configurations; the hardware config will be modified to include the assigned_to field\n user_config = self.random.choice(self.all_user_configs)\n hardware_config = self.random.choice(self.all_hardware_asset_configs)\n\n # Get the common fields between the user and hardware configurations to adjust the hardware config\n common_fields = [\n field for field in hardware_config[\"fields\"].keys() if field in user_config[\"fields\"]\n ]\n common_task_fields = [\n field for field in hardware_config[\"task_fields\"] if field in user_config[\"task_fields\"]\n ]\n common_template_record_fields = [\n field\n for field in hardware_config[\"template_record\"].keys()\n if field in user_config[\"template_record\"] and \"sys\" not in field\n ]\n\n # Drop the common fields as they create synchronization issues\n for field in common_fields + common_task_fields + common_template_record_fields:\n if field in user_config[\"fields\"]:\n user_config[\"fields\"].pop(field)\n if field in hardware_config[\"fields\"]:\n hardware_config[\"fields\"].pop(field)\n\n if field in user_config[\"task_fields\"]:\n user_config[\"task_fields\"].remove(field)\n if field in hardware_config[\"task_fields\"]:\n hardware_config[\"task_fields\"].remove(field)\n\n if field in user_config[\"template_record\"]:\n user_config[\"template_record\"].pop(field)\n if field in hardware_config[\"template_record\"]:\n hardware_config[\"template_record\"].pop(field)\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n create_user_subtask = [\n # Navigate to the user list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"System Security\",\n \"module\": \"Users and Groups > Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new user\n CreateUserTask(\n instance=self.instance,\n fixed_config=user_config,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n order_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n \"url\": \"/now/nav/ui/classic/params/target/catalog_home.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Order a MacBook Pro 15\n OrderAppleMacBookPro15Task(\n instance=self.instance,\n fixed_config={\n \"configuration\": {},\n \"description\": \"Apple MacBook Pro\",\n \"item\": \"Apple MacBook Pro 15\",\n \"quantity\": 1,\n },\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n # The unique name for the user is created once the task is instantiated\n user_full_name = (\n create_user_subtask[1].template_record[\"first_name\"]\n + \" \"\n + create_user_subtask[1].template_record[\"last_name\"]\n )\n # Set the assigned_to field in the hardware asset configuration to the user's email\n hardware_config[\"template_record\"][\"assigned_to\"] = user_full_name\n if \"assigned_to\" not in hardware_config[\"task_fields\"]:\n hardware_config[\"task_fields\"].append(\"assigned_to\")\n\n create_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new hardware asset\n CreateHardwareAssetTask(\n instance=self.instance,\n fixed_config=hardware_config,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + create_user_subtask\n + order_hardware_subtask\n + create_hardware_subtask\n )\n\n return config\n\n\n__TASKS__ = [OnBoardUserTask]","source_hash":"67668f5a73e3374ba315c822de2358f0f61bfd1615ec95d477b91428360cd4f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.onboard_user.OnBoardUserTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.onboard_user.OnBoardUserTask#L17-L223","kind":"class","name":"OnBoardUserTask","path":"src/browsergym/workarena/tasks/compositional/onboard_user.py","language":"python","start_line":17,"end_line":223,"context_start_line":1,"context_end_line":226,"code":"import json\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..form import CreateUserTask, CreateHardwareAssetTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..navigation import AllMenuTask\nfrom ..service_catalog import OrderAppleMacBookPro15Task\n\nfrom ...instance import SNowInstance\nfrom ...config import CREATE_USER_CONFIG_PATH, CREATE_HARDWARE_CONFIG_PATH\n\n\nclass OnBoardUserTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Onboarding a new user', onboard user with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Onboard user John Doe\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Onboarding a new user\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n\n self.all_user_configs = CreateUserTask.all_configs()\n self.all_hardware_asset_configs = CreateHardwareAssetTask.all_configs()\n self.task_description = None\n self.short_description = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n user_name = (\n config[3].fixed_config[\"template_record\"][\"first_name\"]\n + \" \"\n + config[3].fixed_config[\"template_record\"][\"last_name\"]\n )\n # Get the task description\n self.short_description = f\"Onboard user {user_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) onboard user with the following information: \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n # Sample base configurations; the hardware config will be modified to include the assigned_to field\n user_config = self.random.choice(self.all_user_configs)\n hardware_config = self.random.choice(self.all_hardware_asset_configs)\n\n # Get the common fields between the user and hardware configurations to adjust the hardware config\n common_fields = [\n field for field in hardware_config[\"fields\"].keys() if field in user_config[\"fields\"]\n ]\n common_task_fields = [\n field for field in hardware_config[\"task_fields\"] if field in user_config[\"task_fields\"]\n ]\n common_template_record_fields = [\n field\n for field in hardware_config[\"template_record\"].keys()\n if field in user_config[\"template_record\"] and \"sys\" not in field\n ]\n\n # Drop the common fields as they create synchronization issues\n for field in common_fields + common_task_fields + common_template_record_fields:\n if field in user_config[\"fields\"]:\n user_config[\"fields\"].pop(field)\n if field in hardware_config[\"fields\"]:\n hardware_config[\"fields\"].pop(field)\n\n if field in user_config[\"task_fields\"]:\n user_config[\"task_fields\"].remove(field)\n if field in hardware_config[\"task_fields\"]:\n hardware_config[\"task_fields\"].remove(field)\n\n if field in user_config[\"template_record\"]:\n user_config[\"template_record\"].pop(field)\n if field in hardware_config[\"template_record\"]:\n hardware_config[\"template_record\"].pop(field)\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n create_user_subtask = [\n # Navigate to the user list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"System Security\",\n \"module\": \"Users and Groups > Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new user\n CreateUserTask(\n instance=self.instance,\n fixed_config=user_config,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n order_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n \"url\": \"/now/nav/ui/classic/params/target/catalog_home.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Order a MacBook Pro 15\n OrderAppleMacBookPro15Task(\n instance=self.instance,\n fixed_config={\n \"configuration\": {},\n \"description\": \"Apple MacBook Pro\",\n \"item\": \"Apple MacBook Pro 15\",\n \"quantity\": 1,\n },\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n # The unique name for the user is created once the task is instantiated\n user_full_name = (\n create_user_subtask[1].template_record[\"first_name\"]\n + \" \"\n + create_user_subtask[1].template_record[\"last_name\"]\n )\n # Set the assigned_to field in the hardware asset configuration to the user's email\n hardware_config[\"template_record\"][\"assigned_to\"] = user_full_name\n if \"assigned_to\" not in hardware_config[\"task_fields\"]:\n hardware_config[\"task_fields\"].append(\"assigned_to\")\n\n create_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new hardware asset\n CreateHardwareAssetTask(\n instance=self.instance,\n fixed_config=hardware_config,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + create_user_subtask\n + order_hardware_subtask\n + create_hardware_subtask\n )\n\n return config\n\n\n__TASKS__ = [OnBoardUserTask]","source_hash":"67668f5a73e3374ba315c822de2358f0f61bfd1615ec95d477b91428360cd4f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.onboard_user.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.onboard_user.__init__#L18-L59","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/onboard_user.py","language":"python","start_line":18,"end_line":59,"context_start_line":1,"context_end_line":79,"code":"import json\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..form import CreateUserTask, CreateHardwareAssetTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..navigation import AllMenuTask\nfrom ..service_catalog import OrderAppleMacBookPro15Task\n\nfrom ...instance import SNowInstance\nfrom ...config import CREATE_USER_CONFIG_PATH, CREATE_HARDWARE_CONFIG_PATH\n\n\nclass OnBoardUserTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Onboarding a new user', onboard user with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Onboard user John Doe\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Onboarding a new user\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n\n self.all_user_configs = CreateUserTask.all_configs()\n self.all_hardware_asset_configs = CreateHardwareAssetTask.all_configs()\n self.task_description = None\n self.short_description = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n user_name = (\n config[3].fixed_config[\"template_record\"][\"first_name\"]\n + \" \"\n + config[3].fixed_config[\"template_record\"][\"last_name\"]\n )\n # Get the task description\n self.short_description = f\"Onboard user {user_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) onboard user with the following information: \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n # Sample base configurations; the hardware config will be modified to include the assigned_to field\n user_config = self.random.choice(self.all_user_configs)","source_hash":"67668f5a73e3374ba315c822de2358f0f61bfd1615ec95d477b91428360cd4f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.onboard_user.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.onboard_user.setup_goal#L61-L75","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/onboard_user.py","language":"python","start_line":61,"end_line":75,"context_start_line":41,"context_end_line":95,"code":" The start of the task description to be completed. e.g. \"Referring to company protocol 'Onboarding a new user', onboard user with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Onboard user John Doe\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Onboarding a new user\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n\n self.all_user_configs = CreateUserTask.all_configs()\n self.all_hardware_asset_configs = CreateHardwareAssetTask.all_configs()\n self.task_description = None\n self.short_description = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n user_name = (\n config[3].fixed_config[\"template_record\"][\"first_name\"]\n + \" \"\n + config[3].fixed_config[\"template_record\"][\"last_name\"]\n )\n # Get the task description\n self.short_description = f\"Onboard user {user_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) onboard user with the following information: \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n # Sample base configurations; the hardware config will be modified to include the assigned_to field\n user_config = self.random.choice(self.all_user_configs)\n hardware_config = self.random.choice(self.all_hardware_asset_configs)\n\n # Get the common fields between the user and hardware configurations to adjust the hardware config\n common_fields = [\n field for field in hardware_config[\"fields\"].keys() if field in user_config[\"fields\"]\n ]\n common_task_fields = [\n field for field in hardware_config[\"task_fields\"] if field in user_config[\"task_fields\"]\n ]\n common_template_record_fields = [\n field\n for field in hardware_config[\"template_record\"].keys()\n if field in user_config[\"template_record\"] and \"sys\" not in field\n ]\n\n # Drop the common fields as they create synchronization issues","source_hash":"67668f5a73e3374ba315c822de2358f0f61bfd1615ec95d477b91428360cd4f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.onboard_user._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.onboard_user._get_config#L77-L223","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/onboard_user.py","language":"python","start_line":77,"end_line":223,"context_start_line":57,"context_end_line":226,"code":" self.all_hardware_asset_configs = CreateHardwareAssetTask.all_configs()\n self.task_description = None\n self.short_description = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n user_name = (\n config[3].fixed_config[\"template_record\"][\"first_name\"]\n + \" \"\n + config[3].fixed_config[\"template_record\"][\"last_name\"]\n )\n # Get the task description\n self.short_description = f\"Onboard user {user_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) onboard user with the following information: \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n # Sample base configurations; the hardware config will be modified to include the assigned_to field\n user_config = self.random.choice(self.all_user_configs)\n hardware_config = self.random.choice(self.all_hardware_asset_configs)\n\n # Get the common fields between the user and hardware configurations to adjust the hardware config\n common_fields = [\n field for field in hardware_config[\"fields\"].keys() if field in user_config[\"fields\"]\n ]\n common_task_fields = [\n field for field in hardware_config[\"task_fields\"] if field in user_config[\"task_fields\"]\n ]\n common_template_record_fields = [\n field\n for field in hardware_config[\"template_record\"].keys()\n if field in user_config[\"template_record\"] and \"sys\" not in field\n ]\n\n # Drop the common fields as they create synchronization issues\n for field in common_fields + common_task_fields + common_template_record_fields:\n if field in user_config[\"fields\"]:\n user_config[\"fields\"].pop(field)\n if field in hardware_config[\"fields\"]:\n hardware_config[\"fields\"].pop(field)\n\n if field in user_config[\"task_fields\"]:\n user_config[\"task_fields\"].remove(field)\n if field in hardware_config[\"task_fields\"]:\n hardware_config[\"task_fields\"].remove(field)\n\n if field in user_config[\"template_record\"]:\n user_config[\"template_record\"].pop(field)\n if field in hardware_config[\"template_record\"]:\n hardware_config[\"template_record\"].pop(field)\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n create_user_subtask = [\n # Navigate to the user list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"System Security\",\n \"module\": \"Users and Groups > Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new user\n CreateUserTask(\n instance=self.instance,\n fixed_config=user_config,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n order_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n \"url\": \"/now/nav/ui/classic/params/target/catalog_home.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Order a MacBook Pro 15\n OrderAppleMacBookPro15Task(\n instance=self.instance,\n fixed_config={\n \"configuration\": {},\n \"description\": \"Apple MacBook Pro\",\n \"item\": \"Apple MacBook Pro 15\",\n \"quantity\": 1,\n },\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n # The unique name for the user is created once the task is instantiated\n user_full_name = (\n create_user_subtask[1].template_record[\"first_name\"]\n + \" \"\n + create_user_subtask[1].template_record[\"last_name\"]\n )\n # Set the assigned_to field in the hardware asset configuration to the user's email\n hardware_config[\"template_record\"][\"assigned_to\"] = user_full_name\n if \"assigned_to\" not in hardware_config[\"task_fields\"]:\n hardware_config[\"task_fields\"].append(\"assigned_to\")\n\n create_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new hardware asset\n CreateHardwareAssetTask(\n instance=self.instance,\n fixed_config=hardware_config,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + create_user_subtask\n + order_hardware_subtask\n + create_hardware_subtask\n )\n\n return config\n\n\n__TASKS__ = [OnBoardUserTask]","source_hash":"67668f5a73e3374ba315c822de2358f0f61bfd1615ec95d477b91428360cd4f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_base#L1-L1366","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_base","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1,"end_line":1366,"context_start_line":1,"context_end_line":1366,"code":"\"\"\"\nDashboard retrieval and do action comp tasks\n\"\"\"\n\nimport json\nfrom functools import partial\nimport random\nimport numpy as np\nfrom typing import List\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, InfeasibleCompositionalTask, HumanEvalTask\nfrom .utils.infeasible_configs import get_infeasible_service_catalog_config\nfrom ..base import AbstractServiceNowTask\nfrom ..knowledge import KnowledgeBaseSearchTask\n\nfrom ...api.incident import create_incident\nfrom ...api.report import create_report\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import META_CONFIGS\n\n\nclass DashboardRetrieveAndDoTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n dashboard_class: AbstractServiceNowTask = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n dashboard_config: dict = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Generic task to perform a dashboard retrieval and perform a task.\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n dashboard_config: dict\n Configuration to use for the dashboard task.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.dashboard_config = dashboard_config\n self.task_description = None\n self.short_description = None\n self.dashboard_class = dashboard_class\n self.protocol_name = \"Dashboard Retrieve Information and Perform Task\"\n self.description_mapping = {\n \"max\": self.random.choice([\"maximum\", \"highest\", \"greatest\"]),\n \"min\": self.random.choice([\"minimum\", \"lowest\", \"least\"]),\n \"mean\": self.random.choice([\"mean\", \"average\"]),\n \"median\": \"median\",\n \"mode\": \"mode (most frequent)\",\n }\n\n def create_report(self) -> None:\n \"\"\"\n Create task relevant dashboard report\n \"\"\"\n raise NotImplementedError\n\n def set_compositional_task(self) -> None:\n \"\"\"\n Create and return the compositional task\n \"\"\"\n raise NotImplementedError\n\n def get_compositional_task(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Return the compositional task\n \"\"\"\n return self.compositional_task\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n dashboard_retrieval_subtask = [\n # Navigate to the reports list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Reports\",\n \"module\": \"Administration > All\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_report_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Find the user with the desired config\n self.dashboard_class(\n instance=self.instance,\n seed=None,\n fixed_config=self.dashboard_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + dashboard_retrieval_subtask\n + self.get_compositional_task()\n )\n return config\n\n def teardown(self) -> None:\n return super().teardown()\n\n\nclass DashboardRetrieveAndDoInfeasibleTask(InfeasibleCompositionalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n dashboard_class: AbstractServiceNowTask = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n dashboard_config: dict = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Generic task to perform a dashboard retrieval and perform a task.\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n dashboard_config: dict\n Configuration to use for the dashboard task.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.dashboard_config = dashboard_config\n self.task_description = None\n self.short_description = None\n self.dashboard_class = dashboard_class\n self.protocol_name = \"Dashboard Retrieve Information and Perform Task\"\n self.description_mapping = {\n \"max\": self.random.choice([\"maximum\", \"highest\", \"most\"]),\n \"min\": self.random.choice([\"minimum\", \"lowest\", \"least\"]),\n \"mean\": self.random.choice([\"mean\", \"average\"]),\n \"median\": \"median\",\n \"mode\": \"mode (most frequent)\",\n }\n\n def create_report(self) -> None:\n \"\"\"\n Create task relevant dashboard report\n \"\"\"\n raise NotImplementedError\n\n def set_compositional_task(self) -> None:\n \"\"\"\n Create and return the compositional task\n \"\"\"\n raise NotImplementedError\n\n def get_compositional_task(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Return the compositional task\n \"\"\"\n return self.compositional_task\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n has_description=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n has_description=False,\n ),\n ]\n\n dashboard_retrieval_subtask = [\n # Navigate to the reports list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Reports\",\n \"module\": \"Administration > All\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_report_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n # Find the user with the desired config\n self.dashboard_class(\n instance=self.instance,\n seed=None,\n fixed_config=self.dashboard_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + dashboard_retrieval_subtask\n + self.get_compositional_task()\n )\n return config\n\n def teardown(self) -> None:\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndDoTask(DashboardRetrieveAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_incidents_per_agent: int = 4,\n min_incidents_per_agent: int = 1,\n num_agents: int = 4,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.incident_hashtag = (\n f\"#INC{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems\n )\n self.chart_title = f\"Incidents with hashtag {self.incident_hashtag}\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n dashboard_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.chart_title,\n \"question\": question,\n \"chart_series\": \"\",\n },\n level=level,\n dashboard_class=dashboard_class,\n )\n self.question = question\n self.max_incidents_per_agent = max_incidents_per_agent\n self.min_incidents_per_agent = min_incidents_per_agent\n self.num_agents = num_agents\n if (self.max_incidents_per_agent - self.min_incidents_per_agent) < 2 or self.num_agents < 2:\n raise Exception(\n \"The difference between maximum incidents and minimum incidents should be at least two. The number of agents should also be at least 2.\"\n )\n self.task_description = f\"You have to retrieve some information from a dashboard chart based on the description below. The chart presents the number of 'incidents' assigned to different agents. After retrieving the information, you will be asked to use it to complete a task.\\n \\n\"\n self.task_description += f\"Title of the report: {self.incident_hashtag}\\n\\n\"\n if self.level == 3:\n self.task_description += f\"Referring to the company protocol '{self.protocol_name}' (located in the 'Company Protocols' knowledge base), complete the dashboard retrieval task.\\n\\n\"\n self.short_description = (\n f\"Retrieve information from the chart with title {self.incident_hashtag} and perform the mentioned task.\"\n + \"\\n For calculations, please round off to the next highest integer if required. If the required calculation has multiple possible answers (for example, 'mode' or 'most frequently' occuring value), please consider the highest value.\\n\\n\"\n )\n\n def create_report(\n self,\n user_roles=[\"itil\"],\n ) -> None:\n self.agents = {}\n self.agent_sysids = []\n for _ in range(self.num_agents):\n agent_response = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=user_roles,\n )\n self.agents[agent_response[\"sys_id\"]] = agent_response\n self.agent_sysids.append(agent_response[\"sys_id\"])\n\n highest_agent = self.agent_sysids[\n -1\n ] # Choose last agent as the agent with maximum incidents\n self.agents[highest_agent][\"num_incidents\"] = self.max_incidents_per_agent\n self.agents[highest_agent][\"incident_configs\"] = []\n\n lowest_agent = self.agent_sysids[\n 0\n ] # Choose first agent as the agent with minimum incidents\n self.agents[lowest_agent][\"num_incidents\"] = self.min_incidents_per_agent\n self.agents[lowest_agent][\"incident_configs\"] = []\n\n for agent_sysid in self.agent_sysids[1:-1]:\n self.agents[agent_sysid][\"num_incidents\"] = self.random.randint(\n self.min_incidents_per_agent + 1, self.max_incidents_per_agent - 1\n )\n self.agents[agent_sysid][\"incident_configs\"] = []\n\n number_assignments = sum([agent[\"num_incidents\"] for agent in self.agents.values()])\n\n all_existing_incidents = table_api_call(\n instance=self.instance, table=\"incident\", method=\"GET\"\n )[\"result\"]\n self.all_incident_numbers = [incident[\"number\"] for incident in all_existing_incidents]\n\n self.new_incident_numbers = []\n for _ in range(number_assignments):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(self.random.randint(1000, 9999))\n )\n while (\n incident_number in self.all_incident_numbers\n or incident_number in self.new_incident_numbers\n ):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(random.randint(1000, 9999))\n )\n self.new_incident_numbers.append(incident_number)\n\n incident_number_idx = 0\n for agent, agent_attributes in self.agents.items():\n for _ in range(agent_attributes[\"num_incidents\"]):\n incident_response = create_incident(\n instance=self.instance,\n incident_number=self.new_incident_numbers[incident_number_idx],\n caller_sys_id=self._base_user_sysid,\n category=\"software\",\n priority=4,\n impact=2, # priority is calculated as some combination of impact and urgency\n urgency=3,\n incident_hastag=self.incident_hashtag,\n assigned_to=agent,\n )\n self.agents[agent][\"incident_configs\"].append(incident_response)\n incident_number_idx += 1\n\n self.report_sys_id, _ = create_report(\n instance=self.instance,\n table=\"incident\",\n filter_hashtag=self.incident_hashtag,\n field=\"assigned_to\",\n plot_title=self.chart_title,\n random=self.random,\n )\n\n def get_agent_values(self, attribute_name, filter_than) -> list[str]:\n agent_values = []\n agent_value_sysids = []\n agent_incidents = [\n agent_attributes[\"num_incidents\"] for agent_attributes in self.agents.values()\n ]\n\n if self.question == \"max\":\n agent_value_sysids.append(self.agents[self.agent_sysids[-1]][\"sys_id\"])\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n self.agents[self.agent_sysids[-1]][\"first_name\"]\n + \" \"\n + self.agents[self.agent_sysids[-1]][\"last_name\"]\n )\n agent_values.append(agent_full_name)\n elif attribute_name == \"first_name\":\n agent_first_name = self.agents[self.agent_sysids[-1]][\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n elif self.question == \"min\":\n agent_value_sysids.append(self.agents[self.agent_sysids[0]][\"sys_id\"])\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n self.agents[self.agent_sysids[0]][\"first_name\"]\n + \" \"\n + self.agents[self.agent_sysids[0]][\"last_name\"]\n )\n agent_values.append(agent_full_name)\n elif attribute_name == \"first_name\":\n agent_first_name = self.agents[self.agent_sysids[0]][\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n elif self.question == \"mean\" or self.question == \"median\" or self.question == \"mode\":\n if self.question == \"mean\":\n mean_incidents = np.mean(agent_incidents)\n incidents_count = int(np.ceil(mean_incidents))\n elif self.question == \"median\":\n incidents_count = int(np.ceil(np.median(agent_incidents)))\n elif self.question == \"mode\":\n # We select the maximum value if there are two or more modes\n frequencies = {}\n for count in agent_incidents:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n incidents_count = int(max(max_frequencies))\n\n for agent_sysid, agent_attributes in self.agents.items():\n if (\n filter_than == \"greater\"\n and agent_attribute\n# ... truncated ...","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveAndDoTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveAndDoTask#L32-L161","kind":"class","name":"DashboardRetrieveAndDoTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":32,"end_line":161,"context_start_line":12,"context_end_line":181,"code":"\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, InfeasibleCompositionalTask, HumanEvalTask\nfrom .utils.infeasible_configs import get_infeasible_service_catalog_config\nfrom ..base import AbstractServiceNowTask\nfrom ..knowledge import KnowledgeBaseSearchTask\n\nfrom ...api.incident import create_incident\nfrom ...api.report import create_report\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import META_CONFIGS\n\n\nclass DashboardRetrieveAndDoTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n dashboard_class: AbstractServiceNowTask = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n dashboard_config: dict = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Generic task to perform a dashboard retrieval and perform a task.\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n dashboard_config: dict\n Configuration to use for the dashboard task.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.dashboard_config = dashboard_config\n self.task_description = None\n self.short_description = None\n self.dashboard_class = dashboard_class\n self.protocol_name = \"Dashboard Retrieve Information and Perform Task\"\n self.description_mapping = {\n \"max\": self.random.choice([\"maximum\", \"highest\", \"greatest\"]),\n \"min\": self.random.choice([\"minimum\", \"lowest\", \"least\"]),\n \"mean\": self.random.choice([\"mean\", \"average\"]),\n \"median\": \"median\",\n \"mode\": \"mode (most frequent)\",\n }\n\n def create_report(self) -> None:\n \"\"\"\n Create task relevant dashboard report\n \"\"\"\n raise NotImplementedError\n\n def set_compositional_task(self) -> None:\n \"\"\"\n Create and return the compositional task\n \"\"\"\n raise NotImplementedError\n\n def get_compositional_task(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Return the compositional task\n \"\"\"\n return self.compositional_task\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n dashboard_retrieval_subtask = [\n # Navigate to the reports list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Reports\",\n \"module\": \"Administration > All\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_report_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Find the user with the desired config\n self.dashboard_class(\n instance=self.instance,\n seed=None,\n fixed_config=self.dashboard_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + dashboard_retrieval_subtask\n + self.get_compositional_task()\n )\n return config\n\n def teardown(self) -> None:\n return super().teardown()\n\n\nclass DashboardRetrieveAndDoInfeasibleTask(InfeasibleCompositionalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n dashboard_class: AbstractServiceNowTask = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n dashboard_config: dict = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Generic task to perform a dashboard retrieval and perform a task.\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveAndDoInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveAndDoInfeasibleTask#L164-L296","kind":"class","name":"DashboardRetrieveAndDoInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":164,"end_line":296,"context_start_line":144,"context_end_line":316,"code":" self.dashboard_class(\n instance=self.instance,\n seed=None,\n fixed_config=self.dashboard_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + dashboard_retrieval_subtask\n + self.get_compositional_task()\n )\n return config\n\n def teardown(self) -> None:\n return super().teardown()\n\n\nclass DashboardRetrieveAndDoInfeasibleTask(InfeasibleCompositionalTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n dashboard_class: AbstractServiceNowTask = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n dashboard_config: dict = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Generic task to perform a dashboard retrieval and perform a task.\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n dashboard_config: dict\n Configuration to use for the dashboard task.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.dashboard_config = dashboard_config\n self.task_description = None\n self.short_description = None\n self.dashboard_class = dashboard_class\n self.protocol_name = \"Dashboard Retrieve Information and Perform Task\"\n self.description_mapping = {\n \"max\": self.random.choice([\"maximum\", \"highest\", \"most\"]),\n \"min\": self.random.choice([\"minimum\", \"lowest\", \"least\"]),\n \"mean\": self.random.choice([\"mean\", \"average\"]),\n \"median\": \"median\",\n \"mode\": \"mode (most frequent)\",\n }\n\n def create_report(self) -> None:\n \"\"\"\n Create task relevant dashboard report\n \"\"\"\n raise NotImplementedError\n\n def set_compositional_task(self) -> None:\n \"\"\"\n Create and return the compositional task\n \"\"\"\n raise NotImplementedError\n\n def get_compositional_task(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Return the compositional task\n \"\"\"\n return self.compositional_task\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n has_description=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n has_description=False,\n ),\n ]\n\n dashboard_retrieval_subtask = [\n # Navigate to the reports list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Reports\",\n \"module\": \"Administration > All\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_report_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n # Find the user with the desired config\n self.dashboard_class(\n instance=self.instance,\n seed=None,\n fixed_config=self.dashboard_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + dashboard_retrieval_subtask\n + self.get_compositional_task()\n )\n return config\n\n def teardown(self) -> None:\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndDoTask(DashboardRetrieveAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_incidents_per_agent: int = 4,\n min_incidents_per_agent: int = 1,\n num_agents: int = 4,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.incident_hashtag = (\n f\"#INC{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveIncidentAndDoTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveIncidentAndDoTask#L299-L545","kind":"class","name":"DashboardRetrieveIncidentAndDoTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":299,"end_line":545,"context_start_line":279,"context_end_line":565,"code":" self.dashboard_class(\n instance=self.instance,\n seed=None,\n fixed_config=self.dashboard_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + dashboard_retrieval_subtask\n + self.get_compositional_task()\n )\n return config\n\n def teardown(self) -> None:\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndDoTask(DashboardRetrieveAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_incidents_per_agent: int = 4,\n min_incidents_per_agent: int = 1,\n num_agents: int = 4,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.incident_hashtag = (\n f\"#INC{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems\n )\n self.chart_title = f\"Incidents with hashtag {self.incident_hashtag}\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n dashboard_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.chart_title,\n \"question\": question,\n \"chart_series\": \"\",\n },\n level=level,\n dashboard_class=dashboard_class,\n )\n self.question = question\n self.max_incidents_per_agent = max_incidents_per_agent\n self.min_incidents_per_agent = min_incidents_per_agent\n self.num_agents = num_agents\n if (self.max_incidents_per_agent - self.min_incidents_per_agent) < 2 or self.num_agents < 2:\n raise Exception(\n \"The difference between maximum incidents and minimum incidents should be at least two. The number of agents should also be at least 2.\"\n )\n self.task_description = f\"You have to retrieve some information from a dashboard chart based on the description below. The chart presents the number of 'incidents' assigned to different agents. After retrieving the information, you will be asked to use it to complete a task.\\n \\n\"\n self.task_description += f\"Title of the report: {self.incident_hashtag}\\n\\n\"\n if self.level == 3:\n self.task_description += f\"Referring to the company protocol '{self.protocol_name}' (located in the 'Company Protocols' knowledge base), complete the dashboard retrieval task.\\n\\n\"\n self.short_description = (\n f\"Retrieve information from the chart with title {self.incident_hashtag} and perform the mentioned task.\"\n + \"\\n For calculations, please round off to the next highest integer if required. If the required calculation has multiple possible answers (for example, 'mode' or 'most frequently' occuring value), please consider the highest value.\\n\\n\"\n )\n\n def create_report(\n self,\n user_roles=[\"itil\"],\n ) -> None:\n self.agents = {}\n self.agent_sysids = []\n for _ in range(self.num_agents):\n agent_response = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=user_roles,\n )\n self.agents[agent_response[\"sys_id\"]] = agent_response\n self.agent_sysids.append(agent_response[\"sys_id\"])\n\n highest_agent = self.agent_sysids[\n -1\n ] # Choose last agent as the agent with maximum incidents\n self.agents[highest_agent][\"num_incidents\"] = self.max_incidents_per_agent\n self.agents[highest_agent][\"incident_configs\"] = []\n\n lowest_agent = self.agent_sysids[\n 0\n ] # Choose first agent as the agent with minimum incidents\n self.agents[lowest_agent][\"num_incidents\"] = self.min_incidents_per_agent\n self.agents[lowest_agent][\"incident_configs\"] = []\n\n for agent_sysid in self.agent_sysids[1:-1]:\n self.agents[agent_sysid][\"num_incidents\"] = self.random.randint(\n self.min_incidents_per_agent + 1, self.max_incidents_per_agent - 1\n )\n self.agents[agent_sysid][\"incident_configs\"] = []\n\n number_assignments = sum([agent[\"num_incidents\"] for agent in self.agents.values()])\n\n all_existing_incidents = table_api_call(\n instance=self.instance, table=\"incident\", method=\"GET\"\n )[\"result\"]\n self.all_incident_numbers = [incident[\"number\"] for incident in all_existing_incidents]\n\n self.new_incident_numbers = []\n for _ in range(number_assignments):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(self.random.randint(1000, 9999))\n )\n while (\n incident_number in self.all_incident_numbers\n or incident_number in self.new_incident_numbers\n ):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(random.randint(1000, 9999))\n )\n self.new_incident_numbers.append(incident_number)\n\n incident_number_idx = 0\n for agent, agent_attributes in self.agents.items():\n for _ in range(agent_attributes[\"num_incidents\"]):\n incident_response = create_incident(\n instance=self.instance,\n incident_number=self.new_incident_numbers[incident_number_idx],\n caller_sys_id=self._base_user_sysid,\n category=\"software\",\n priority=4,\n impact=2, # priority is calculated as some combination of impact and urgency\n urgency=3,\n incident_hastag=self.incident_hashtag,\n assigned_to=agent,\n )\n self.agents[agent][\"incident_configs\"].append(incident_response)\n incident_number_idx += 1\n\n self.report_sys_id, _ = create_report(\n instance=self.instance,\n table=\"incident\",\n filter_hashtag=self.incident_hashtag,\n field=\"assigned_to\",\n plot_title=self.chart_title,\n random=self.random,\n )\n\n def get_agent_values(self, attribute_name, filter_than) -> list[str]:\n agent_values = []\n agent_value_sysids = []\n agent_incidents = [\n agent_attributes[\"num_incidents\"] for agent_attributes in self.agents.values()\n ]\n\n if self.question == \"max\":\n agent_value_sysids.append(self.agents[self.agent_sysids[-1]][\"sys_id\"])\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n self.agents[self.agent_sysids[-1]][\"first_name\"]\n + \" \"\n + self.agents[self.agent_sysids[-1]][\"last_name\"]\n )\n agent_values.append(agent_full_name)\n elif attribute_name == \"first_name\":\n agent_first_name = self.agents[self.agent_sysids[-1]][\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n elif self.question == \"min\":\n agent_value_sysids.append(self.agents[self.agent_sysids[0]][\"sys_id\"])\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n self.agents[self.agent_sysids[0]][\"first_name\"]\n + \" \"\n + self.agents[self.agent_sysids[0]][\"last_name\"]\n )\n agent_values.append(agent_full_name)\n elif attribute_name == \"first_name\":\n agent_first_name = self.agents[self.agent_sysids[0]][\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n elif self.question == \"mean\" or self.question == \"median\" or self.question == \"mode\":\n if self.question == \"mean\":\n mean_incidents = np.mean(agent_incidents)\n incidents_count = int(np.ceil(mean_incidents))\n elif self.question == \"median\":\n incidents_count = int(np.ceil(np.median(agent_incidents)))\n elif self.question == \"mode\":\n # We select the maximum value if there are two or more modes\n frequencies = {}\n for count in agent_incidents:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n incidents_count = int(max(max_frequencies))\n\n for agent_sysid, agent_attributes in self.agents.items():\n if (\n filter_than == \"greater\"\n and agent_attributes[\"num_incidents\"] >= incidents_count\n ) or (\n filter_than == \"lesser\" and agent_attributes[\"num_incidents\"] <= incidents_count\n ):\n agent_value_sysids.append(agent_sysid)\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n agent_attributes[\"first_name\"] + \" \" + agent_attributes[\"last_name\"]\n )\n agent_values.append(agent_full_name)\n\n elif attribute_name == \"first_name\":\n agent_first_name = agent_attributes[\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n else:\n raise Exception(\"Unsopprted question type.\")\n\n return agent_values, agent_value_sysids\n\n def set_compositional_task(self) -> None:\n raise NotImplementedError\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the incidents and users\n for agent_sys_id in self.agents:\n for incident in self.agents[agent_sys_id][\"incident_configs\"]:\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=incident[\"sys_id\"],\n )\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=agent_sys_id,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndDoInfeasibleTask(DashboardRetrieveAndDoInfeasibleTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_incidents_per_agent: int = 4,\n min_incidents_per_agent: int = 1,\n num_agents: int = 4,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n function: callable = None,\n provide_reason: bool = True,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveIncidentAndDoInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveIncidentAndDoInfeasibleTask#L548-L791","kind":"class","name":"DashboardRetrieveIncidentAndDoInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":548,"end_line":791,"context_start_line":528,"context_end_line":811,"code":" instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the incidents and users\n for agent_sys_id in self.agents:\n for incident in self.agents[agent_sys_id][\"incident_configs\"]:\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=incident[\"sys_id\"],\n )\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=agent_sys_id,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndDoInfeasibleTask(DashboardRetrieveAndDoInfeasibleTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_incidents_per_agent: int = 4,\n min_incidents_per_agent: int = 1,\n num_agents: int = 4,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n function: callable = None,\n provide_reason: bool = True,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.incident_hashtag = (\n f\"#INC{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems\n )\n self.chart_title = f\"Incidents with hashtag {self.incident_hashtag}\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n dashboard_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.chart_title,\n \"question\": question,\n \"chart_series\": \"\",\n },\n level=level,\n dashboard_class=dashboard_class,\n )\n self.question = question\n self.max_incidents_per_agent = max_incidents_per_agent\n self.min_incidents_per_agent = min_incidents_per_agent\n self.num_agents = num_agents\n if (self.max_incidents_per_agent - self.min_incidents_per_agent) < 2 or self.num_agents < 2:\n raise Exception(\n \"The difference between maximum incidents and minimum incidents should be at least two. The number of agents should also be at least 2.\"\n )\n self.task_description = f\"Retrieve the information mentioned in the following description from the report of the incidents with the title {self.incident_hashtag}. Using the information, follow the subsequent task steps mentioned. For all calculations, round of to the next highest integer first. For multiple modes, choose the highest value.\\n\"\n if self.level == 3:\n self.task_description += f\"Follow the '{self.protocol_name}' protocol from the knowledge base for extra instructions.\\n\"\n self.short_description = \"Retrieve incident information and perform the mentioned task\"\n self.function = partial(function, provide_reason=provide_reason)\n\n def create_report(\n self,\n user_roles=[\"itil\"],\n ) -> None:\n self.agents = {}\n self.agent_sysids = []\n for _ in range(self.num_agents):\n agent_response = create_user(\n instance=self.instance,\n first_name=f\"{fake.first_name()}-{fake.first_name()}\",\n last_name=f\"{fake.last_name()}-{fake.last_name()}\",\n return_full_response=True,\n user_roles=user_roles,\n )\n self.agents[agent_response[\"sys_id\"]] = agent_response\n self.agent_sysids.append(agent_response[\"sys_id\"])\n\n highest_agent = self.agent_sysids[\n -1\n ] # Choose last agent as the agent with maximum incidents\n self.agents[highest_agent][\"num_incidents\"] = self.max_incidents_per_agent\n self.agents[highest_agent][\"incident_configs\"] = []\n\n lowest_agent = self.agent_sysids[\n 0\n ] # Choose first agent as the agent with minimum incidents\n self.agents[lowest_agent][\"num_incidents\"] = self.min_incidents_per_agent\n self.agents[lowest_agent][\"incident_configs\"] = []\n\n for agent_sysid in self.agent_sysids[1:-1]:\n self.agents[agent_sysid][\"num_incidents\"] = self.random.randint(\n self.min_incidents_per_agent + 1, self.max_incidents_per_agent - 1\n )\n self.agents[agent_sysid][\"incident_configs\"] = []\n\n number_assignments = sum([agent[\"num_incidents\"] for agent in self.agents.values()])\n\n all_existing_incidents = table_api_call(\n instance=self.instance, table=\"incident\", method=\"GET\"\n )[\"result\"]\n self.all_incident_numbers = [incident[\"number\"] for incident in all_existing_incidents]\n\n self.new_incident_numbers = []\n for _ in range(number_assignments):\n incident_number = (\n self.prefix + str(id(self) % (10**8)).zfill(8)[:4] + str(random.randint(1000, 9999))\n )\n while (\n incident_number in self.all_incident_numbers\n or incident_number in self.new_incident_numbers\n ):\n incident_number = (\n self.prefix\n + str(id(self) % (10**8)).zfill(8)[:4]\n + str(random.randint(1000, 9999))\n )\n self.new_incident_numbers.append(incident_number)\n\n incident_number_idx = 0\n for agent, agent_attributes in self.agents.items():\n for _ in range(agent_attributes[\"num_incidents\"]):\n incident_response = create_incident(\n instance=self.instance,\n incident_number=self.new_incident_numbers[incident_number_idx],\n caller_sys_id=self._base_user_sysid,\n category=\"software\",\n priority=4,\n impact=2, # priority is calculated as some combination of impact and urgency\n urgency=3,\n incident_hastag=self.incident_hashtag,\n assigned_to=agent,\n )\n self.agents[agent][\"incident_configs\"].append(incident_response)\n incident_number_idx += 1\n\n self.report_sys_id, _ = create_report(\n instance=self.instance,\n table=\"incident\",\n filter_hashtag=self.incident_hashtag,\n field=\"assigned_to\",\n plot_title=self.chart_title,\n random=self.random,\n )\n\n def get_agent_values(self, attribute_name, filter_than) -> list[str]:\n agent_values = []\n agent_value_sysids = []\n agent_incidents = [\n agent_attributes[\"num_incidents\"] for agent_attributes in self.agents.values()\n ]\n\n if self.question == \"max\":\n agent_value_sysids.append(self.agents[self.agent_sysids[-1]][\"sys_id\"])\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n self.agents[self.agent_sysids[-1]][\"first_name\"]\n + \" \"\n + self.agents[self.agent_sysids[-1]][\"last_name\"]\n )\n agent_values.append(agent_full_name)\n elif attribute_name == \"first_name\":\n agent_first_name = self.agents[self.agent_sysids[-1]][\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n elif self.question == \"min\":\n agent_value_sysids.append(self.agents[self.agent_sysids[0]][\"sys_id\"])\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n self.agents[self.agent_sysids[0]][\"first_name\"]\n + \" \"\n + self.agents[self.agent_sysids[0]][\"last_name\"]\n )\n agent_values.append(agent_full_name)\n elif attribute_name == \"first_name\":\n agent_first_name = self.agents[self.agent_sysids[0]][\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n elif self.question == \"mean\" or self.question == \"median\" or self.question == \"mode\":\n if self.question == \"mean\":\n mean_incidents = np.mean(agent_incidents)\n incidents_count = int(np.ceil(mean_incidents))\n elif self.question == \"median\":\n incidents_count = int(np.ceil(np.median(agent_incidents)))\n elif self.question == \"mode\":\n # We select the maximum value if there are two or more modes\n frequencies = {}\n for count in agent_incidents:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n incidents_count = int(max(max_frequencies))\n\n for agent_sysid, agent_attributes in self.agents.items():\n if (\n filter_than == \"greater\"\n and agent_attributes[\"num_incidents\"] >= incidents_count\n ) or (\n filter_than == \"lesser\" and agent_attributes[\"num_incidents\"] <= incidents_count\n ):\n agent_value_sysids.append(agent_sysid)\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n agent_attributes[\"first_name\"] + \" \" + agent_attributes[\"last_name\"]\n )\n agent_values.append(agent_full_name)\n\n elif attribute_name == \"first_name\":\n agent_first_name = agent_attributes[\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n else:\n raise Exception(\"Unsopprted question type.\")\n\n return agent_values, agent_value_sysids\n\n def set_compositional_task(self) -> None:\n raise NotImplementedError\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the incidents and users\n for agent_sys_id in self.agents:\n for incident in self.agents[agent_sys_id][\"incident_configs\"]:\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=incident[\"sys_id\"],\n )\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=agent_sys_id,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveCatalogAndDoTask(DashboardRetrieveAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_items: int = 5,\n min_items: int = 3,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n min_catalog_item: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.catalog_hashtag = (\n f\"#CAT{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveCatalogAndDoTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveCatalogAndDoTask#L794-L1071","kind":"class","name":"DashboardRetrieveCatalogAndDoTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":794,"end_line":1071,"context_start_line":774,"context_end_line":1091,"code":" instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the incidents and users\n for agent_sys_id in self.agents:\n for incident in self.agents[agent_sys_id][\"incident_configs\"]:\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=incident[\"sys_id\"],\n )\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=agent_sys_id,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveCatalogAndDoTask(DashboardRetrieveAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_items: int = 5,\n min_items: int = 3,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n min_catalog_item: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.catalog_hashtag = (\n f\"#CAT{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems\n )\n self.chart_title = f\"Catalog with hashtag {self.catalog_hashtag}\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n dashboard_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.chart_title,\n \"question\": question,\n \"chart_series\": \"\",\n },\n level=level,\n dashboard_class=dashboard_class,\n )\n self.question = question\n self.max_number_per_item = self.random.choice([5, 6, 7])\n self.min_number_per_item = self.random.choice([1, 2])\n self.max_items = max_items\n self.min_items = min_items\n if self.max_items < 2 or self.min_items < 2:\n raise Exception(\"The items allowed should at least be 2.\")\n self.min_catalog_item = min_catalog_item\n self.task_description = f\"You have to retrieve some information from a dashboard chart based on the description below. The chart presents the number of 'hardware items' available in stock. After retrieving the information, you will be asked to use it to complete a task.\\n \\n\"\n self.task_description += f\"Title of the report: {self.catalog_hashtag}\\n\\n\"\n if self.level == 3:\n self.task_description += f\"Referring to the company protocol '{self.protocol_name}' (located in the 'Company Protocols' knowledge base), complete the dashboard retrieval task.\\n\\n\"\n self.short_description = (\n f\"Retrieve information from the chart with the title {self.catalog_hashtag} and perform the mentioned task.\"\n + \"\\nFor calculations, please round off to the next highest integer if required. If the required calculation has multiple possible answers (for example, 'mode' or 'most frequently' occuring value), please consider the highest value.\\n\\n\"\n )\n\n def get_catalog_item_sysid(self, catalog_item: str) -> str:\n catalog_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\"sysparm_query\": f\"sys_name={catalog_item}\", \"sysparm_fields\": \"sys_id\"},\n method=\"GET\",\n )[\"result\"]\n if len(catalog_item_response) == 0:\n raise Exception(\"Catalog item not found.\")\n elif len(catalog_item_response) > 1:\n raise Exception(\"Multiple catalog items found.\")\n return catalog_item_response[0][\"sys_id\"]\n\n def create_report(\n self,\n user_roles=[\"itil\"],\n ) -> None:\n catalog_item_list = list(META_CONFIGS.keys())\n catalog_item_list.remove(self.min_catalog_item)\n random_service_catalog_items = self.random.choice(\n catalog_item_list, self.random.randint(self.min_items, self.max_items), replace=False\n ).tolist()\n cat_item_sys_name = {\n \"Developer Laptop (Mac)\": \"Developer Laptop (Mac)\",\n \"iPad mini\": \"iPad mini\",\n \"iPad pro\": \"iPad pro\",\n \"Sales Laptop\": \"Sales Laptop\",\n \"Standard Laptop\": \"Standard Laptop\",\n \"Apple Watch\": \"Apple Watch\",\n \"Apple MacBook Pro 15\": 'Apple MacBook Pro 15\"',\n \"Development Laptop (PC)\": \"Development Laptop (PC)\",\n \"Loaner Laptop\": \"Notebook Computer Loaner\",\n }\n\n # shuffle\n self.random.shuffle(random_service_catalog_items)\n self.random_service_catalog_items = random_service_catalog_items\n random_service_catalog_items = [self.min_catalog_item] + random_service_catalog_items\n\n service_catalog_report_config = {}\n service_catalog_report_config[random_service_catalog_items[0]] = {\n \"quantity\": self.min_number_per_item,\n \"description\": META_CONFIGS[random_service_catalog_items[0]][\"desc\"],\n \"configuration\": {},\n \"item\": random_service_catalog_items[0],\n \"sys_id\": self.get_catalog_item_sysid(\n cat_item_sys_name[random_service_catalog_items[0]]\n ),\n }\n service_catalog_report_config[random_service_catalog_items[-1]] = {\n \"quantity\": self.max_number_per_item,\n \"description\": META_CONFIGS[random_service_catalog_items[-1]][\"desc\"],\n \"configuration\": {},\n \"item\": random_service_catalog_items[-1],\n \"sys_id\": self.get_catalog_item_sysid(\n cat_item_sys_name[random_service_catalog_items[-1]]\n ),\n }\n\n for service_catalog_item in random_service_catalog_items[1:-1]:\n service_catalog_report_config[service_catalog_item] = {\n \"quantity\": self.random.randint(\n self.min_number_per_item + 1, self.max_number_per_item - 1\n ),\n \"description\": META_CONFIGS[service_catalog_item][\"desc\"],\n \"configuration\": {},\n \"item\": service_catalog_item,\n \"sys_id\": self.get_catalog_item_sysid(cat_item_sys_name[service_catalog_item]),\n }\n\n self.service_catalog_report_config = service_catalog_report_config\n created_request_items = []\n for (\n service_catalog_item,\n service_catalog_item_config,\n ) in service_catalog_report_config.items():\n for _ in range(service_catalog_item_config[\"quantity\"]):\n request_item_dict = {\n \"requested_for\": self._base_user_sysid,\n \"quantity\": 1,\n \"cat_item\": service_catalog_item_config[\"sys_id\"],\n }\n criteria_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n json=request_item_dict,\n method=\"POST\",\n )[\"result\"]\n created_request_items.append((service_catalog_item, criteria_response[\"sys_id\"]))\n\n self.created_request_items = created_request_items\n\n user_details = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n \"sysparm_fields\": \"first_name,last_name\",\n },\n method=\"GET\",\n )[\"result\"][0]\n user_full_name = user_details[\"first_name\"] + \" \" + user_details[\"last_name\"]\n\n self.report_sys_id, _ = create_report(\n instance=self.instance,\n table=\"sc_req_item\",\n filter_hashtag=user_full_name,\n filter_field=\"requested_for\",\n field=\"cat_item\",\n plot_title=self.chart_title,\n random=self.random,\n )\n\n def get_order_quantity_value(self) -> list[str]:\n quantities = [\n service_catalog_report_config_attribute[\"quantity\"]\n for service_catalog_report_config_attribute in self.service_catalog_report_config.values()\n ]\n if self.question == \"max\":\n if max(quantities) != self.max_number_per_item:\n raise Exception(\"Maximum of quantities does not match attribute. Please check.\")\n target_quantity = self.max_number_per_item\n elif self.question == \"mean\":\n mean_quantity = np.mean(quantities)\n target_quantity = int(np.ceil(mean_quantity))\n elif self.question == \"median\":\n target_quantity = int(np.ceil(np.median(quantities)))\n elif self.question == \"mode\":\n frequencies = {}\n for count in quantities:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n target_quantity = int(max(max_frequencies))\n if target_quantity - self.min_number_per_item <= 0:\n raise Exception(\"Unable to order quantity {target_quantity - self.min_number_per_item}\")\n return int(target_quantity - self.min_number_per_item)\n\n def set_compositional_task(self) -> None:\n\n order_config = {\n \"configuration\": {},\n \"description\": META_CONFIGS[self.min_catalog_item][\"desc\"],\n \"item\": self.min_catalog_item,\n \"quantity\": self.get_order_quantity_value(),\n }\n\n create_order_item_subtask = [\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n \"url\": \"/now/nav/ui/classic/params/target/catalog_home.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n self.order_item_class(\n instance=self.instance,\n fixed_config=order_config,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n self.compositional_task = create_order_item_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of all the items in stock.\\n\\n\"\n + f\"\\t - Task: Place an order for the least available item in stock. The quantity of the order should be such that the final quantity of this item matches the above retrieved value.\\n\"\n + f\"\\t For example, consider the above task asks you to retrieve the maximum number of items in stock, say 4, and the least available item is an Apple Watch and its quantity is 1. You have to order 3 more Apple Watches.\\n\\n\"\n + f\"\\t - Please do not change any other configuration while placing the order for the item. You can find important links to the pages in the protocol article.\\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page.\\n\"\n + f\"\\n2. Given the title of the report, search for it on this page.\\n\"\n + f\"\\n3. Find the value which is the {self.description_mapping[self.question]} of the items present in stock as per the chart. Also remember the least available item in the stock.\\n\"\n + f\"\\n4. Navigate to Self-Service > Service Catalog. \\n\"\n + f\"\\n5. For the least available item in stock, place an order for extra items such that its quantity matches the value you found.\"\n + \"\\nFor example, if you were requested to find the maximum value across the items, you would place an order for the least available item such that its NEW quantity matches this number. Please do not change any 'configuration' when placing the order.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the request items\n for created_request_item in self.created_request_items:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_request_item[1],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveCatalogAndDoInfeasibleTask(DashboardRetrieveAndDoInfeasibleTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_items: int = 5,\n min_items: int = 3,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n min_catalog_item: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.catalog_hashtag = (","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveCatalogAndDoInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_base.DashboardRetrieveCatalogAndDoInfeasibleTask#L1074-L1360","kind":"class","name":"DashboardRetrieveCatalogAndDoInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1074,"end_line":1360,"context_start_line":1054,"context_end_line":1366,"code":"\n return goal, info\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the request items\n for created_request_item in self.created_request_items:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_request_item[1],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveCatalogAndDoInfeasibleTask(DashboardRetrieveAndDoInfeasibleTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_items: int = 5,\n min_items: int = 3,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n min_catalog_item: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.catalog_hashtag = (\n f\"#CAT{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems\n )\n self.chart_title = f\"Catalog with hashtag {self.catalog_hashtag}\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n dashboard_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.chart_title,\n \"question\": question,\n \"chart_series\": \"\",\n },\n level=level,\n dashboard_class=dashboard_class,\n )\n self.question = question\n self.max_number_per_item = self.random.choice([5, 6, 7])\n self.min_number_per_item = self.random.choice([1, 2])\n self.max_items = max_items\n self.min_items = min_items\n if self.max_items < 2 or self.min_items < 2:\n raise Exception(\"The items allowed should at least be 2.\")\n self.task_description = f\"Retrieve the information mentioned in the following description from the report of the catalogs with the title {self.catalog_hashtag}. Using the information, follow the subsequent task steps mentioned. For all calculations, round of to the next highest integer first. For multiple modes, choose the highest value.\\n\"\n if self.level == 3:\n self.task_description += f\"Follow the '{self.protocol_name}' protocol from the knowledge base for extra instructions.\\n\"\n self.short_description = \"Retrieve catalog information and perform the mentioned task\"\n self.min_catalog_item = min_catalog_item\n self.function = partial(\n get_infeasible_service_catalog_config, provide_reason=provide_reason\n )\n self.all_configs = self.all_configs()\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_catalog_item_sysid(self, catalog_item: str) -> str:\n catalog_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\"sysparm_query\": f\"sys_name={catalog_item}\", \"sysparm_fields\": \"sys_id\"},\n method=\"GET\",\n )[\"result\"]\n if len(catalog_item_response) == 0:\n raise Exception(\"Catalog item not found.\")\n elif len(catalog_item_response) > 1:\n raise Exception(\"Multiple catalog items found.\")\n return catalog_item_response[0][\"sys_id\"]\n\n def create_report(\n self,\n user_roles=[\"itil\"],\n ) -> None:\n catalog_item_list = list(META_CONFIGS.keys())\n catalog_item_list.remove(self.min_catalog_item)\n random_service_catalog_items = self.random.choice(\n catalog_item_list, self.random.randint(self.min_items, self.max_items), replace=False\n ).tolist()\n cat_item_sys_name = {\n \"Developer Laptop (Mac)\": \"Developer Laptop (Mac)\",\n \"iPad mini\": \"iPad mini\",\n \"iPad pro\": \"iPad pro\",\n \"Sales Laptop\": \"Sales Laptop\",\n \"Standard Laptop\": \"Standard Laptop\",\n \"Apple Watch\": \"Apple Watch\",\n \"Apple MacBook Pro 15\": 'Apple MacBook Pro 15\"',\n \"Development Laptop (PC)\": \"Development Laptop (PC)\",\n \"Loaner Laptop\": \"Notebook Computer Loaner\",\n }\n\n # shuffle\n self.random.shuffle(random_service_catalog_items)\n random_service_catalog_items = [\n self.min_catalog_item\n ] + random_service_catalog_items.tolist()\n self.random_service_catalog_items = random_service_catalog_items\n\n service_catalog_report_config = {}\n service_catalog_report_config[random_service_catalog_items[0]] = {\n \"quantity\": self.min_number_per_item,\n \"description\": META_CONFIGS[random_service_catalog_items[0]][\"desc\"],\n \"configuration\": {},\n \"item\": random_service_catalog_items[0],\n \"sys_id\": self.get_catalog_item_sysid(\n cat_item_sys_name[random_service_catalog_items[0]]\n ),\n }\n service_catalog_report_config[random_service_catalog_items[-1]] = {\n \"quantity\": self.max_number_per_item,\n \"description\": META_CONFIGS[random_service_catalog_items[-1]][\"desc\"],\n \"configuration\": {},\n \"item\": random_service_catalog_items[-1],\n \"sys_id\": self.get_catalog_item_sysid(\n cat_item_sys_name[random_service_catalog_items[-1]]\n ),\n }\n\n for service_catalog_item in random_service_catalog_items[1:-1]:\n service_catalog_report_config[service_catalog_item] = {\n \"quantity\": self.random.randint(\n self.min_number_per_item + 1, self.max_number_per_item - 1\n ),\n \"description\": META_CONFIGS[service_catalog_item][\"desc\"],\n \"configuration\": {},\n \"item\": service_catalog_item,\n \"sys_id\": self.get_catalog_item_sysid(cat_item_sys_name[service_catalog_item]),\n }\n\n self.service_catalog_report_config = service_catalog_report_config\n created_request_items = []\n for (\n service_catalog_item,\n service_catalog_item_config,\n ) in service_catalog_report_config.items():\n for _ in range(service_catalog_item_config[\"quantity\"]):\n request_item_dict = {\n \"requested_for\": self._base_user_sysid,\n \"quantity\": 1,\n \"cat_item\": service_catalog_item_config[\"sys_id\"],\n }\n criteria_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n json=request_item_dict,\n method=\"POST\",\n )[\"result\"]\n created_request_items.append((service_catalog_item, criteria_response[\"sys_id\"]))\n\n self.created_request_items = created_request_items\n\n user_details = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n \"sysparm_fields\": \"first_name,last_name\",\n },\n method=\"GET\",\n )[\"result\"][0]\n user_full_name = user_details[\"first_name\"] + \" \" + user_details[\"last_name\"]\n\n self.report_sys_id, _ = create_report(\n instance=self.instance,\n table=\"sc_req_item\",\n filter_hashtag=user_full_name,\n filter_field=\"requested_for\",\n field=\"cat_item\",\n plot_title=self.chart_title,\n random=self.random,\n )\n\n def get_order_quantity_value(self) -> list[str]:\n quantities = [\n service_catalog_report_config_attribute[\"quantity\"]\n for service_catalog_report_config_attribute in self.service_catalog_report_config.values()\n ]\n if self.question == \"max\":\n if max(quantities) != self.max_number_per_item:\n raise Exception(\"Maximum of quantities does not match attribute. Please check.\")\n target_quantity = self.max_number_per_item\n elif self.question == \"mean\":\n mean_quantity = np.mean(quantities)\n target_quantity = int(np.ceil(mean_quantity))\n elif self.question == \"median\":\n target_quantity = int(np.ceil(np.median(quantities)))\n elif self.question == \"mode\":\n frequencies = {}\n for count in quantities:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n target_quantity = int(max(max_frequencies))\n if target_quantity - self.min_number_per_item <= 0:\n raise Exception(\"Unable to order quantity {target_quantity - self.min_number_per_item}\")\n return int(target_quantity - self.min_number_per_item)\n\n def set_compositional_task(self) -> None:\n\n config = self.random.choice(self.all_configs)\n self.configuration = config[\"configuration\"]\n order_config = {\n \"configuration\": self.configuration,\n \"description\": META_CONFIGS[self.min_catalog_item][\"desc\"],\n \"item\": self.min_catalog_item,\n \"quantity\": self.get_order_quantity_value(),\n }\n order_config, self.infeasible_reasons = self.function(\n config=order_config, random=self.random\n )\n\n create_order_item_subtask = [\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n \"url\": \"/now/nav/ui/classic/params/target/catalog_home.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n self.order_item_class(\n instance=self.instance,\n fixed_config=order_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n self.compositional_task = create_order_item_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the catalog items.\\n\"\n + f\"Task: Place an order for requesting more of the least available item in the report. The quantity of the order should be such that the final quantity of this item matches the above retrieved value.\\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the catalog report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the value which is the {self.description_mapping[self.question]} of the catalog items present in stock shown in the report. \\n\"\n + f\"\\n3. Navigate to Self-Service > Service Catalog. \\n\"\n + f\"\\n4. For the least available item in stock, place an order for extra items such that its quantity matches the value you found.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the request items\n for created_request_item in self.created_request_items:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_request_item[1],\n )\n return super().teardown()\n\n\nclass DashDoFinalTask:\n \"\"\"Base class for dash do final tasks block tasks. Used to include these tasks across multiple superclasses.\"\"\"\n\n pass","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.DashDoFinalTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_base.DashDoFinalTask#L1363-L1366","kind":"class","name":"DashDoFinalTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1363,"end_line":1366,"context_start_line":1343,"context_end_line":1366,"code":"\n return goal, info\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the request items\n for created_request_item in self.created_request_items:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_request_item[1],\n )\n return super().teardown()\n\n\nclass DashDoFinalTask:\n \"\"\"Base class for dash do final tasks block tasks. Used to include these tasks across multiple superclasses.\"\"\"\n\n pass","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.__init__#L1075-L1123","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1075,"end_line":1123,"context_start_line":1055,"context_end_line":1143,"code":" return goal, info\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the request items\n for created_request_item in self.created_request_items:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_request_item[1],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveCatalogAndDoInfeasibleTask(DashboardRetrieveAndDoInfeasibleTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_items: int = 5,\n min_items: int = 3,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n min_catalog_item: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.catalog_hashtag = (\n f\"#CAT{str(id(self) % (10**8)).zfill(9)}\" # identifier to select problems\n )\n self.chart_title = f\"Catalog with hashtag {self.catalog_hashtag}\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n dashboard_config={\n \"url\": \"/now/nav/ui/classic/params/target/sys_report\",\n \"chart_title\": self.chart_title,\n \"question\": question,\n \"chart_series\": \"\",\n },\n level=level,\n dashboard_class=dashboard_class,\n )\n self.question = question\n self.max_number_per_item = self.random.choice([5, 6, 7])\n self.min_number_per_item = self.random.choice([1, 2])\n self.max_items = max_items\n self.min_items = min_items\n if self.max_items < 2 or self.min_items < 2:\n raise Exception(\"The items allowed should at least be 2.\")\n self.task_description = f\"Retrieve the information mentioned in the following description from the report of the catalogs with the title {self.catalog_hashtag}. Using the information, follow the subsequent task steps mentioned. For all calculations, round of to the next highest integer first. For multiple modes, choose the highest value.\\n\"\n if self.level == 3:\n self.task_description += f\"Follow the '{self.protocol_name}' protocol from the knowledge base for extra instructions.\\n\"\n self.short_description = \"Retrieve catalog information and perform the mentioned task\"\n self.min_catalog_item = min_catalog_item\n self.function = partial(\n get_infeasible_service_catalog_config, provide_reason=provide_reason\n )\n self.all_configs = self.all_configs()\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_catalog_item_sysid(self, catalog_item: str) -> str:\n catalog_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\"sysparm_query\": f\"sys_name={catalog_item}\", \"sysparm_fields\": \"sys_id\"},\n method=\"GET\",\n )[\"result\"]\n if len(catalog_item_response) == 0:\n raise Exception(\"Catalog item not found.\")\n elif len(catalog_item_response) > 1:\n raise Exception(\"Multiple catalog items found.\")\n return catalog_item_response[0][\"sys_id\"]\n\n def create_report(","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.create_report","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.create_report#L1143-L1243","kind":"function","name":"create_report","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1143,"end_line":1243,"context_start_line":1123,"context_end_line":1263,"code":" self.all_configs = self.all_configs()\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_catalog_item_sysid(self, catalog_item: str) -> str:\n catalog_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\"sysparm_query\": f\"sys_name={catalog_item}\", \"sysparm_fields\": \"sys_id\"},\n method=\"GET\",\n )[\"result\"]\n if len(catalog_item_response) == 0:\n raise Exception(\"Catalog item not found.\")\n elif len(catalog_item_response) > 1:\n raise Exception(\"Multiple catalog items found.\")\n return catalog_item_response[0][\"sys_id\"]\n\n def create_report(\n self,\n user_roles=[\"itil\"],\n ) -> None:\n catalog_item_list = list(META_CONFIGS.keys())\n catalog_item_list.remove(self.min_catalog_item)\n random_service_catalog_items = self.random.choice(\n catalog_item_list, self.random.randint(self.min_items, self.max_items), replace=False\n ).tolist()\n cat_item_sys_name = {\n \"Developer Laptop (Mac)\": \"Developer Laptop (Mac)\",\n \"iPad mini\": \"iPad mini\",\n \"iPad pro\": \"iPad pro\",\n \"Sales Laptop\": \"Sales Laptop\",\n \"Standard Laptop\": \"Standard Laptop\",\n \"Apple Watch\": \"Apple Watch\",\n \"Apple MacBook Pro 15\": 'Apple MacBook Pro 15\"',\n \"Development Laptop (PC)\": \"Development Laptop (PC)\",\n \"Loaner Laptop\": \"Notebook Computer Loaner\",\n }\n\n # shuffle\n self.random.shuffle(random_service_catalog_items)\n random_service_catalog_items = [\n self.min_catalog_item\n ] + random_service_catalog_items.tolist()\n self.random_service_catalog_items = random_service_catalog_items\n\n service_catalog_report_config = {}\n service_catalog_report_config[random_service_catalog_items[0]] = {\n \"quantity\": self.min_number_per_item,\n \"description\": META_CONFIGS[random_service_catalog_items[0]][\"desc\"],\n \"configuration\": {},\n \"item\": random_service_catalog_items[0],\n \"sys_id\": self.get_catalog_item_sysid(\n cat_item_sys_name[random_service_catalog_items[0]]\n ),\n }\n service_catalog_report_config[random_service_catalog_items[-1]] = {\n \"quantity\": self.max_number_per_item,\n \"description\": META_CONFIGS[random_service_catalog_items[-1]][\"desc\"],\n \"configuration\": {},\n \"item\": random_service_catalog_items[-1],\n \"sys_id\": self.get_catalog_item_sysid(\n cat_item_sys_name[random_service_catalog_items[-1]]\n ),\n }\n\n for service_catalog_item in random_service_catalog_items[1:-1]:\n service_catalog_report_config[service_catalog_item] = {\n \"quantity\": self.random.randint(\n self.min_number_per_item + 1, self.max_number_per_item - 1\n ),\n \"description\": META_CONFIGS[service_catalog_item][\"desc\"],\n \"configuration\": {},\n \"item\": service_catalog_item,\n \"sys_id\": self.get_catalog_item_sysid(cat_item_sys_name[service_catalog_item]),\n }\n\n self.service_catalog_report_config = service_catalog_report_config\n created_request_items = []\n for (\n service_catalog_item,\n service_catalog_item_config,\n ) in service_catalog_report_config.items():\n for _ in range(service_catalog_item_config[\"quantity\"]):\n request_item_dict = {\n \"requested_for\": self._base_user_sysid,\n \"quantity\": 1,\n \"cat_item\": service_catalog_item_config[\"sys_id\"],\n }\n criteria_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n json=request_item_dict,\n method=\"POST\",\n )[\"result\"]\n created_request_items.append((service_catalog_item, criteria_response[\"sys_id\"]))\n\n self.created_request_items = created_request_items\n\n user_details = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n \"sysparm_fields\": \"first_name,last_name\",\n },\n method=\"GET\",\n )[\"result\"][0]\n user_full_name = user_details[\"first_name\"] + \" \" + user_details[\"last_name\"]\n\n self.report_sys_id, _ = create_report(\n instance=self.instance,\n table=\"sc_req_item\",\n filter_hashtag=user_full_name,\n filter_field=\"requested_for\",\n field=\"cat_item\",\n plot_title=self.chart_title,\n random=self.random,\n )\n\n def get_order_quantity_value(self) -> list[str]:\n quantities = [\n service_catalog_report_config_attribute[\"quantity\"]\n for service_catalog_report_config_attribute in self.service_catalog_report_config.values()\n ]\n if self.question == \"max\":\n if max(quantities) != self.max_number_per_item:\n raise Exception(\"Maximum of quantities does not match attribute. Please check.\")\n target_quantity = self.max_number_per_item\n elif self.question == \"mean\":\n mean_quantity = np.mean(quantities)\n target_quantity = int(np.ceil(mean_quantity))\n elif self.question == \"median\":\n target_quantity = int(np.ceil(np.median(quantities)))\n elif self.question == \"mode\":\n frequencies = {}\n for count in quantities:\n if count not in frequencies:\n frequencies[count] = 1","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.set_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.set_compositional_task#L1283-L1317","kind":"function","name":"set_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1283,"end_line":1317,"context_start_line":1263,"context_end_line":1337,"code":" frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n target_quantity = int(max(max_frequencies))\n if target_quantity - self.min_number_per_item <= 0:\n raise Exception(\"Unable to order quantity {target_quantity - self.min_number_per_item}\")\n return int(target_quantity - self.min_number_per_item)\n\n def set_compositional_task(self) -> None:\n\n config = self.random.choice(self.all_configs)\n self.configuration = config[\"configuration\"]\n order_config = {\n \"configuration\": self.configuration,\n \"description\": META_CONFIGS[self.min_catalog_item][\"desc\"],\n \"item\": self.min_catalog_item,\n \"quantity\": self.get_order_quantity_value(),\n }\n order_config, self.infeasible_reasons = self.function(\n config=order_config, random=self.random\n )\n\n create_order_item_subtask = [\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n \"url\": \"/now/nav/ui/classic/params/target/catalog_home.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n self.order_item_class(\n instance=self.instance,\n fixed_config=order_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n self.compositional_task = create_order_item_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the catalog items.\\n\"\n + f\"Task: Place an order for requesting more of the least available item in the report. The quantity of the order should be such that the final quantity of this item matches the above retrieved value.\\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.task_description","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.get_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.get_compositional_task#L229-L233","kind":"function","name":"get_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":229,"end_line":233,"context_start_line":209,"context_end_line":253,"code":" self.description_mapping = {\n \"max\": self.random.choice([\"maximum\", \"highest\", \"most\"]),\n \"min\": self.random.choice([\"minimum\", \"lowest\", \"least\"]),\n \"mean\": self.random.choice([\"mean\", \"average\"]),\n \"median\": \"median\",\n \"mode\": \"mode (most frequent)\",\n }\n\n def create_report(self) -> None:\n \"\"\"\n Create task relevant dashboard report\n \"\"\"\n raise NotImplementedError\n\n def set_compositional_task(self) -> None:\n \"\"\"\n Create and return the compositional task\n \"\"\"\n raise NotImplementedError\n\n def get_compositional_task(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Return the compositional task\n \"\"\"\n return self.compositional_task\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n has_description=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base._get_config#L235-L293","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":235,"end_line":293,"context_start_line":215,"context_end_line":313,"code":" }\n\n def create_report(self) -> None:\n \"\"\"\n Create task relevant dashboard report\n \"\"\"\n raise NotImplementedError\n\n def set_compositional_task(self) -> None:\n \"\"\"\n Create and return the compositional task\n \"\"\"\n raise NotImplementedError\n\n def get_compositional_task(self) -> list[AbstractServiceNowTask]:\n \"\"\"\n Return the compositional task\n \"\"\"\n return self.compositional_task\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n has_description=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f\"Can you find the '{self.protocol_name}' Protocol in the Knowledge Base?\",\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n has_description=False,\n ),\n ]\n\n dashboard_retrieval_subtask = [\n # Navigate to the reports list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Reports\",\n \"module\": \"Administration > All\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_report_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n # Find the user with the desired config\n self.dashboard_class(\n instance=self.instance,\n seed=None,\n fixed_config=self.dashboard_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + dashboard_retrieval_subtask\n + self.get_compositional_task()\n )\n return config\n\n def teardown(self) -> None:\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndDoTask(DashboardRetrieveAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_incidents_per_agent: int = 4,\n min_incidents_per_agent: int = 1,\n num_agents: int = 4,\n question: str = \"\",\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.teardown#L1346-L1360","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1346,"end_line":1360,"context_start_line":1326,"context_end_line":1366,"code":" + f\"Value to retrieve: {self.description_mapping[self.question]} of all the catalog items.\\n\"\n + f\"Task: Place an order for requesting more of the least available item in the report. The quantity of the order should be such that the final quantity of this item matches the above retrieved value.\\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the catalog report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the value which is the {self.description_mapping[self.question]} of the catalog items present in stock shown in the report. \\n\"\n + f\"\\n3. Navigate to Self-Service > Service Catalog. \\n\"\n + f\"\\n4. For the least available item in stock, place an order for extra items such that its quantity matches the value you found.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the request items\n for created_request_item in self.created_request_items:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_request_item[1],\n )\n return super().teardown()\n\n\nclass DashDoFinalTask:\n \"\"\"Base class for dash do final tasks block tasks. Used to include these tasks across multiple superclasses.\"\"\"\n\n pass","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.get_agent_values","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.get_agent_values#L681-L766","kind":"function","name":"get_agent_values","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":681,"end_line":766,"context_start_line":661,"context_end_line":786,"code":" caller_sys_id=self._base_user_sysid,\n category=\"software\",\n priority=4,\n impact=2, # priority is calculated as some combination of impact and urgency\n urgency=3,\n incident_hastag=self.incident_hashtag,\n assigned_to=agent,\n )\n self.agents[agent][\"incident_configs\"].append(incident_response)\n incident_number_idx += 1\n\n self.report_sys_id, _ = create_report(\n instance=self.instance,\n table=\"incident\",\n filter_hashtag=self.incident_hashtag,\n field=\"assigned_to\",\n plot_title=self.chart_title,\n random=self.random,\n )\n\n def get_agent_values(self, attribute_name, filter_than) -> list[str]:\n agent_values = []\n agent_value_sysids = []\n agent_incidents = [\n agent_attributes[\"num_incidents\"] for agent_attributes in self.agents.values()\n ]\n\n if self.question == \"max\":\n agent_value_sysids.append(self.agents[self.agent_sysids[-1]][\"sys_id\"])\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n self.agents[self.agent_sysids[-1]][\"first_name\"]\n + \" \"\n + self.agents[self.agent_sysids[-1]][\"last_name\"]\n )\n agent_values.append(agent_full_name)\n elif attribute_name == \"first_name\":\n agent_first_name = self.agents[self.agent_sysids[-1]][\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n elif self.question == \"min\":\n agent_value_sysids.append(self.agents[self.agent_sysids[0]][\"sys_id\"])\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n self.agents[self.agent_sysids[0]][\"first_name\"]\n + \" \"\n + self.agents[self.agent_sysids[0]][\"last_name\"]\n )\n agent_values.append(agent_full_name)\n elif attribute_name == \"first_name\":\n agent_first_name = self.agents[self.agent_sysids[0]][\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n elif self.question == \"mean\" or self.question == \"median\" or self.question == \"mode\":\n if self.question == \"mean\":\n mean_incidents = np.mean(agent_incidents)\n incidents_count = int(np.ceil(mean_incidents))\n elif self.question == \"median\":\n incidents_count = int(np.ceil(np.median(agent_incidents)))\n elif self.question == \"mode\":\n # We select the maximum value if there are two or more modes\n frequencies = {}\n for count in agent_incidents:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n incidents_count = int(max(max_frequencies))\n\n for agent_sysid, agent_attributes in self.agents.items():\n if (\n filter_than == \"greater\"\n and agent_attributes[\"num_incidents\"] >= incidents_count\n ) or (\n filter_than == \"lesser\" and agent_attributes[\"num_incidents\"] <= incidents_count\n ):\n agent_value_sysids.append(agent_sysid)\n if attribute_name == \"assigned_to\":\n agent_full_name = (\n agent_attributes[\"first_name\"] + \" \" + agent_attributes[\"last_name\"]\n )\n agent_values.append(agent_full_name)\n\n elif attribute_name == \"first_name\":\n agent_first_name = agent_attributes[\"first_name\"]\n agent_values.append(agent_first_name)\n else:\n raise Exception(\"Filter column not supported.\")\n else:\n raise Exception(\"Unsopprted question type.\")\n\n return agent_values, agent_value_sysids\n\n def set_compositional_task(self) -> None:\n raise NotImplementedError\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the incidents and users\n for agent_sys_id in self.agents:\n for incident in self.agents[agent_sys_id][\"incident_configs\"]:\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=incident[\"sys_id\"],\n )\n db_delete_from_table(","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.get_catalog_item_sysid","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.get_catalog_item_sysid#L1130-L1141","kind":"function","name":"get_catalog_item_sysid","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1130,"end_line":1141,"context_start_line":1110,"context_end_line":1161,"code":" self.min_number_per_item = self.random.choice([1, 2])\n self.max_items = max_items\n self.min_items = min_items\n if self.max_items < 2 or self.min_items < 2:\n raise Exception(\"The items allowed should at least be 2.\")\n self.task_description = f\"Retrieve the information mentioned in the following description from the report of the catalogs with the title {self.catalog_hashtag}. Using the information, follow the subsequent task steps mentioned. For all calculations, round of to the next highest integer first. For multiple modes, choose the highest value.\\n\"\n if self.level == 3:\n self.task_description += f\"Follow the '{self.protocol_name}' protocol from the knowledge base for extra instructions.\\n\"\n self.short_description = \"Retrieve catalog information and perform the mentioned task\"\n self.min_catalog_item = min_catalog_item\n self.function = partial(\n get_infeasible_service_catalog_config, provide_reason=provide_reason\n )\n self.all_configs = self.all_configs()\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_catalog_item_sysid(self, catalog_item: str) -> str:\n catalog_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\"sysparm_query\": f\"sys_name={catalog_item}\", \"sysparm_fields\": \"sys_id\"},\n method=\"GET\",\n )[\"result\"]\n if len(catalog_item_response) == 0:\n raise Exception(\"Catalog item not found.\")\n elif len(catalog_item_response) > 1:\n raise Exception(\"Multiple catalog items found.\")\n return catalog_item_response[0][\"sys_id\"]\n\n def create_report(\n self,\n user_roles=[\"itil\"],\n ) -> None:\n catalog_item_list = list(META_CONFIGS.keys())\n catalog_item_list.remove(self.min_catalog_item)\n random_service_catalog_items = self.random.choice(\n catalog_item_list, self.random.randint(self.min_items, self.max_items), replace=False\n ).tolist()\n cat_item_sys_name = {\n \"Developer Laptop (Mac)\": \"Developer Laptop (Mac)\",\n \"iPad mini\": \"iPad mini\",\n \"iPad pro\": \"iPad pro\",\n \"Sales Laptop\": \"Sales Laptop\",\n \"Standard Laptop\": \"Standard Laptop\",\n \"Apple Watch\": \"Apple Watch\",\n \"Apple MacBook Pro 15\": 'Apple MacBook Pro 15\"',\n \"Development Laptop (PC)\": \"Development Laptop (PC)\",\n \"Loaner Laptop\": \"Notebook Computer Loaner\",","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.get_order_quantity_value","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.get_order_quantity_value#L1245-L1281","kind":"function","name":"get_order_quantity_value","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1245,"end_line":1281,"context_start_line":1225,"context_end_line":1301,"code":" instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n \"sysparm_fields\": \"first_name,last_name\",\n },\n method=\"GET\",\n )[\"result\"][0]\n user_full_name = user_details[\"first_name\"] + \" \" + user_details[\"last_name\"]\n\n self.report_sys_id, _ = create_report(\n instance=self.instance,\n table=\"sc_req_item\",\n filter_hashtag=user_full_name,\n filter_field=\"requested_for\",\n field=\"cat_item\",\n plot_title=self.chart_title,\n random=self.random,\n )\n\n def get_order_quantity_value(self) -> list[str]:\n quantities = [\n service_catalog_report_config_attribute[\"quantity\"]\n for service_catalog_report_config_attribute in self.service_catalog_report_config.values()\n ]\n if self.question == \"max\":\n if max(quantities) != self.max_number_per_item:\n raise Exception(\"Maximum of quantities does not match attribute. Please check.\")\n target_quantity = self.max_number_per_item\n elif self.question == \"mean\":\n mean_quantity = np.mean(quantities)\n target_quantity = int(np.ceil(mean_quantity))\n elif self.question == \"median\":\n target_quantity = int(np.ceil(np.median(quantities)))\n elif self.question == \"mode\":\n frequencies = {}\n for count in quantities:\n if count not in frequencies:\n frequencies[count] = 1\n else:\n frequencies[count] += 1\n sorted_frequencies = {\n count: frequency\n for count, frequency in sorted(\n frequencies.items(), key=lambda item: item[1], reverse=True\n )\n }\n max_frequency = list(sorted_frequencies.values())[0]\n max_frequencies = [\n count\n for count, frequency in sorted_frequencies.items()\n if frequency == max_frequency\n ]\n target_quantity = int(max(max_frequencies))\n if target_quantity - self.min_number_per_item <= 0:\n raise Exception(\"Unable to order quantity {target_quantity - self.min_number_per_item}\")\n return int(target_quantity - self.min_number_per_item)\n\n def set_compositional_task(self) -> None:\n\n config = self.random.choice(self.all_configs)\n self.configuration = config[\"configuration\"]\n order_config = {\n \"configuration\": self.configuration,\n \"description\": META_CONFIGS[self.min_catalog_item][\"desc\"],\n \"item\": self.min_catalog_item,\n \"quantity\": self.get_order_quantity_value(),\n }\n order_config, self.infeasible_reasons = self.function(\n config=order_config, random=self.random\n )\n\n create_order_item_subtask = [\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.setup_goal#L1319-L1344","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1319,"end_line":1344,"context_start_line":1299,"context_end_line":1364,"code":" instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n \"url\": \"/now/nav/ui/classic/params/target/catalog_home.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n self.order_item_class(\n instance=self.instance,\n fixed_config=order_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n self.compositional_task = create_order_item_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the catalog items.\\n\"\n + f\"Task: Place an order for requesting more of the least available item in the report. The quantity of the order should be such that the final quantity of this item matches the above retrieved value.\\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the catalog report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the value which is the {self.description_mapping[self.question]} of the catalog items present in stock shown in the report. \\n\"\n + f\"\\n3. Navigate to Self-Service > Service Catalog. \\n\"\n + f\"\\n4. For the least available item in stock, place an order for extra items such that its quantity matches the value you found.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete the report\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_report\",\n sys_id=self.report_sys_id,\n )\n # Delete the request items\n for created_request_item in self.created_request_items:\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_request_item[1],\n )\n return super().teardown()\n\n\nclass DashDoFinalTask:\n \"\"\"Base class for dash do final tasks block tasks. Used to include these tasks across multiple superclasses.\"\"\"","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_base.all_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_base.all_configs#L1126-L1128","kind":"function","name":"all_configs","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1126,"end_line":1128,"context_start_line":1106,"context_end_line":1148,"code":" dashboard_class=dashboard_class,\n )\n self.question = question\n self.max_number_per_item = self.random.choice([5, 6, 7])\n self.min_number_per_item = self.random.choice([1, 2])\n self.max_items = max_items\n self.min_items = min_items\n if self.max_items < 2 or self.min_items < 2:\n raise Exception(\"The items allowed should at least be 2.\")\n self.task_description = f\"Retrieve the information mentioned in the following description from the report of the catalogs with the title {self.catalog_hashtag}. Using the information, follow the subsequent task steps mentioned. For all calculations, round of to the next highest integer first. For multiple modes, choose the highest value.\\n\"\n if self.level == 3:\n self.task_description += f\"Follow the '{self.protocol_name}' protocol from the knowledge base for extra instructions.\\n\"\n self.short_description = \"Retrieve catalog information and perform the mentioned task\"\n self.min_catalog_item = min_catalog_item\n self.function = partial(\n get_infeasible_service_catalog_config, provide_reason=provide_reason\n )\n self.all_configs = self.all_configs()\n\n @classmethod\n def all_configs(cls) -> List[dict]:\n with open(cls.config_path, \"r\") as f:\n return json.load(f)\n\n def get_catalog_item_sysid(self, catalog_item: str) -> str:\n catalog_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\"sysparm_query\": f\"sys_name={catalog_item}\", \"sysparm_fields\": \"sys_id\"},\n method=\"GET\",\n )[\"result\"]\n if len(catalog_item_response) == 0:\n raise Exception(\"Catalog item not found.\")\n elif len(catalog_item_response) > 1:\n raise Exception(\"Multiple catalog items found.\")\n return catalog_item_response[0][\"sys_id\"]\n\n def create_report(\n self,\n user_roles=[\"itil\"],\n ) -> None:\n catalog_item_list = list(META_CONFIGS.keys())\n catalog_item_list.remove(self.min_catalog_item)","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.warranty_check","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.warranty_check#L1-L227","kind":"module","name":"src.browsergym.workarena.tasks.compositional.warranty_check","path":"src/browsergym/workarena/tasks/compositional/warranty_check.py","language":"python","start_line":1,"end_line":227,"context_start_line":1,"context_end_line":227,"code":"import json\nimport time\nfrom faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import ExtractListInfoTask, FilterHardwareListTask\nfrom ..navigation import AllMenuTask\n\nfrom ...api.computer_asset import create_computer_asset\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...instance import SNowInstance\n\n\nclass GetWarrantyExpirationDateTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol '[company_protocol]', onboard user with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Find the warranty expiration date for John Doe's laptop\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Finding the warranty expiration for a user's laptop\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n self.task_description = None\n self.short_description = None\n self.user_sys_id = None\n self.user_name = None\n self.user_full_name = None\n self.laptop_sys_id = None\n self.warranty_expiration_date = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create a user and a laptop for the user\n self._create_user_and_laptop()\n\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n # Get the task description\n self.short_description = (\n f\"Find the warranty expiration date for {self.user_full_name}'s laptop\"\n )\n self.task_description = f'Refer to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) for the steps to find the Warranty expiration date for {self.user_full_name}\\'s laptop.\\n \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n navigate_to_hardware_asset_and_filter = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the hardware asset list\n FilterHardwareListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [f\"{self.user_full_name}\"],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n extract_warranty_subtask = [\n ExtractListInfoTask(\n instance=self.instance,\n unique_field_name=\"assigned_to\",\n fixed_config={\n \"start_rel_url\": \"\",\n \"fields\": {\n \"assigned_to\": \"Assigned to\",\n \"warranty_expiration\": \"Warranty expiration\",\n },\n \"expected_values\": [\n {\n \"assigned_to\": f\"{self.user_full_name}\",\n \"warranty_expiration\": f\"{self.warranty_expiration_date}\",\n }\n ],\n },\n list_name=\"Hardware Assets\",\n list_url=\"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n table_name=\"alm_hardware\",\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + navigate_to_hardware_asset_and_filter\n + extract_warranty_subtask\n )\n\n return config\n\n def _create_user_and_laptop(self) -> None:\n \"\"\"\n Creates a user and a laptop for the user. The laptop model is randomly selected from the available computer models.\n Sets the user_sys_id, laptop_sys_id, user_name and warranty_expiration_date attributes.\n \"\"\"\n # Generate random name for the user\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n self.user_full_name = first_name + \" \" + last_name\n # Create user\n self.user_name, _, self.user_sys_id = create_user(\n instance=self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n self.warranty_expiration_date = str(fake.date_between(start_date=\"-1y\", end_date=\"+1y\"))\n asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n (\n computer_sys_id,\n _,\n _,\n ) = create_computer_asset(\n instance=self.instance,\n asset_tag=asset_tag,\n warranty_expiration_date=self.warranty_expiration_date,\n user_sys_id=self.user_sys_id,\n random=self.random,\n )\n\n assert computer_sys_id, f\"Failed to create hardware asset {asset_tag}\"\n self.laptop_sys_id = computer_sys_id\n\n def teardown(self) -> None:\n # Delete the user and the laptop\n user_record_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.user_sys_id}\"},\n )\n laptop_record_exists = table_api_call(\n instance=self.instance,\n table=\"alm_hardware\",\n params={\"sysparm_query\": f\"sys_id={self.laptop_sys_id}\"},\n )\n if user_record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.user_sys_id,\n )\n if laptop_record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_hardware\",\n sys_id=self.laptop_sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [GetWarrantyExpirationDateTask]","source_hash":"d044e5d7aeb33ea3993ef8b8a3553d9ef2c649bf6b7f6cd0268596b8ced95299","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.warranty_check.GetWarrantyExpirationDateTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.warranty_check.GetWarrantyExpirationDateTask#L22-L224","kind":"class","name":"GetWarrantyExpirationDateTask","path":"src/browsergym/workarena/tasks/compositional/warranty_check.py","language":"python","start_line":22,"end_line":224,"context_start_line":2,"context_end_line":227,"code":"import time\nfrom faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import ExtractListInfoTask, FilterHardwareListTask\nfrom ..navigation import AllMenuTask\n\nfrom ...api.computer_asset import create_computer_asset\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...instance import SNowInstance\n\n\nclass GetWarrantyExpirationDateTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol '[company_protocol]', onboard user with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Find the warranty expiration date for John Doe's laptop\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Finding the warranty expiration for a user's laptop\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n self.task_description = None\n self.short_description = None\n self.user_sys_id = None\n self.user_name = None\n self.user_full_name = None\n self.laptop_sys_id = None\n self.warranty_expiration_date = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create a user and a laptop for the user\n self._create_user_and_laptop()\n\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n # Get the task description\n self.short_description = (\n f\"Find the warranty expiration date for {self.user_full_name}'s laptop\"\n )\n self.task_description = f'Refer to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) for the steps to find the Warranty expiration date for {self.user_full_name}\\'s laptop.\\n \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n navigate_to_hardware_asset_and_filter = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the hardware asset list\n FilterHardwareListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [f\"{self.user_full_name}\"],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n extract_warranty_subtask = [\n ExtractListInfoTask(\n instance=self.instance,\n unique_field_name=\"assigned_to\",\n fixed_config={\n \"start_rel_url\": \"\",\n \"fields\": {\n \"assigned_to\": \"Assigned to\",\n \"warranty_expiration\": \"Warranty expiration\",\n },\n \"expected_values\": [\n {\n \"assigned_to\": f\"{self.user_full_name}\",\n \"warranty_expiration\": f\"{self.warranty_expiration_date}\",\n }\n ],\n },\n list_name=\"Hardware Assets\",\n list_url=\"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n table_name=\"alm_hardware\",\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + navigate_to_hardware_asset_and_filter\n + extract_warranty_subtask\n )\n\n return config\n\n def _create_user_and_laptop(self) -> None:\n \"\"\"\n Creates a user and a laptop for the user. The laptop model is randomly selected from the available computer models.\n Sets the user_sys_id, laptop_sys_id, user_name and warranty_expiration_date attributes.\n \"\"\"\n # Generate random name for the user\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n self.user_full_name = first_name + \" \" + last_name\n # Create user\n self.user_name, _, self.user_sys_id = create_user(\n instance=self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n self.warranty_expiration_date = str(fake.date_between(start_date=\"-1y\", end_date=\"+1y\"))\n asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n (\n computer_sys_id,\n _,\n _,\n ) = create_computer_asset(\n instance=self.instance,\n asset_tag=asset_tag,\n warranty_expiration_date=self.warranty_expiration_date,\n user_sys_id=self.user_sys_id,\n random=self.random,\n )\n\n assert computer_sys_id, f\"Failed to create hardware asset {asset_tag}\"\n self.laptop_sys_id = computer_sys_id\n\n def teardown(self) -> None:\n # Delete the user and the laptop\n user_record_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.user_sys_id}\"},\n )\n laptop_record_exists = table_api_call(\n instance=self.instance,\n table=\"alm_hardware\",\n params={\"sysparm_query\": f\"sys_id={self.laptop_sys_id}\"},\n )\n if user_record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.user_sys_id,\n )\n if laptop_record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_hardware\",\n sys_id=self.laptop_sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [GetWarrantyExpirationDateTask]","source_hash":"d044e5d7aeb33ea3993ef8b8a3553d9ef2c649bf6b7f6cd0268596b8ced95299","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.warranty_check.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.warranty_check.__init__#L23-L66","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/warranty_check.py","language":"python","start_line":23,"end_line":66,"context_start_line":3,"context_end_line":86,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import ExtractListInfoTask, FilterHardwareListTask\nfrom ..navigation import AllMenuTask\n\nfrom ...api.computer_asset import create_computer_asset\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...instance import SNowInstance\n\n\nclass GetWarrantyExpirationDateTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol '[company_protocol]', onboard user with the following information: \\n\"\n short_description: str\n A short description of the task to be completed. e.g. \"Find the warranty expiration date for John Doe's laptop\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Finding the warranty expiration for a user's laptop\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n self.task_description = None\n self.short_description = None\n self.user_sys_id = None\n self.user_name = None\n self.user_full_name = None\n self.laptop_sys_id = None\n self.warranty_expiration_date = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create a user and a laptop for the user\n self._create_user_and_laptop()\n\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n # Get the task description\n self.short_description = (\n f\"Find the warranty expiration date for {self.user_full_name}'s laptop\"\n )\n self.task_description = f'Refer to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) for the steps to find the Warranty expiration date for {self.user_full_name}\\'s laptop.\\n \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n navigate_to_protocol_subtask = [","source_hash":"d044e5d7aeb33ea3993ef8b8a3553d9ef2c649bf6b7f6cd0268596b8ced95299","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.warranty_check.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.warranty_check.setup_goal#L68-L83","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/warranty_check.py","language":"python","start_line":68,"end_line":83,"context_start_line":48,"context_end_line":103,"code":" A short description of the task to be completed. e.g. \"Find the warranty expiration date for John Doe's laptop\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Finding the warranty expiration for a user's laptop\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n self.task_description = None\n self.short_description = None\n self.user_sys_id = None\n self.user_name = None\n self.user_full_name = None\n self.laptop_sys_id = None\n self.warranty_expiration_date = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create a user and a laptop for the user\n self._create_user_and_laptop()\n\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n # Get the task description\n self.short_description = (\n f\"Find the warranty expiration date for {self.user_full_name}'s laptop\"\n )\n self.task_description = f'Refer to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) for the steps to find the Warranty expiration date for {self.user_full_name}\\'s laptop.\\n \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",","source_hash":"d044e5d7aeb33ea3993ef8b8a3553d9ef2c649bf6b7f6cd0268596b8ced95299","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.warranty_check._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.warranty_check._get_config#L85-L166","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/warranty_check.py","language":"python","start_line":85,"end_line":166,"context_start_line":65,"context_end_line":186,"code":" self.laptop_sys_id = None\n self.warranty_expiration_date = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create a user and a laptop for the user\n self._create_user_and_laptop()\n\n # Sample a configuration\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n # Get the task description\n self.short_description = (\n f\"Find the warranty expiration date for {self.user_full_name}'s laptop\"\n )\n self.task_description = f'Refer to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) for the steps to find the Warranty expiration date for {self.user_full_name}\\'s laptop.\\n \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n navigate_to_hardware_asset_and_filter = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the hardware asset list\n FilterHardwareListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [f\"{self.user_full_name}\"],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n extract_warranty_subtask = [\n ExtractListInfoTask(\n instance=self.instance,\n unique_field_name=\"assigned_to\",\n fixed_config={\n \"start_rel_url\": \"\",\n \"fields\": {\n \"assigned_to\": \"Assigned to\",\n \"warranty_expiration\": \"Warranty expiration\",\n },\n \"expected_values\": [\n {\n \"assigned_to\": f\"{self.user_full_name}\",\n \"warranty_expiration\": f\"{self.warranty_expiration_date}\",\n }\n ],\n },\n list_name=\"Hardware Assets\",\n list_url=\"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n table_name=\"alm_hardware\",\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + navigate_to_hardware_asset_and_filter\n + extract_warranty_subtask\n )\n\n return config\n\n def _create_user_and_laptop(self) -> None:\n \"\"\"\n Creates a user and a laptop for the user. The laptop model is randomly selected from the available computer models.\n Sets the user_sys_id, laptop_sys_id, user_name and warranty_expiration_date attributes.\n \"\"\"\n # Generate random name for the user\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n self.user_full_name = first_name + \" \" + last_name\n # Create user\n self.user_name, _, self.user_sys_id = create_user(\n instance=self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n self.warranty_expiration_date = str(fake.date_between(start_date=\"-1y\", end_date=\"+1y\"))\n asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n (\n computer_sys_id,","source_hash":"d044e5d7aeb33ea3993ef8b8a3553d9ef2c649bf6b7f6cd0268596b8ced95299","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.warranty_check._create_user_and_laptop","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.warranty_check._create_user_and_laptop#L168-L198","kind":"function","name":"_create_user_and_laptop","path":"src/browsergym/workarena/tasks/compositional/warranty_check.py","language":"python","start_line":168,"end_line":198,"context_start_line":148,"context_end_line":218,"code":" \"warranty_expiration\": f\"{self.warranty_expiration_date}\",\n }\n ],\n },\n list_name=\"Hardware Assets\",\n list_url=\"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n table_name=\"alm_hardware\",\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + navigate_to_hardware_asset_and_filter\n + extract_warranty_subtask\n )\n\n return config\n\n def _create_user_and_laptop(self) -> None:\n \"\"\"\n Creates a user and a laptop for the user. The laptop model is randomly selected from the available computer models.\n Sets the user_sys_id, laptop_sys_id, user_name and warranty_expiration_date attributes.\n \"\"\"\n # Generate random name for the user\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n self.user_full_name = first_name + \" \" + last_name\n # Create user\n self.user_name, _, self.user_sys_id = create_user(\n instance=self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n self.warranty_expiration_date = str(fake.date_between(start_date=\"-1y\", end_date=\"+1y\"))\n asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n (\n computer_sys_id,\n _,\n _,\n ) = create_computer_asset(\n instance=self.instance,\n asset_tag=asset_tag,\n warranty_expiration_date=self.warranty_expiration_date,\n user_sys_id=self.user_sys_id,\n random=self.random,\n )\n\n assert computer_sys_id, f\"Failed to create hardware asset {asset_tag}\"\n self.laptop_sys_id = computer_sys_id\n\n def teardown(self) -> None:\n # Delete the user and the laptop\n user_record_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.user_sys_id}\"},\n )\n laptop_record_exists = table_api_call(\n instance=self.instance,\n table=\"alm_hardware\",\n params={\"sysparm_query\": f\"sys_id={self.laptop_sys_id}\"},\n )\n if user_record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.user_sys_id,\n )\n if laptop_record_exists:","source_hash":"d044e5d7aeb33ea3993ef8b8a3553d9ef2c649bf6b7f6cd0268596b8ced95299","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.warranty_check.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.warranty_check.teardown#L200-L224","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/warranty_check.py","language":"python","start_line":200,"end_line":224,"context_start_line":180,"context_end_line":227,"code":" )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n self.warranty_expiration_date = str(fake.date_between(start_date=\"-1y\", end_date=\"+1y\"))\n asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n (\n computer_sys_id,\n _,\n _,\n ) = create_computer_asset(\n instance=self.instance,\n asset_tag=asset_tag,\n warranty_expiration_date=self.warranty_expiration_date,\n user_sys_id=self.user_sys_id,\n random=self.random,\n )\n\n assert computer_sys_id, f\"Failed to create hardware asset {asset_tag}\"\n self.laptop_sys_id = computer_sys_id\n\n def teardown(self) -> None:\n # Delete the user and the laptop\n user_record_exists = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.user_sys_id}\"},\n )\n laptop_record_exists = table_api_call(\n instance=self.instance,\n table=\"alm_hardware\",\n params={\"sysparm_query\": f\"sys_id={self.laptop_sys_id}\"},\n )\n if user_record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.user_sys_id,\n )\n if laptop_record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_hardware\",\n sys_id=self.laptop_sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [GetWarrantyExpirationDateTask]","source_hash":"d044e5d7aeb33ea3993ef8b8a3553d9ef2c649bf6b7f6cd0268596b8ced95299","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.offboard_user","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.offboard_user#L1-L207","kind":"module","name":"src.browsergym.workarena.tasks.compositional.offboard_user","path":"src/browsergym/workarena/tasks/compositional/offboard_user.py","language":"python","start_line":1,"end_line":207,"context_start_line":1,"context_end_line":207,"code":"import json\n\nfrom faker import Faker\n\nfake = Faker()\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\nfrom .delete_record import DeleteUserTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..form import EditHardwareAssetTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import FilterHardwareListTask\nfrom ..navigation import AllMenuTask\n\nfrom ...api.computer_asset import create_computer_asset\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\n\nclass OffBoardUserTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Employee OffBoarding Task\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Offboarding a user', offboard user XYZ\"\n short_description: str\n A short description of the task to be completed. e.g. \"Offboard user John Doe\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Offboarding a user\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n self.task_description = None\n self.short_description = None\n self.user_full_name = None\n self.user_sys_id = None\n self.user_name = None\n self.laptop_asset_tag = None\n self.laptop_sys_id = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Generate random name for the user\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n self.user_full_name = first_name + \" \" + last_name\n self.laptop_asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n\n # Create user\n self.user_name, _, self.user_sys_id = create_user(\n instance=self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n\n self.laptop_sys_id, _, _ = create_computer_asset(\n instance=self.instance,\n asset_tag=self.laptop_asset_tag,\n user_sys_id=self.user_sys_id,\n random=self.random,\n )\n\n config = self.fixed_config if self.fixed_config else self._get_config()\n # Get the task description\n self.short_description = f\"Offboard user {self.user_full_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) offboard user \"{self.user_full_name}\" \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\"Sample a user configuration and a hardware asset configuration. Add the assigned_to field if missing\n from the hardware asset configuration. Finally, return the list of subtasks, with navigation subtasks included.\n \"\"\"\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n unassign_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n FilterHardwareListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [f\"{self.user_full_name}\"],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new hardware asset\n EditHardwareAssetTask(\n instance=self.instance,\n record_sys_id=self.laptop_sys_id,\n new_values={\"assigned_to\": \"\"},\n is_validated=True,\n used_in_level_2=True,\n level=self.level,\n ),\n ]\n delete_user_subtask = [\n # Navigate to the user list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"System Security\",\n \"module\": \"Users and Groups > Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new user\n DeleteUserTask(\n instance=self.instance,\n fixed_config={\n \"field_name\": \"name\",\n \"pretty_printed_field_name\": \"Name\",\n \"field_value\": self.user_full_name,\n \"other_fields\": {},\n },\n record_sys_id=self.user_sys_id,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = navigate_to_protocol_subtask + unassign_hardware_subtask + delete_user_subtask\n\n return config\n\n def teardown(self) -> None:\n # Delete the user\n user_record = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.user_sys_id}\"},\n )[\"result\"]\n if user_record:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.user_sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [OffBoardUserTask]","source_hash":"87909b53265ff49c92db26bd07d448ff07d2880b8498fe0b705982ea187e7f07","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.offboard_user.OffBoardUserTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.offboard_user.OffBoardUserTask#L23-L204","kind":"class","name":"OffBoardUserTask","path":"src/browsergym/workarena/tasks/compositional/offboard_user.py","language":"python","start_line":23,"end_line":204,"context_start_line":3,"context_end_line":207,"code":"from faker import Faker\n\nfake = Faker()\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\nfrom .delete_record import DeleteUserTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..form import EditHardwareAssetTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import FilterHardwareListTask\nfrom ..navigation import AllMenuTask\n\nfrom ...api.computer_asset import create_computer_asset\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\n\nclass OffBoardUserTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Employee OffBoarding Task\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Offboarding a user', offboard user XYZ\"\n short_description: str\n A short description of the task to be completed. e.g. \"Offboard user John Doe\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Offboarding a user\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n self.task_description = None\n self.short_description = None\n self.user_full_name = None\n self.user_sys_id = None\n self.user_name = None\n self.laptop_asset_tag = None\n self.laptop_sys_id = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Generate random name for the user\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n self.user_full_name = first_name + \" \" + last_name\n self.laptop_asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n\n # Create user\n self.user_name, _, self.user_sys_id = create_user(\n instance=self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n\n self.laptop_sys_id, _, _ = create_computer_asset(\n instance=self.instance,\n asset_tag=self.laptop_asset_tag,\n user_sys_id=self.user_sys_id,\n random=self.random,\n )\n\n config = self.fixed_config if self.fixed_config else self._get_config()\n # Get the task description\n self.short_description = f\"Offboard user {self.user_full_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) offboard user \"{self.user_full_name}\" \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\"Sample a user configuration and a hardware asset configuration. Add the assigned_to field if missing\n from the hardware asset configuration. Finally, return the list of subtasks, with navigation subtasks included.\n \"\"\"\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n unassign_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n FilterHardwareListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [f\"{self.user_full_name}\"],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new hardware asset\n EditHardwareAssetTask(\n instance=self.instance,\n record_sys_id=self.laptop_sys_id,\n new_values={\"assigned_to\": \"\"},\n is_validated=True,\n used_in_level_2=True,\n level=self.level,\n ),\n ]\n delete_user_subtask = [\n # Navigate to the user list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"System Security\",\n \"module\": \"Users and Groups > Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new user\n DeleteUserTask(\n instance=self.instance,\n fixed_config={\n \"field_name\": \"name\",\n \"pretty_printed_field_name\": \"Name\",\n \"field_value\": self.user_full_name,\n \"other_fields\": {},\n },\n record_sys_id=self.user_sys_id,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = navigate_to_protocol_subtask + unassign_hardware_subtask + delete_user_subtask\n\n return config\n\n def teardown(self) -> None:\n # Delete the user\n user_record = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.user_sys_id}\"},\n )[\"result\"]\n if user_record:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.user_sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [OffBoardUserTask]","source_hash":"87909b53265ff49c92db26bd07d448ff07d2880b8498fe0b705982ea187e7f07","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.offboard_user.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.offboard_user.__init__#L24-L67","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/offboard_user.py","language":"python","start_line":24,"end_line":67,"context_start_line":4,"context_end_line":87,"code":"\nfake = Faker()\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\nfrom .delete_record import DeleteUserTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..form import EditHardwareAssetTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import FilterHardwareListTask\nfrom ..navigation import AllMenuTask\n\nfrom ...api.computer_asset import create_computer_asset\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\n\nclass OffBoardUserTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Employee OffBoarding Task\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of subtasks.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Offboarding a user', offboard user XYZ\"\n short_description: str\n A short description of the task to be completed. e.g. \"Offboard user John Doe\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Offboarding a user\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n self.task_description = None\n self.short_description = None\n self.user_full_name = None\n self.user_sys_id = None\n self.user_name = None\n self.laptop_asset_tag = None\n self.laptop_sys_id = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Generate random name for the user\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n self.user_full_name = first_name + \" \" + last_name\n self.laptop_asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n\n # Create user\n self.user_name, _, self.user_sys_id = create_user(\n instance=self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n\n self.laptop_sys_id, _, _ = create_computer_asset(\n instance=self.instance,\n asset_tag=self.laptop_asset_tag,\n user_sys_id=self.user_sys_id,\n random=self.random,","source_hash":"87909b53265ff49c92db26bd07d448ff07d2880b8498fe0b705982ea187e7f07","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.offboard_user.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.offboard_user.setup_goal#L69-L97","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/offboard_user.py","language":"python","start_line":69,"end_line":97,"context_start_line":49,"context_end_line":117,"code":" A short description of the task to be completed. e.g. \"Offboard user John Doe\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Offboarding a user\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n )\n self.task_description = None\n self.short_description = None\n self.user_full_name = None\n self.user_sys_id = None\n self.user_name = None\n self.laptop_asset_tag = None\n self.laptop_sys_id = None\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Generate random name for the user\n first_name = fake.first_name() + \"-\" + fake.first_name()\n last_name = fake.last_name() + \"-\" + fake.last_name()\n self.user_full_name = first_name + \" \" + last_name\n self.laptop_asset_tag = \"P\" + str(id(self) % (10**8)).zfill(8)\n\n # Create user\n self.user_name, _, self.user_sys_id = create_user(\n instance=self.instance, first_name=first_name, last_name=last_name, random=self.random\n )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n\n self.laptop_sys_id, _, _ = create_computer_asset(\n instance=self.instance,\n asset_tag=self.laptop_asset_tag,\n user_sys_id=self.user_sys_id,\n random=self.random,\n )\n\n config = self.fixed_config if self.fixed_config else self._get_config()\n # Get the task description\n self.short_description = f\"Offboard user {self.user_full_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) offboard user \"{self.user_full_name}\" \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\"Sample a user configuration and a hardware asset configuration. Add the assigned_to field if missing\n from the hardware asset configuration. Finally, return the list of subtasks, with navigation subtasks included.\n \"\"\"\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,","source_hash":"87909b53265ff49c92db26bd07d448ff07d2880b8498fe0b705982ea187e7f07","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.offboard_user._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.offboard_user._get_config#L99-L189","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/offboard_user.py","language":"python","start_line":99,"end_line":189,"context_start_line":79,"context_end_line":207,"code":" )\n\n assert self.user_sys_id, f\"Failed to create user {first_name} {last_name}\"\n\n self.laptop_sys_id, _, _ = create_computer_asset(\n instance=self.instance,\n asset_tag=self.laptop_asset_tag,\n user_sys_id=self.user_sys_id,\n random=self.random,\n )\n\n config = self.fixed_config if self.fixed_config else self._get_config()\n # Get the task description\n self.short_description = f\"Offboard user {self.user_full_name}\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) offboard user \"{self.user_full_name}\" \\n'\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n \"\"\"Sample a user configuration and a hardware asset configuration. Add the assigned_to field if missing\n from the hardware asset configuration. Finally, return the list of subtasks, with navigation subtasks included.\n \"\"\"\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n unassign_hardware_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n FilterHardwareListTask(\n instance=self.instance,\n fixed_config={\n \"filter_columns\": [\"assigned_to\"],\n \"filter_kind\": \"AND\",\n \"filter_values\": [f\"{self.user_full_name}\"],\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new hardware asset\n EditHardwareAssetTask(\n instance=self.instance,\n record_sys_id=self.laptop_sys_id,\n new_values={\"assigned_to\": \"\"},\n is_validated=True,\n used_in_level_2=True,\n level=self.level,\n ),\n ]\n delete_user_subtask = [\n # Navigate to the user list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"System Security\",\n \"module\": \"Users and Groups > Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a new user\n DeleteUserTask(\n instance=self.instance,\n fixed_config={\n \"field_name\": \"name\",\n \"pretty_printed_field_name\": \"Name\",\n \"field_value\": self.user_full_name,\n \"other_fields\": {},\n },\n record_sys_id=self.user_sys_id,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = navigate_to_protocol_subtask + unassign_hardware_subtask + delete_user_subtask\n\n return config\n\n def teardown(self) -> None:\n # Delete the user\n user_record = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.user_sys_id}\"},\n )[\"result\"]\n if user_record:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.user_sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [OffBoardUserTask]","source_hash":"87909b53265ff49c92db26bd07d448ff07d2880b8498fe0b705982ea187e7f07","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.offboard_user.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.offboard_user.teardown#L191-L204","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/offboard_user.py","language":"python","start_line":191,"end_line":204,"context_start_line":171,"context_end_line":207,"code":" ),\n # Create a new user\n DeleteUserTask(\n instance=self.instance,\n fixed_config={\n \"field_name\": \"name\",\n \"pretty_printed_field_name\": \"Name\",\n \"field_value\": self.user_full_name,\n \"other_fields\": {},\n },\n record_sys_id=self.user_sys_id,\n is_validated=True,\n used_in_level_2=True,\n ),\n ]\n\n config = navigate_to_protocol_subtask + unassign_hardware_subtask + delete_user_subtask\n\n return config\n\n def teardown(self) -> None:\n # Delete the user\n user_record = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\"sysparm_query\": f\"sys_id={self.user_sys_id}\"},\n )[\"result\"]\n if user_record:\n db_delete_from_table(\n instance=self.instance,\n table=\"sys_user\",\n sys_id=self.user_sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [OffBoardUserTask]","source_hash":"87909b53265ff49c92db26bd07d448ff07d2880b8498fe0b705982ea187e7f07","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.edit_knowledge_base#L1-L457","kind":"module","name":"src.browsergym.workarena.tasks.compositional.edit_knowledge_base","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":1,"end_line":457,"context_start_line":1,"context_end_line":457,"code":"import html\nimport json\nimport random\n\nfrom faker import Faker\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfake = Faker()\n\nfrom ...api.knowledge import give_kb_read_permissions\nfrom ...api.utils import table_api_call\nfrom ..base import AbstractServiceNowTask\nfrom .base import CompositionalTask\nfrom ...config import KB_FILEPATH, PROTOCOL_KB_NAME\nfrom ...instance import SNowInstance\nfrom ..knowledge import KnowledgeBaseSearchTask, AddCommentToKnowledgeArticleTask\nfrom ..navigation import AllMenuTask\n\n\nclass EditKnowledgeBaseTask(CompositionalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask, its configuration and whether or not it should be validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Edit a knowledge article', edit the knowledge base to handle the incorrect information: \\n'\n short_description: str\n A short description of the task to be completed. e.g. \"Edit knowledge base entries for address of parking lot.\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Edit a knowledge article to manage incorrect information\"\n\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n user_roles=[\"itil\"], # Required permission to access service desk for l3\n )\n with open(KB_FILEPATH, \"r\") as f:\n self.kb_entries = json.load(f)\n if not hasattr(self, \"_base_initial_instance\"):\n self._base_initial_instance = self.instance\n self.adhoc_kb_name = None\n self.task_description = None\n self.short_description = None\n\n def create_adhoc_kb(self):\n user_full_name = \" \".join(self._base_user_name.split(\".\")[:-1])\n adhoc_kb_name = f\"{user_full_name}'s Knowledge Base\"\n self.adhoc_kb_name = adhoc_kb_name\n\n kb = table_api_call(\n instance=self._base_initial_instance,\n table=\"kb_knowledge_base\",\n method=\"POST\",\n data=json.dumps(\n {\n \"title\": self.adhoc_kb_name,\n }\n ),\n )[\"result\"]\n\n return kb[\"sys_id\"]\n\n def get_random_article_name(self):\n kb = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"kb_knowledge_base={self.adhoc_kb_sys_id}\",\n \"sysparm_fields\": \"short_description\",\n },\n )[\"result\"]\n self.article_titles = [kb_article[\"short_description\"] for kb_article in kb]\n\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n base_article_name = self.base_config[\"item\"].capitalize()\n article_title = f\"{base_article_name}-{article_date}\"\n while article_title in self.article_titles:\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n article_title = f\"{base_article_name}-{article_date}\"\n\n return article_title\n\n def create_article(self, article_name, article_text):\n if article_name in self.article_titles:\n raise Exception(\"Article with the name already exists...\")\n\n adhoc_kb_response = table_api_call(\n instance=self._base_initial_instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"POST\",\n data=json.dumps(\n {\n \"short_description\": article_name,\n \"sys_class_name\": \"kb_knowledge\",\n \"text\": article_text,\n \"article_type\": \"text\",\n \"kb_knowledge_base\": self.adhoc_kb_sys_id,\n }\n ),\n )[\"result\"]\n\n return adhoc_kb_response\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create the KB\n self.adhoc_kb_sys_id = self.create_adhoc_kb()\n # Sample a configuration\n self.base_config = self.random.choice(self.kb_entries)\n self.incorrect_kb_article_name = self.get_random_article_name()\n self.correct_kb_article_name = self.get_random_article_name()\n self.item = self.base_config[\"item\"]\n self.correct_answer = self.base_config[\"value\"]\n\n self.incorrect_answer = \" \".join(\n [fake.word() for _ in range(len(self.correct_answer.split()))]\n ) # Random incorrect answer with the same number of words as the correct answer\n\n incorrect_kb_article = self.create_article(\n self.incorrect_kb_article_name,\n self.base_config[\"article\"].replace(self.correct_answer, self.incorrect_answer),\n )\n self.incorrect_kb_article_sys_id = incorrect_kb_article[\"sys_id\"]\n self.incorrect_kb_article_number = incorrect_kb_article[\"number\"]\n\n correct_kb_article = self.create_article(\n self.correct_kb_article_name, self.base_config[\"article\"]\n )\n self.correct_kb_article_sys_id = correct_kb_article[\"sys_id\"]\n self.correct_kb_article_number = correct_kb_article[\"number\"]\n\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n give_kb_read_permissions(\n self._base_initial_instance,\n self._base_user_sysid,\n self._base_user_name,\n self.adhoc_kb_sys_id,\n self.adhoc_kb_name,\n )\n\n if self.level == 3:\n protocol_kb_sys_id = table_api_call(\n instance=self._base_initial_instance,\n table=\"kb_knowledge_base\",\n params={\"sysparm_query\": f\"title={PROTOCOL_KB_NAME}\"},\n )[\"result\"][0][\"sys_id\"]\n give_kb_read_permissions(\n self._base_initial_instance,\n self._base_user_sysid,\n self._base_user_name,\n protocol_kb_sys_id,\n PROTOCOL_KB_NAME,\n )\n\n # Get the task description\n self.short_description = f\"Edit knowledge base article for {self.item}\"\n self.task_description = (\n f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) edit the knowledge base to handle incorrect information. \\n'\n + f'Searching for \"{self.item}\" in the knowledge base gives different articles as the output: \"{self.incorrect_kb_article_name}\" with number \"{self.incorrect_kb_article_number}\" and \"{self.correct_kb_article_name}\" with number \"{self.correct_kb_article_number}\". \\n'\n # + f'One of the articles has incorrect information \"{self.incorrect_answer}\" and the other one has the correct answer \"{self.correct_answer}\". \\n'\n + f'The correct information for \"{self.item}\" should be {self.correct_answer}. '\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n \"\"\"Add more extensive definition here.\"\"\"\n\n self.incorrect_config = {\n \"item\": self.item,\n \"kb_article_title\": self.incorrect_kb_article_name,\n \"value\": self.incorrect_answer,\n \"question\": self.base_config[\"questions\"][0],\n # \"replaced_text\": self.incorrect_answer,\n \"comment\": f\"This article has incorrect information and is obsolete. Please refer to the article numbered {self.correct_kb_article_number} for reference.\",\n \"alternative_answers\": [\n self.incorrect_answer,\n ],\n }\n\n self.correct_config = {\n \"item\": self.item,\n \"kb_article_title\": self.correct_kb_article_name,\n \"value\": self.correct_answer,\n \"question\": self.base_config[\"questions\"][0],\n \"comment\": f\"This article has correct information. Please DO NOT refer to the article numbered {self.incorrect_kb_article_number} for reference.\",\n \"alternative_answers\": [\n self.correct_answer,\n ],\n }\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": 'Can you find the \"Edit Knowledge Article Protocol\" in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n search_and_comment_knowledge_base_incorrect_subtask = [\n # Navigate to the knowledge base home page\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config=self.incorrect_config,\n is_validated=False,\n used_in_level_2=True,\n is_correct=False,\n is_only_navigating=True,\n search_by_title=True,\n ),\n # Search the knowledge base for the incorrect article\n AddCommentToKnowledgeArticleTask(\n instance=self.instance,\n fixed_config=self.incorrect_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n search_and_comment_knowledge_base_correct_subtask = [\n # Navigate to the knowledge base home page\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config=self.correct_config,\n is_validated=False,\n used_in_level_2=True,\n is_only_navigating=True,\n search_by_title=True,\n ),\n # Search the knowledge base for the incorrect article\n AddCommentToKnowledgeArticleTask(\n instance=self.instance,\n fixed_config=self.correct_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + search_and_comment_knowledge_base_incorrect_subtask\n + search_and_comment_knowledge_base_correct_subtask\n )\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n incorrect_article_kb_sys_id = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"short_description={self.incorrect_kb_article_name}\",\n },\n )[\"result\"][0][\"sys_id\"]\n\n incorrect_synonyms = [\n \"incorrect\",\n \"wrong\",\n \"false\",\n \"inaccurate\",\n \"mistaken\",\n \"erroneous\",\n \"improper\",\n \"invalid\",\n \"untrue\",\n \"misleading\",\n \"off\",\n \"obsolete\",\n ]\n incorrect_validated = 0\n all_comments = table_api_call(\n instance=self.instance,\n table=\"kb_feedback\",\n params={\n \"sysparm_query\": f\"article={incorrect_article_kb_sys_id}\",\n },\n )[\"result\"]\n\n for comment in all_comments:\n if (\n any(\n incorrect_synonym.lower() in html.unescape(comment[\"comments\"]).lower()\n for incorrect_synonym in incorrect_synonyms\n )\n and comment[\"sys_created_by\"] == self._base_user_name\n and self.correct_kb_article_number.lower()\n in html.unescape(comment[\"comments\"]).lower()\n ):\n incorrect_validated = 1\n break\n\n correct_article_kb_sys_id = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"short_description={self.correct_kb_article_name}\",\n },\n )[\"result\"][0][\"sys_id\"]\n\n correct_synonyms = [\n \"correct\",\n \"right\",\n \"accurate\",\n \"true\",\n \"exact\",\n \"precise\",\n \"proper\",\n \"valid\",\n \"factual\",\n \"appropriate\",\n \"verifiable\",\n \"up-to-date\",\n \"up to date\",\n ]\n correct_validated = 0\n all_comments = table_api_call(\n instance=self.instance,\n table=\"kb_feedback\",\n params={\n \"sysparm_query\": f\"article={correct_article_kb_sys_id}\",\n },\n )[\"result\"]\n\n for comment in all_comments:\n if (\n any(\n correct_synonym.lower() in html.unescape(comment[\"comments\"]).lower()\n for correct_synonym in correct_synonyms\n )\n and comment[\"sys_created_by\"] == self._base_user_name\n and self.incorrect_kb_article_number.lower()\n in html.unescape(comment[\"comments\"]).lower()\n ):\n correct_validated = 1\n break\n\n if incorrect_validated and correct_validated:\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n elif incorrect_validated and not correct_validated:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment successfully added to the incorrect article but not the correct article.\"\n },\n )\n elif not incorrect_validated and correct_validated:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment successfully added to the correct article but not the incorrect article.\"\n },\n )\n else:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment not added to either the correct article or the incorrect article.\"\n },\n )\n\n def teardown(self) -> None:\n # Delete created articles\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge/{self.incorrect_kb_article_sys_id}\",\n method=\"DELETE\",\n )\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge/{self.correct_kb_article_sys_id}\",\n method=\"DELETE\",\n )\n\n # Archive knowledge base\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge_base/{self.adhoc_kb_sys_id}\",\n method=\"PATCH\",\n json={\"title\": f\"archived_{self.adhoc_kb_sys_id}\", \"active\": \"false\"},\n )\n return super().teardown()\n\n\n__TASKS__ = [EditKnowledgeBaseTask]","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base.EditKnowledgeBaseTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.edit_knowledge_base.EditKnowledgeBaseTask#L21-L454","kind":"class","name":"EditKnowledgeBaseTask","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":21,"end_line":454,"context_start_line":1,"context_end_line":457,"code":"import html\nimport json\nimport random\n\nfrom faker import Faker\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfake = Faker()\n\nfrom ...api.knowledge import give_kb_read_permissions\nfrom ...api.utils import table_api_call\nfrom ..base import AbstractServiceNowTask\nfrom .base import CompositionalTask\nfrom ...config import KB_FILEPATH, PROTOCOL_KB_NAME\nfrom ...instance import SNowInstance\nfrom ..knowledge import KnowledgeBaseSearchTask, AddCommentToKnowledgeArticleTask\nfrom ..navigation import AllMenuTask\n\n\nclass EditKnowledgeBaseTask(CompositionalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask, its configuration and whether or not it should be validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Edit a knowledge article', edit the knowledge base to handle the incorrect information: \\n'\n short_description: str\n A short description of the task to be completed. e.g. \"Edit knowledge base entries for address of parking lot.\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Edit a knowledge article to manage incorrect information\"\n\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n user_roles=[\"itil\"], # Required permission to access service desk for l3\n )\n with open(KB_FILEPATH, \"r\") as f:\n self.kb_entries = json.load(f)\n if not hasattr(self, \"_base_initial_instance\"):\n self._base_initial_instance = self.instance\n self.adhoc_kb_name = None\n self.task_description = None\n self.short_description = None\n\n def create_adhoc_kb(self):\n user_full_name = \" \".join(self._base_user_name.split(\".\")[:-1])\n adhoc_kb_name = f\"{user_full_name}'s Knowledge Base\"\n self.adhoc_kb_name = adhoc_kb_name\n\n kb = table_api_call(\n instance=self._base_initial_instance,\n table=\"kb_knowledge_base\",\n method=\"POST\",\n data=json.dumps(\n {\n \"title\": self.adhoc_kb_name,\n }\n ),\n )[\"result\"]\n\n return kb[\"sys_id\"]\n\n def get_random_article_name(self):\n kb = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"kb_knowledge_base={self.adhoc_kb_sys_id}\",\n \"sysparm_fields\": \"short_description\",\n },\n )[\"result\"]\n self.article_titles = [kb_article[\"short_description\"] for kb_article in kb]\n\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n base_article_name = self.base_config[\"item\"].capitalize()\n article_title = f\"{base_article_name}-{article_date}\"\n while article_title in self.article_titles:\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n article_title = f\"{base_article_name}-{article_date}\"\n\n return article_title\n\n def create_article(self, article_name, article_text):\n if article_name in self.article_titles:\n raise Exception(\"Article with the name already exists...\")\n\n adhoc_kb_response = table_api_call(\n instance=self._base_initial_instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"POST\",\n data=json.dumps(\n {\n \"short_description\": article_name,\n \"sys_class_name\": \"kb_knowledge\",\n \"text\": article_text,\n \"article_type\": \"text\",\n \"kb_knowledge_base\": self.adhoc_kb_sys_id,\n }\n ),\n )[\"result\"]\n\n return adhoc_kb_response\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create the KB\n self.adhoc_kb_sys_id = self.create_adhoc_kb()\n # Sample a configuration\n self.base_config = self.random.choice(self.kb_entries)\n self.incorrect_kb_article_name = self.get_random_article_name()\n self.correct_kb_article_name = self.get_random_article_name()\n self.item = self.base_config[\"item\"]\n self.correct_answer = self.base_config[\"value\"]\n\n self.incorrect_answer = \" \".join(\n [fake.word() for _ in range(len(self.correct_answer.split()))]\n ) # Random incorrect answer with the same number of words as the correct answer\n\n incorrect_kb_article = self.create_article(\n self.incorrect_kb_article_name,\n self.base_config[\"article\"].replace(self.correct_answer, self.incorrect_answer),\n )\n self.incorrect_kb_article_sys_id = incorrect_kb_article[\"sys_id\"]\n self.incorrect_kb_article_number = incorrect_kb_article[\"number\"]\n\n correct_kb_article = self.create_article(\n self.correct_kb_article_name, self.base_config[\"article\"]\n )\n self.correct_kb_article_sys_id = correct_kb_article[\"sys_id\"]\n self.correct_kb_article_number = correct_kb_article[\"number\"]\n\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n give_kb_read_permissions(\n self._base_initial_instance,\n self._base_user_sysid,\n self._base_user_name,\n self.adhoc_kb_sys_id,\n self.adhoc_kb_name,\n )\n\n if self.level == 3:\n protocol_kb_sys_id = table_api_call(\n instance=self._base_initial_instance,\n table=\"kb_knowledge_base\",\n params={\"sysparm_query\": f\"title={PROTOCOL_KB_NAME}\"},\n )[\"result\"][0][\"sys_id\"]\n give_kb_read_permissions(\n self._base_initial_instance,\n self._base_user_sysid,\n self._base_user_name,\n protocol_kb_sys_id,\n PROTOCOL_KB_NAME,\n )\n\n # Get the task description\n self.short_description = f\"Edit knowledge base article for {self.item}\"\n self.task_description = (\n f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) edit the knowledge base to handle incorrect information. \\n'\n + f'Searching for \"{self.item}\" in the knowledge base gives different articles as the output: \"{self.incorrect_kb_article_name}\" with number \"{self.incorrect_kb_article_number}\" and \"{self.correct_kb_article_name}\" with number \"{self.correct_kb_article_number}\". \\n'\n # + f'One of the articles has incorrect information \"{self.incorrect_answer}\" and the other one has the correct answer \"{self.correct_answer}\". \\n'\n + f'The correct information for \"{self.item}\" should be {self.correct_answer}. '\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n \"\"\"Add more extensive definition here.\"\"\"\n\n self.incorrect_config = {\n \"item\": self.item,\n \"kb_article_title\": self.incorrect_kb_article_name,\n \"value\": self.incorrect_answer,\n \"question\": self.base_config[\"questions\"][0],\n # \"replaced_text\": self.incorrect_answer,\n \"comment\": f\"This article has incorrect information and is obsolete. Please refer to the article numbered {self.correct_kb_article_number} for reference.\",\n \"alternative_answers\": [\n self.incorrect_answer,\n ],\n }\n\n self.correct_config = {\n \"item\": self.item,\n \"kb_article_title\": self.correct_kb_article_name,\n \"value\": self.correct_answer,\n \"question\": self.base_config[\"questions\"][0],\n \"comment\": f\"This article has correct information. Please DO NOT refer to the article numbered {self.incorrect_kb_article_number} for reference.\",\n \"alternative_answers\": [\n self.correct_answer,\n ],\n }\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": 'Can you find the \"Edit Knowledge Article Protocol\" in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n search_and_comment_knowledge_base_incorrect_subtask = [\n # Navigate to the knowledge base home page\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config=self.incorrect_config,\n is_validated=False,\n used_in_level_2=True,\n is_correct=False,\n is_only_navigating=True,\n search_by_title=True,\n ),\n # Search the knowledge base for the incorrect article\n AddCommentToKnowledgeArticleTask(\n instance=self.instance,\n fixed_config=self.incorrect_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n search_and_comment_knowledge_base_correct_subtask = [\n # Navigate to the knowledge base home page\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config=self.correct_config,\n is_validated=False,\n used_in_level_2=True,\n is_only_navigating=True,\n search_by_title=True,\n ),\n # Search the knowledge base for the incorrect article\n AddCommentToKnowledgeArticleTask(\n instance=self.instance,\n fixed_config=self.correct_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + search_and_comment_knowledge_base_incorrect_subtask\n + search_and_comment_knowledge_base_correct_subtask\n )\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n incorrect_article_kb_sys_id = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"short_description={self.incorrect_kb_article_name}\",\n },\n )[\"result\"][0][\"sys_id\"]\n\n incorrect_synonyms = [\n \"incorrect\",\n \"wrong\",\n \"false\",\n \"inaccurate\",\n \"mistaken\",\n \"erroneous\",\n \"improper\",\n \"invalid\",\n \"untrue\",\n \"misleading\",\n \"off\",\n \"obsolete\",\n ]\n incorrect_validated = 0\n all_comments = table_api_call(\n instance=self.instance,\n table=\"kb_feedback\",\n params={\n \"sysparm_query\": f\"article={incorrect_article_kb_sys_id}\",\n },\n )[\"result\"]\n\n for comment in all_comments:\n if (\n any(\n incorrect_synonym.lower() in html.unescape(comment[\"comments\"]).lower()\n for incorrect_synonym in incorrect_synonyms\n )\n and comment[\"sys_created_by\"] == self._base_user_name\n and self.correct_kb_article_number.lower()\n in html.unescape(comment[\"comments\"]).lower()\n ):\n incorrect_validated = 1\n break\n\n correct_article_kb_sys_id = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"short_description={self.correct_kb_article_name}\",\n },\n )[\"result\"][0][\"sys_id\"]\n\n correct_synonyms = [\n \"correct\",\n \"right\",\n \"accurate\",\n \"true\",\n \"exact\",\n \"precise\",\n \"proper\",\n \"valid\",\n \"factual\",\n \"appropriate\",\n \"verifiable\",\n \"up-to-date\",\n \"up to date\",\n ]\n correct_validated = 0\n all_comments = table_api_call(\n instance=self.instance,\n table=\"kb_feedback\",\n params={\n \"sysparm_query\": f\"article={correct_article_kb_sys_id}\",\n },\n )[\"result\"]\n\n for comment in all_comments:\n if (\n any(\n correct_synonym.lower() in html.unescape(comment[\"comments\"]).lower()\n for correct_synonym in correct_synonyms\n )\n and comment[\"sys_created_by\"] == self._base_user_name\n and self.incorrect_kb_article_number.lower()\n in html.unescape(comment[\"comments\"]).lower()\n ):\n correct_validated = 1\n break\n\n if incorrect_validated and correct_validated:\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n elif incorrect_validated and not correct_validated:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment successfully added to the incorrect article but not the correct article.\"\n },\n )\n elif not incorrect_validated and correct_validated:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment successfully added to the correct article but not the incorrect article.\"\n },\n )\n else:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment not added to either the correct article or the incorrect article.\"\n },\n )\n\n def teardown(self) -> None:\n # Delete created articles\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge/{self.incorrect_kb_article_sys_id}\",\n method=\"DELETE\",\n )\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge/{self.correct_kb_article_sys_id}\",\n method=\"DELETE\",\n )\n\n # Archive knowledge base\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge_base/{self.adhoc_kb_sys_id}\",\n method=\"PATCH\",\n json={\"title\": f\"archived_{self.adhoc_kb_sys_id}\", \"active\": \"false\"},\n )\n return super().teardown()\n\n\n__TASKS__ = [EditKnowledgeBaseTask]","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.edit_knowledge_base.__init__#L22-L68","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":22,"end_line":68,"context_start_line":2,"context_end_line":88,"code":"import json\nimport random\n\nfrom faker import Faker\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfake = Faker()\n\nfrom ...api.knowledge import give_kb_read_permissions\nfrom ...api.utils import table_api_call\nfrom ..base import AbstractServiceNowTask\nfrom .base import CompositionalTask\nfrom ...config import KB_FILEPATH, PROTOCOL_KB_NAME\nfrom ...instance import SNowInstance\nfrom ..knowledge import KnowledgeBaseSearchTask, AddCommentToKnowledgeArticleTask\nfrom ..navigation import AllMenuTask\n\n\nclass EditKnowledgeBaseTask(CompositionalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Create a compositional task with specific subtasks\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask, its configuration and whether or not it should be validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. e.g. \"Referring to company protocol 'Edit a knowledge article', edit the knowledge base to handle the incorrect information: \\n'\n short_description: str\n A short description of the task to be completed. e.g. \"Edit knowledge base entries for address of parking lot.\"\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Edit a knowledge article to manage incorrect information\"\n\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n user_roles=[\"itil\"], # Required permission to access service desk for l3\n )\n with open(KB_FILEPATH, \"r\") as f:\n self.kb_entries = json.load(f)\n if not hasattr(self, \"_base_initial_instance\"):\n self._base_initial_instance = self.instance\n self.adhoc_kb_name = None\n self.task_description = None\n self.short_description = None\n\n def create_adhoc_kb(self):\n user_full_name = \" \".join(self._base_user_name.split(\".\")[:-1])\n adhoc_kb_name = f\"{user_full_name}'s Knowledge Base\"\n self.adhoc_kb_name = adhoc_kb_name\n\n kb = table_api_call(\n instance=self._base_initial_instance,\n table=\"kb_knowledge_base\",\n method=\"POST\",\n data=json.dumps(\n {\n \"title\": self.adhoc_kb_name,\n }\n ),\n )[\"result\"]\n\n return kb[\"sys_id\"]\n\n def get_random_article_name(self):","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base.create_adhoc_kb","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.edit_knowledge_base.create_adhoc_kb#L70-L86","kind":"function","name":"create_adhoc_kb","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":70,"end_line":86,"context_start_line":50,"context_end_line":106,"code":" assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n self.protocol_name = \"Edit a knowledge article to manage incorrect information\"\n\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n protocol_name=self.protocol_name,\n user_roles=[\"itil\"], # Required permission to access service desk for l3\n )\n with open(KB_FILEPATH, \"r\") as f:\n self.kb_entries = json.load(f)\n if not hasattr(self, \"_base_initial_instance\"):\n self._base_initial_instance = self.instance\n self.adhoc_kb_name = None\n self.task_description = None\n self.short_description = None\n\n def create_adhoc_kb(self):\n user_full_name = \" \".join(self._base_user_name.split(\".\")[:-1])\n adhoc_kb_name = f\"{user_full_name}'s Knowledge Base\"\n self.adhoc_kb_name = adhoc_kb_name\n\n kb = table_api_call(\n instance=self._base_initial_instance,\n table=\"kb_knowledge_base\",\n method=\"POST\",\n data=json.dumps(\n {\n \"title\": self.adhoc_kb_name,\n }\n ),\n )[\"result\"]\n\n return kb[\"sys_id\"]\n\n def get_random_article_name(self):\n kb = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"kb_knowledge_base={self.adhoc_kb_sys_id}\",\n \"sysparm_fields\": \"short_description\",\n },\n )[\"result\"]\n self.article_titles = [kb_article[\"short_description\"] for kb_article in kb]\n\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n base_article_name = self.base_config[\"item\"].capitalize()\n article_title = f\"{base_article_name}-{article_date}\"\n while article_title in self.article_titles:\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n article_title = f\"{base_article_name}-{article_date}\"\n\n return article_title","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base.get_random_article_name","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.edit_knowledge_base.get_random_article_name#L88-L106","kind":"function","name":"get_random_article_name","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":88,"end_line":106,"context_start_line":68,"context_end_line":126,"code":" self.short_description = None\n\n def create_adhoc_kb(self):\n user_full_name = \" \".join(self._base_user_name.split(\".\")[:-1])\n adhoc_kb_name = f\"{user_full_name}'s Knowledge Base\"\n self.adhoc_kb_name = adhoc_kb_name\n\n kb = table_api_call(\n instance=self._base_initial_instance,\n table=\"kb_knowledge_base\",\n method=\"POST\",\n data=json.dumps(\n {\n \"title\": self.adhoc_kb_name,\n }\n ),\n )[\"result\"]\n\n return kb[\"sys_id\"]\n\n def get_random_article_name(self):\n kb = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"kb_knowledge_base={self.adhoc_kb_sys_id}\",\n \"sysparm_fields\": \"short_description\",\n },\n )[\"result\"]\n self.article_titles = [kb_article[\"short_description\"] for kb_article in kb]\n\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n base_article_name = self.base_config[\"item\"].capitalize()\n article_title = f\"{base_article_name}-{article_date}\"\n while article_title in self.article_titles:\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n article_title = f\"{base_article_name}-{article_date}\"\n\n return article_title\n\n def create_article(self, article_name, article_text):\n if article_name in self.article_titles:\n raise Exception(\"Article with the name already exists...\")\n\n adhoc_kb_response = table_api_call(\n instance=self._base_initial_instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"POST\",\n data=json.dumps(\n {\n \"short_description\": article_name,\n \"sys_class_name\": \"kb_knowledge\",\n \"text\": article_text,\n \"article_type\": \"text\",\n \"kb_knowledge_base\": self.adhoc_kb_sys_id,\n }\n ),\n )[\"result\"]\n","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base.create_article","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.edit_knowledge_base.create_article#L108-L127","kind":"function","name":"create_article","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":108,"end_line":127,"context_start_line":88,"context_end_line":147,"code":" def get_random_article_name(self):\n kb = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"kb_knowledge_base={self.adhoc_kb_sys_id}\",\n \"sysparm_fields\": \"short_description\",\n },\n )[\"result\"]\n self.article_titles = [kb_article[\"short_description\"] for kb_article in kb]\n\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n base_article_name = self.base_config[\"item\"].capitalize()\n article_title = f\"{base_article_name}-{article_date}\"\n while article_title in self.article_titles:\n article_date = fake.date_this_year().strftime(\"%Y-%m-%d\")\n article_title = f\"{base_article_name}-{article_date}\"\n\n return article_title\n\n def create_article(self, article_name, article_text):\n if article_name in self.article_titles:\n raise Exception(\"Article with the name already exists...\")\n\n adhoc_kb_response = table_api_call(\n instance=self._base_initial_instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"POST\",\n data=json.dumps(\n {\n \"short_description\": article_name,\n \"sys_class_name\": \"kb_knowledge\",\n \"text\": article_text,\n \"article_type\": \"text\",\n \"kb_knowledge_base\": self.adhoc_kb_sys_id,\n }\n ),\n )[\"result\"]\n\n return adhoc_kb_response\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create the KB\n self.adhoc_kb_sys_id = self.create_adhoc_kb()\n # Sample a configuration\n self.base_config = self.random.choice(self.kb_entries)\n self.incorrect_kb_article_name = self.get_random_article_name()\n self.correct_kb_article_name = self.get_random_article_name()\n self.item = self.base_config[\"item\"]\n self.correct_answer = self.base_config[\"value\"]\n\n self.incorrect_answer = \" \".join(\n [fake.word() for _ in range(len(self.correct_answer.split()))]\n ) # Random incorrect answer with the same number of words as the correct answer\n\n incorrect_kb_article = self.create_article(\n self.incorrect_kb_article_name,\n self.base_config[\"article\"].replace(self.correct_answer, self.incorrect_answer),\n )\n self.incorrect_kb_article_sys_id = incorrect_kb_article[\"sys_id\"]","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.edit_knowledge_base.setup_goal#L129-L191","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":129,"end_line":191,"context_start_line":109,"context_end_line":211,"code":" if article_name in self.article_titles:\n raise Exception(\"Article with the name already exists...\")\n\n adhoc_kb_response = table_api_call(\n instance=self._base_initial_instance, # admin permissions to contribute to the KB\n table=\"kb_knowledge\",\n method=\"POST\",\n data=json.dumps(\n {\n \"short_description\": article_name,\n \"sys_class_name\": \"kb_knowledge\",\n \"text\": article_text,\n \"article_type\": \"text\",\n \"kb_knowledge_base\": self.adhoc_kb_sys_id,\n }\n ),\n )[\"result\"]\n\n return adhoc_kb_response\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n # Create the KB\n self.adhoc_kb_sys_id = self.create_adhoc_kb()\n # Sample a configuration\n self.base_config = self.random.choice(self.kb_entries)\n self.incorrect_kb_article_name = self.get_random_article_name()\n self.correct_kb_article_name = self.get_random_article_name()\n self.item = self.base_config[\"item\"]\n self.correct_answer = self.base_config[\"value\"]\n\n self.incorrect_answer = \" \".join(\n [fake.word() for _ in range(len(self.correct_answer.split()))]\n ) # Random incorrect answer with the same number of words as the correct answer\n\n incorrect_kb_article = self.create_article(\n self.incorrect_kb_article_name,\n self.base_config[\"article\"].replace(self.correct_answer, self.incorrect_answer),\n )\n self.incorrect_kb_article_sys_id = incorrect_kb_article[\"sys_id\"]\n self.incorrect_kb_article_number = incorrect_kb_article[\"number\"]\n\n correct_kb_article = self.create_article(\n self.correct_kb_article_name, self.base_config[\"article\"]\n )\n self.correct_kb_article_sys_id = correct_kb_article[\"sys_id\"]\n self.correct_kb_article_number = correct_kb_article[\"number\"]\n\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n give_kb_read_permissions(\n self._base_initial_instance,\n self._base_user_sysid,\n self._base_user_name,\n self.adhoc_kb_sys_id,\n self.adhoc_kb_name,\n )\n\n if self.level == 3:\n protocol_kb_sys_id = table_api_call(\n instance=self._base_initial_instance,\n table=\"kb_knowledge_base\",\n params={\"sysparm_query\": f\"title={PROTOCOL_KB_NAME}\"},\n )[\"result\"][0][\"sys_id\"]\n give_kb_read_permissions(\n self._base_initial_instance,\n self._base_user_sysid,\n self._base_user_name,\n protocol_kb_sys_id,\n PROTOCOL_KB_NAME,\n )\n\n # Get the task description\n self.short_description = f\"Edit knowledge base article for {self.item}\"\n self.task_description = (\n f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) edit the knowledge base to handle incorrect information. \\n'\n + f'Searching for \"{self.item}\" in the knowledge base gives different articles as the output: \"{self.incorrect_kb_article_name}\" with number \"{self.incorrect_kb_article_number}\" and \"{self.correct_kb_article_name}\" with number \"{self.correct_kb_article_number}\". \\n'\n # + f'One of the articles has incorrect information \"{self.incorrect_answer}\" and the other one has the correct answer \"{self.correct_answer}\". \\n'\n + f'The correct information for \"{self.item}\" should be {self.correct_answer}. '\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n \"\"\"Add more extensive definition here.\"\"\"\n\n self.incorrect_config = {\n \"item\": self.item,\n \"kb_article_title\": self.incorrect_kb_article_name,\n \"value\": self.incorrect_answer,\n \"question\": self.base_config[\"questions\"][0],\n # \"replaced_text\": self.incorrect_answer,\n \"comment\": f\"This article has incorrect information and is obsolete. Please refer to the article numbered {self.correct_kb_article_number} for reference.\",\n \"alternative_answers\": [\n self.incorrect_answer,\n ],\n }\n\n self.correct_config = {\n \"item\": self.item,\n \"kb_article_title\": self.correct_kb_article_name,\n \"value\": self.correct_answer,","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.edit_knowledge_base._get_config#L193-L310","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":193,"end_line":310,"context_start_line":173,"context_end_line":330,"code":" self._base_initial_instance,\n self._base_user_sysid,\n self._base_user_name,\n protocol_kb_sys_id,\n PROTOCOL_KB_NAME,\n )\n\n # Get the task description\n self.short_description = f\"Edit knowledge base article for {self.item}\"\n self.task_description = (\n f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) edit the knowledge base to handle incorrect information. \\n'\n + f'Searching for \"{self.item}\" in the knowledge base gives different articles as the output: \"{self.incorrect_kb_article_name}\" with number \"{self.incorrect_kb_article_number}\" and \"{self.correct_kb_article_name}\" with number \"{self.correct_kb_article_number}\". \\n'\n # + f'One of the articles has incorrect information \"{self.incorrect_answer}\" and the other one has the correct answer \"{self.correct_answer}\". \\n'\n + f'The correct information for \"{self.item}\" should be {self.correct_answer}. '\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[tuple[AbstractServiceNowTask, dict, bool]]:\n \"\"\"Add more extensive definition here.\"\"\"\n\n self.incorrect_config = {\n \"item\": self.item,\n \"kb_article_title\": self.incorrect_kb_article_name,\n \"value\": self.incorrect_answer,\n \"question\": self.base_config[\"questions\"][0],\n # \"replaced_text\": self.incorrect_answer,\n \"comment\": f\"This article has incorrect information and is obsolete. Please refer to the article numbered {self.correct_kb_article_number} for reference.\",\n \"alternative_answers\": [\n self.incorrect_answer,\n ],\n }\n\n self.correct_config = {\n \"item\": self.item,\n \"kb_article_title\": self.correct_kb_article_name,\n \"value\": self.correct_answer,\n \"question\": self.base_config[\"questions\"][0],\n \"comment\": f\"This article has correct information. Please DO NOT refer to the article numbered {self.incorrect_kb_article_number} for reference.\",\n \"alternative_answers\": [\n self.correct_answer,\n ],\n }\n\n navigate_to_protocol_subtask = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": 'Can you find the \"Edit Knowledge Article Protocol\" in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n search_and_comment_knowledge_base_incorrect_subtask = [\n # Navigate to the knowledge base home page\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config=self.incorrect_config,\n is_validated=False,\n used_in_level_2=True,\n is_correct=False,\n is_only_navigating=True,\n search_by_title=True,\n ),\n # Search the knowledge base for the incorrect article\n AddCommentToKnowledgeArticleTask(\n instance=self.instance,\n fixed_config=self.incorrect_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n search_and_comment_knowledge_base_correct_subtask = [\n # Navigate to the knowledge base home page\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config=self.correct_config,\n is_validated=False,\n used_in_level_2=True,\n is_only_navigating=True,\n search_by_title=True,\n ),\n # Search the knowledge base for the incorrect article\n AddCommentToKnowledgeArticleTask(\n instance=self.instance,\n fixed_config=self.correct_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + search_and_comment_knowledge_base_incorrect_subtask\n + search_and_comment_knowledge_base_correct_subtask\n )\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n incorrect_article_kb_sys_id = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"short_description={self.incorrect_kb_article_name}\",\n },\n )[\"result\"][0][\"sys_id\"]\n\n incorrect_synonyms = [\n \"incorrect\",\n \"wrong\",\n \"false\",\n \"inaccurate\",\n \"mistaken\",\n \"erroneous\",\n \"improper\",\n \"invalid\",\n \"untrue\",","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.edit_knowledge_base.validate#L312-L432","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":312,"end_line":432,"context_start_line":292,"context_end_line":452,"code":" is_only_navigating=True,\n search_by_title=True,\n ),\n # Search the knowledge base for the incorrect article\n AddCommentToKnowledgeArticleTask(\n instance=self.instance,\n fixed_config=self.correct_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n ]\n\n config = (\n navigate_to_protocol_subtask\n + search_and_comment_knowledge_base_incorrect_subtask\n + search_and_comment_knowledge_base_correct_subtask\n )\n\n return config\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n incorrect_article_kb_sys_id = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"short_description={self.incorrect_kb_article_name}\",\n },\n )[\"result\"][0][\"sys_id\"]\n\n incorrect_synonyms = [\n \"incorrect\",\n \"wrong\",\n \"false\",\n \"inaccurate\",\n \"mistaken\",\n \"erroneous\",\n \"improper\",\n \"invalid\",\n \"untrue\",\n \"misleading\",\n \"off\",\n \"obsolete\",\n ]\n incorrect_validated = 0\n all_comments = table_api_call(\n instance=self.instance,\n table=\"kb_feedback\",\n params={\n \"sysparm_query\": f\"article={incorrect_article_kb_sys_id}\",\n },\n )[\"result\"]\n\n for comment in all_comments:\n if (\n any(\n incorrect_synonym.lower() in html.unescape(comment[\"comments\"]).lower()\n for incorrect_synonym in incorrect_synonyms\n )\n and comment[\"sys_created_by\"] == self._base_user_name\n and self.correct_kb_article_number.lower()\n in html.unescape(comment[\"comments\"]).lower()\n ):\n incorrect_validated = 1\n break\n\n correct_article_kb_sys_id = table_api_call(\n instance=self.instance,\n table=\"kb_knowledge\",\n params={\n \"sysparm_query\": f\"short_description={self.correct_kb_article_name}\",\n },\n )[\"result\"][0][\"sys_id\"]\n\n correct_synonyms = [\n \"correct\",\n \"right\",\n \"accurate\",\n \"true\",\n \"exact\",\n \"precise\",\n \"proper\",\n \"valid\",\n \"factual\",\n \"appropriate\",\n \"verifiable\",\n \"up-to-date\",\n \"up to date\",\n ]\n correct_validated = 0\n all_comments = table_api_call(\n instance=self.instance,\n table=\"kb_feedback\",\n params={\n \"sysparm_query\": f\"article={correct_article_kb_sys_id}\",\n },\n )[\"result\"]\n\n for comment in all_comments:\n if (\n any(\n correct_synonym.lower() in html.unescape(comment[\"comments\"]).lower()\n for correct_synonym in correct_synonyms\n )\n and comment[\"sys_created_by\"] == self._base_user_name\n and self.incorrect_kb_article_number.lower()\n in html.unescape(comment[\"comments\"]).lower()\n ):\n correct_validated = 1\n break\n\n if incorrect_validated and correct_validated:\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n elif incorrect_validated and not correct_validated:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment successfully added to the incorrect article but not the correct article.\"\n },\n )\n elif not incorrect_validated and correct_validated:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment successfully added to the correct article but not the incorrect article.\"\n },\n )\n else:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment not added to either the correct article or the incorrect article.\"\n },\n )\n\n def teardown(self) -> None:\n # Delete created articles\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge/{self.incorrect_kb_article_sys_id}\",\n method=\"DELETE\",\n )\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge/{self.correct_kb_article_sys_id}\",\n method=\"DELETE\",\n )\n\n # Archive knowledge base\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge_base/{self.adhoc_kb_sys_id}\",\n method=\"PATCH\",\n json={\"title\": f\"archived_{self.adhoc_kb_sys_id}\", \"active\": \"false\"},","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.edit_knowledge_base.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.edit_knowledge_base.teardown#L434-L454","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":434,"end_line":454,"context_start_line":414,"context_end_line":457,"code":" )\n elif not incorrect_validated and correct_validated:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment successfully added to the correct article but not the incorrect article.\"\n },\n )\n else:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": \"Comment not added to either the correct article or the incorrect article.\"\n },\n )\n\n def teardown(self) -> None:\n # Delete created articles\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge/{self.incorrect_kb_article_sys_id}\",\n method=\"DELETE\",\n )\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge/{self.correct_kb_article_sys_id}\",\n method=\"DELETE\",\n )\n\n # Archive knowledge base\n table_api_call(\n instance=self._base_initial_instance,\n table=f\"kb_knowledge_base/{self.adhoc_kb_sys_id}\",\n method=\"PATCH\",\n json={\"title\": f\"archived_{self.adhoc_kb_sys_id}\", \"active\": \"false\"},\n )\n return super().teardown()\n\n\n__TASKS__ = [EditKnowledgeBaseTask]","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.update_task","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.update_task#L1-L145","kind":"module","name":"src.browsergym.workarena.tasks.compositional.update_task","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":1,"end_line":145,"context_start_line":1,"context_end_line":145,"code":"from playwright.sync_api import Page\nfrom typing import List, Tuple\n\nfrom ..base import AbstractServiceNowTask\nfrom ..comp_building_block import CompositionalBuildingBlockTask\nfrom ..utils.utils import check_url_suffix_match\nfrom ..utils.private_tasks import create_private_task_and_get_sys_id\n\nfrom ...api.utils import db_delete_from_table, table_api_call\n\n\nclass UpdatePrivateTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Set a private task to complete, assuming we start on the task viewed as form.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the task list.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n set_as_completed: bool\n Whether the task should be marked as complete or not. If True, the task will be marked as complete; otherwise, marked as.\n used to set infeasible tasks to incomplete.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n start_rel_url=\"/now/nav/ui/classic/params/target/task_list.do%3Fsysparm_userpref_module%3D1523b8d4c611227b00be8216ec331b9a%26sysparm_query%3Dactive%253Dtrue%255Eassigned_to%253Djavascript%253AgetMyAssignments%2528%2529%255Estate%2521%253D-5%255EEQ\",\n fixed_config: dict = None,\n set_as_completed: bool = True,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n self.set_as_completed = set_as_completed\n # 3 is the state for \"Closed-Complete\", 4 is \"Closed-Incomplete\", 7 is \"Closed-Skipped\"\n self.allowed_options = [\"3\"] if self.set_as_completed else [\"4\", \"7\"]\n self.private_task_id = \"PTSK\" + str(id(self) % (10**8)).zfill(8)\n if self.fixed_config is None:\n self.config = {\n \"task_description\": \"Close private task\",\n \"short_description\": self.private_task_id,\n }\n self.sys_id = None\n self.task_rel_url = None # Relative URL of the task in form view\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n task_description = self.config[\"task_description\"]\n short_description = self.config[\"short_description\"]\n self.sys_id = create_private_task_and_get_sys_id(\n self.instance,\n page,\n self.private_task_id,\n task_description,\n short_description,\n user_sys_id=self._base_user_sysid,\n )\n self.task_rel_url = (\n f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n goal = f\"Close private task {self.private_task_id}\"\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = \"Don't forget to mark this task as complete once you're done.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.get_by_label(\"Search a specific field of the Tasks list\").select_option(\"number\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(self.private_task_id)\n search_input.press(\"Enter\")\n page.wait_for_timeout(1500)\n # Click on the private task to open it\n frame.get_by_label(f\"Open record: {self.private_task_id}\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Click on the task state, select \"Closed-Complete\" if complete, else \"Closed Skipped\" and update the task\n option = \"3\" if self.set_as_completed else \"7\"\n frame.get_by_label(\"state\").first.select_option(option)\n frame.get_by_text(\"update\").first.click()\n # Wait for record to be updated in the DB\n record_updated = False\n while not record_updated:\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n record_updated = record[0][\"state\"] == option\n page.wait_for_timeout(1000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n if not record:\n return 0, False, \"\", {\"message\": \"Private task not found.\"}\n if record[0][\"state\"] not in self.allowed_options:\n return 0, False, \"\", {\"message\": \"Private task not closed appropriately.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Private task was closed.\"}\n\n def teardown(self) -> None:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"sys_id={self.sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"vtb_task\",\n sys_id=self.sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [UpdatePrivateTask]","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.update_task.UpdatePrivateTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.update_task.UpdatePrivateTask#L12-L142","kind":"class","name":"UpdatePrivateTask","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":12,"end_line":142,"context_start_line":1,"context_end_line":145,"code":"from playwright.sync_api import Page\nfrom typing import List, Tuple\n\nfrom ..base import AbstractServiceNowTask\nfrom ..comp_building_block import CompositionalBuildingBlockTask\nfrom ..utils.utils import check_url_suffix_match\nfrom ..utils.private_tasks import create_private_task_and_get_sys_id\n\nfrom ...api.utils import db_delete_from_table, table_api_call\n\n\nclass UpdatePrivateTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Set a private task to complete, assuming we start on the task viewed as form.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the task list.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n set_as_completed: bool\n Whether the task should be marked as complete or not. If True, the task will be marked as complete; otherwise, marked as.\n used to set infeasible tasks to incomplete.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n start_rel_url=\"/now/nav/ui/classic/params/target/task_list.do%3Fsysparm_userpref_module%3D1523b8d4c611227b00be8216ec331b9a%26sysparm_query%3Dactive%253Dtrue%255Eassigned_to%253Djavascript%253AgetMyAssignments%2528%2529%255Estate%2521%253D-5%255EEQ\",\n fixed_config: dict = None,\n set_as_completed: bool = True,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n self.set_as_completed = set_as_completed\n # 3 is the state for \"Closed-Complete\", 4 is \"Closed-Incomplete\", 7 is \"Closed-Skipped\"\n self.allowed_options = [\"3\"] if self.set_as_completed else [\"4\", \"7\"]\n self.private_task_id = \"PTSK\" + str(id(self) % (10**8)).zfill(8)\n if self.fixed_config is None:\n self.config = {\n \"task_description\": \"Close private task\",\n \"short_description\": self.private_task_id,\n }\n self.sys_id = None\n self.task_rel_url = None # Relative URL of the task in form view\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n task_description = self.config[\"task_description\"]\n short_description = self.config[\"short_description\"]\n self.sys_id = create_private_task_and_get_sys_id(\n self.instance,\n page,\n self.private_task_id,\n task_description,\n short_description,\n user_sys_id=self._base_user_sysid,\n )\n self.task_rel_url = (\n f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n goal = f\"Close private task {self.private_task_id}\"\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = \"Don't forget to mark this task as complete once you're done.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.get_by_label(\"Search a specific field of the Tasks list\").select_option(\"number\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(self.private_task_id)\n search_input.press(\"Enter\")\n page.wait_for_timeout(1500)\n # Click on the private task to open it\n frame.get_by_label(f\"Open record: {self.private_task_id}\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Click on the task state, select \"Closed-Complete\" if complete, else \"Closed Skipped\" and update the task\n option = \"3\" if self.set_as_completed else \"7\"\n frame.get_by_label(\"state\").first.select_option(option)\n frame.get_by_text(\"update\").first.click()\n # Wait for record to be updated in the DB\n record_updated = False\n while not record_updated:\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n record_updated = record[0][\"state\"] == option\n page.wait_for_timeout(1000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n if not record:\n return 0, False, \"\", {\"message\": \"Private task not found.\"}\n if record[0][\"state\"] not in self.allowed_options:\n return 0, False, \"\", {\"message\": \"Private task not closed appropriately.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Private task was closed.\"}\n\n def teardown(self) -> None:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"sys_id={self.sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"vtb_task\",\n sys_id=self.sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [UpdatePrivateTask]","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.update_task.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.update_task.__init__#L31-L54","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":31,"end_line":54,"context_start_line":11,"context_end_line":74,"code":"\nclass UpdatePrivateTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Set a private task to complete, assuming we start on the task viewed as form.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the task list.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n set_as_completed: bool\n Whether the task should be marked as complete or not. If True, the task will be marked as complete; otherwise, marked as.\n used to set infeasible tasks to incomplete.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n start_rel_url=\"/now/nav/ui/classic/params/target/task_list.do%3Fsysparm_userpref_module%3D1523b8d4c611227b00be8216ec331b9a%26sysparm_query%3Dactive%253Dtrue%255Eassigned_to%253Djavascript%253AgetMyAssignments%2528%2529%255Estate%2521%253D-5%255EEQ\",\n fixed_config: dict = None,\n set_as_completed: bool = True,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n self.set_as_completed = set_as_completed\n # 3 is the state for \"Closed-Complete\", 4 is \"Closed-Incomplete\", 7 is \"Closed-Skipped\"\n self.allowed_options = [\"3\"] if self.set_as_completed else [\"4\", \"7\"]\n self.private_task_id = \"PTSK\" + str(id(self) % (10**8)).zfill(8)\n if self.fixed_config is None:\n self.config = {\n \"task_description\": \"Close private task\",\n \"short_description\": self.private_task_id,\n }\n self.sys_id = None\n self.task_rel_url = None # Relative URL of the task in form view\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n task_description = self.config[\"task_description\"]\n short_description = self.config[\"short_description\"]\n self.sys_id = create_private_task_and_get_sys_id(\n self.instance,\n page,\n self.private_task_id,\n task_description,\n short_description,\n user_sys_id=self._base_user_sysid,\n )\n self.task_rel_url = (\n f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n goal = f\"Close private task {self.private_task_id}\"\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.update_task.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.update_task.setup_goal#L56-L72","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":56,"end_line":72,"context_start_line":36,"context_end_line":92,"code":" fixed_config: dict = None,\n set_as_completed: bool = True,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.fixed_config = fixed_config\n self.config = fixed_config\n self.set_as_completed = set_as_completed\n # 3 is the state for \"Closed-Complete\", 4 is \"Closed-Incomplete\", 7 is \"Closed-Skipped\"\n self.allowed_options = [\"3\"] if self.set_as_completed else [\"4\", \"7\"]\n self.private_task_id = \"PTSK\" + str(id(self) % (10**8)).zfill(8)\n if self.fixed_config is None:\n self.config = {\n \"task_description\": \"Close private task\",\n \"short_description\": self.private_task_id,\n }\n self.sys_id = None\n self.task_rel_url = None # Relative URL of the task in form view\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n task_description = self.config[\"task_description\"]\n short_description = self.config[\"short_description\"]\n self.sys_id = create_private_task_and_get_sys_id(\n self.instance,\n page,\n self.private_task_id,\n task_description,\n short_description,\n user_sys_id=self._base_user_sysid,\n )\n self.task_rel_url = (\n f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n goal = f\"Close private task {self.private_task_id}\"\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = \"Don't forget to mark this task as complete once you're done.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.get_by_label(\"Search a specific field of the Tasks list\").select_option(\"number\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(self.private_task_id)\n search_input.press(\"Enter\")\n page.wait_for_timeout(1500)","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.update_task.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.update_task.get_pretty_printed_description#L74-L81","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":74,"end_line":81,"context_start_line":54,"context_end_line":101,"code":" self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n task_description = self.config[\"task_description\"]\n short_description = self.config[\"short_description\"]\n self.sys_id = create_private_task_and_get_sys_id(\n self.instance,\n page,\n self.private_task_id,\n task_description,\n short_description,\n user_sys_id=self._base_user_sysid,\n )\n self.task_rel_url = (\n f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n goal = f\"Close private task {self.private_task_id}\"\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = \"Don't forget to mark this task as complete once you're done.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.get_by_label(\"Search a specific field of the Tasks list\").select_option(\"number\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(self.private_task_id)\n search_input.press(\"Enter\")\n page.wait_for_timeout(1500)\n # Click on the private task to open it\n frame.get_by_label(f\"Open record: {self.private_task_id}\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Click on the task state, select \"Closed-Complete\" if complete, else \"Closed Skipped\" and update the task\n option = \"3\" if self.set_as_completed else \"7\"\n frame.get_by_label(\"state\").first.select_option(option)","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.update_task.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.update_task.cheat#L83-L112","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":83,"end_line":112,"context_start_line":63,"context_end_line":132,"code":" task_description,\n short_description,\n user_sys_id=self._base_user_sysid,\n )\n self.task_rel_url = (\n f\"/now/nav/ui/classic/params/target/vtb_task.do%3Fsys_id%3D{self.sys_id}\"\n )\n goal = f\"Close private task {self.private_task_id}\"\n\n return goal, {}\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = \"Don't forget to mark this task as complete once you're done.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Search for the private task by search for the number\n frame.get_by_label(\"Search a specific field of the Tasks list\").select_option(\"number\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(self.private_task_id)\n search_input.press(\"Enter\")\n page.wait_for_timeout(1500)\n # Click on the private task to open it\n frame.get_by_label(f\"Open record: {self.private_task_id}\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Click on the task state, select \"Closed-Complete\" if complete, else \"Closed Skipped\" and update the task\n option = \"3\" if self.set_as_completed else \"7\"\n frame.get_by_label(\"state\").first.select_option(option)\n frame.get_by_text(\"update\").first.click()\n # Wait for record to be updated in the DB\n record_updated = False\n while not record_updated:\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n record_updated = record[0][\"state\"] == option\n page.wait_for_timeout(1000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n if not record:\n return 0, False, \"\", {\"message\": \"Private task not found.\"}\n if record[0][\"state\"] not in self.allowed_options:\n return 0, False, \"\", {\"message\": \"Private task not closed appropriately.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Private task was closed.\"}\n\n def teardown(self) -> None:\n record_exists = table_api_call(\n instance=self.instance,","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.update_task.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.update_task.validate#L114-L128","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":114,"end_line":128,"context_start_line":94,"context_end_line":145,"code":" frame.get_by_label(f\"Open record: {self.private_task_id}\").click()\n page.wait_for_timeout(2000)\n page.wait_for_load_state(\"networkidle\")\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n page.wait_for_timeout(1500)\n # Click on the task state, select \"Closed-Complete\" if complete, else \"Closed Skipped\" and update the task\n option = \"3\" if self.set_as_completed else \"7\"\n frame.get_by_label(\"state\").first.select_option(option)\n frame.get_by_text(\"update\").first.click()\n # Wait for record to be updated in the DB\n record_updated = False\n while not record_updated:\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n record_updated = record[0][\"state\"] == option\n page.wait_for_timeout(1000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n if not record:\n return 0, False, \"\", {\"message\": \"Private task not found.\"}\n if record[0][\"state\"] not in self.allowed_options:\n return 0, False, \"\", {\"message\": \"Private task not closed appropriately.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Private task was closed.\"}\n\n def teardown(self) -> None:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"sys_id={self.sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"vtb_task\",\n sys_id=self.sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [UpdatePrivateTask]","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.update_task.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.update_task.teardown#L130-L142","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":130,"end_line":142,"context_start_line":110,"context_end_line":145,"code":" )[\"result\"]\n record_updated = record[0][\"state\"] == option\n page.wait_for_timeout(1000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"task_effective_number={self.private_task_id}\"},\n )[\"result\"]\n if not record:\n return 0, False, \"\", {\"message\": \"Private task not found.\"}\n if record[0][\"state\"] not in self.allowed_options:\n return 0, False, \"\", {\"message\": \"Private task not closed appropriately.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Private task was closed.\"}\n\n def teardown(self) -> None:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"vtb_task\",\n params={\"sysparm_query\": f\"sys_id={self.sys_id}\"},\n )[\"result\"]\n if record_exists:\n db_delete_from_table(\n instance=self.instance,\n table=\"vtb_task\",\n sys_id=self.sys_id,\n )\n super().teardown()\n\n\n__TASKS__ = [UpdatePrivateTask]","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible#L1-L2047","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1,"end_line":2047,"context_start_line":1,"context_end_line":2047,"code":"from .dash_do_base import DashboardRetrieveCatalogAndDoInfeasibleTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n)\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\n\nclass DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDeveloperLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Developer Laptop (Mac)\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopWithReasonInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_IPAD_MINI_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadMiniTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad mini\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_IPAD_PRO_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadProTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad pro\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n leve\n# ... truncated ...","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask#L34-L62","kind":"class","name":"DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":34,"end_line":62,"context_start_line":14,"context_end_line":82,"code":" ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n)\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\n\nclass DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDeveloperLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Developer Laptop (Mac)\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleWithReasonTask#L65-L86","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":65,"end_line":86,"context_start_line":45,"context_end_line":106,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDeveloperLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Developer Laptop (Mac)\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleTask#L89-L110","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":89,"end_line":110,"context_start_line":69,"context_end_line":130,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopWithReasonInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopWithReasonInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopWithReasonInfeasibleTask#L113-L134","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopWithReasonInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":113,"end_line":134,"context_start_line":93,"context_end_line":154,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopWithReasonInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopInfeasibleTask#L137-L158","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":137,"end_line":158,"context_start_line":117,"context_end_line":178,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleWithReasonTask#L161-L182","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":161,"end_line":182,"context_start_line":141,"context_end_line":202,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleTask#L185-L206","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":185,"end_line":206,"context_start_line":165,"context_end_line":226,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleWithReasonTask#L209-L230","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":209,"end_line":230,"context_start_line":189,"context_end_line":250,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleTask#L233-L254","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":233,"end_line":254,"context_start_line":213,"context_end_line":274,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_IPAD_MINI_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask#L257-L285","kind":"class","name":"DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":257,"end_line":285,"context_start_line":237,"context_end_line":305,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_IPAD_MINI_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadMiniTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad mini\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleWithReasonTask#L288-L309","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":288,"end_line":309,"context_start_line":268,"context_end_line":329,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadMiniTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad mini\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleTask#L312-L333","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":312,"end_line":333,"context_start_line":292,"context_end_line":353,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleWithReasonTask#L336-L357","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":336,"end_line":357,"context_start_line":316,"context_end_line":377,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleTask#L360-L381","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":360,"end_line":381,"context_start_line":340,"context_end_line":401,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleWithReasonTask#L384-L405","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":384,"end_line":405,"context_start_line":364,"context_end_line":425,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleTask#L408-L429","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":408,"end_line":429,"context_start_line":388,"context_end_line":449,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleWithReasonTask#L432-L453","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":432,"end_line":453,"context_start_line":412,"context_end_line":473,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleTask#L456-L477","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":456,"end_line":477,"context_start_line":436,"context_end_line":497,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadMiniInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_IPAD_PRO_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask#L480-L508","kind":"class","name":"DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":480,"end_line":508,"context_start_line":460,"context_end_line":528,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_IPAD_PRO_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadProTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad pro\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleWithReasonTask#L511-L532","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":511,"end_line":532,"context_start_line":491,"context_end_line":552,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadProTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad pro\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleTask#L535-L556","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":535,"end_line":556,"context_start_line":515,"context_end_line":576,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleWithReasonTask#L559-L580","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":559,"end_line":580,"context_start_line":539,"context_end_line":600,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleTask#L583-L604","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":583,"end_line":604,"context_start_line":563,"context_end_line":624,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleWithReasonTask#L607-L628","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":607,"end_line":628,"context_start_line":587,"context_end_line":648,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleTask#L631-L652","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":631,"end_line":652,"context_start_line":611,"context_end_line":672,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleWithReasonTask#L655-L676","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":655,"end_line":676,"context_start_line":635,"context_end_line":696,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleTask#L679-L700","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":679,"end_line":700,"context_start_line":659,"context_end_line":720,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadProInfeasibleTask(\n DashboardRetrieveCatalogAndOrderiPadProInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_SALES_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask#L703-L731","kind":"class","name":"DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":703,"end_line":731,"context_start_line":683,"context_end_line":751,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_SALES_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderSalesLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Sales Laptop\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleWithReasonTask#L734-L755","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":734,"end_line":755,"context_start_line":714,"context_end_line":775,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderSalesLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Sales Laptop\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleTask#L758-L779","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":758,"end_line":779,"context_start_line":738,"context_end_line":799,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleWithReasonTask#L782-L803","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":782,"end_line":803,"context_start_line":762,"context_end_line":823,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleTask#L806-L827","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":806,"end_line":827,"context_start_line":786,"context_end_line":847,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleWithReasonTask#L830-L851","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":830,"end_line":851,"context_start_line":810,"context_end_line":871,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleTask#L854-L875","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":854,"end_line":875,"context_start_line":834,"context_end_line":895,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleWithReasonTask#L878-L899","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":878,"end_line":899,"context_start_line":858,"context_end_line":919,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleTask#L902-L923","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":902,"end_line":923,"context_start_line":882,"context_end_line":943,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderSalesLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask#L926-L954","kind":"class","name":"DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":926,"end_line":954,"context_start_line":906,"context_end_line":974,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderStandardLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Standard Laptop\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleWithReasonTask#L957-L978","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":957,"end_line":978,"context_start_line":937,"context_end_line":998,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderStandardLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Standard Laptop\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleTask#L981-L1002","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":981,"end_line":1002,"context_start_line":961,"context_end_line":1022,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleWithReasonTask#L1005-L1026","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1005,"end_line":1026,"context_start_line":985,"context_end_line":1046,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleTask#L1029-L1050","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1029,"end_line":1050,"context_start_line":1009,"context_end_line":1070,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleWithReasonTask#L1053-L1074","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1053,"end_line":1074,"context_start_line":1033,"context_end_line":1094,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleTask#L1077-L1098","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1077,"end_line":1098,"context_start_line":1057,"context_end_line":1118,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleWithReasonTask#L1101-L1122","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1101,"end_line":1122,"context_start_line":1081,"context_end_line":1142,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleTask#L1125-L1146","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1125,"end_line":1146,"context_start_line":1105,"context_end_line":1166,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderStandardLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask#L1149-L1177","kind":"class","name":"DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1149,"end_line":1177,"context_start_line":1129,"context_end_line":1197,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleWatchTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple Watch\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleWithReasonTask#L1180-L1201","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1180,"end_line":1201,"context_start_line":1160,"context_end_line":1221,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleWatchTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple Watch\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleTask#L1204-L1225","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1204,"end_line":1225,"context_start_line":1184,"context_end_line":1245,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleWithReasonTask#L1228-L1249","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1228,"end_line":1249,"context_start_line":1208,"context_end_line":1269,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleTask#L1252-L1273","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1252,"end_line":1273,"context_start_line":1232,"context_end_line":1293,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleWithReasonTask#L1276-L1297","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1276,"end_line":1297,"context_start_line":1256,"context_end_line":1317,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleTask#L1300-L1321","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1300,"end_line":1321,"context_start_line":1280,"context_end_line":1341,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleWithReasonTask#L1324-L1345","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1324,"end_line":1345,"context_start_line":1304,"context_end_line":1365,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleTask#L1348-L1369","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1348,"end_line":1369,"context_start_line":1328,"context_end_line":1389,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleWatchInfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleWatchInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask#L1372-L1400","kind":"class","name":"DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1372,"end_line":1400,"context_start_line":1352,"context_end_line":1420,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleMacBookPro15Task\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple MacBook Pro 15\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleWithReasonTask#L1403-L1424","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1403,"end_line":1424,"context_start_line":1383,"context_end_line":1444,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleMacBookPro15Task\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple MacBook Pro 15\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleTask#L1427-L1448","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1427,"end_line":1448,"context_start_line":1407,"context_end_line":1468,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleWithReasonTask#L1451-L1472","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1451,"end_line":1472,"context_start_line":1431,"context_end_line":1492,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleTask#L1475-L1496","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1475,"end_line":1496,"context_start_line":1455,"context_end_line":1516,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleWithReasonTask#L1499-L1520","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1499,"end_line":1520,"context_start_line":1479,"context_end_line":1540,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleTask#L1523-L1544","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1523,"end_line":1544,"context_start_line":1503,"context_end_line":1564,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleWithReasonTask#L1547-L1568","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1547,"end_line":1568,"context_start_line":1527,"context_end_line":1588,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleTask#L1571-L1592","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1571,"end_line":1592,"context_start_line":1551,"context_end_line":1612,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15InfeasibleTask(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15InfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask#L1595-L1623","kind":"class","name":"DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1595,"end_line":1623,"context_start_line":1575,"context_end_line":1643,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDevelopmentLaptopPCTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Development Laptop (PC)\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleWithReasonTask#L1626-L1647","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1626,"end_line":1647,"context_start_line":1606,"context_end_line":1667,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDevelopmentLaptopPCTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Development Laptop (PC)\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleTask#L1650-L1671","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1650,"end_line":1671,"context_start_line":1630,"context_end_line":1691,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleWithReasonTask#L1674-L1695","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1674,"end_line":1695,"context_start_line":1654,"context_end_line":1715,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleTask#L1698-L1719","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1698,"end_line":1719,"context_start_line":1678,"context_end_line":1739,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleWithReasonTask#L1722-L1743","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1722,"end_line":1743,"context_start_line":1702,"context_end_line":1763,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleTask#L1746-L1767","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1746,"end_line":1767,"context_start_line":1726,"context_end_line":1787,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleWithReasonTask#L1770-L1791","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1770,"end_line":1791,"context_start_line":1750,"context_end_line":1811,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleTask#L1794-L1815","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1794,"end_line":1815,"context_start_line":1774,"context_end_line":1835,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCInfeasibleTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask#L1818-L1846","kind":"class","name":"DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1818,"end_line":1846,"context_start_line":1798,"context_end_line":1866,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndDoInfeasibleTask\n):\n config_path = ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH\n\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderLoanerLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Loaner Laptop\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleWithReasonTask#L1849-L1870","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1849,"end_line":1870,"context_start_line":1829,"context_end_line":1890,"code":" dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n provide_reason: bool = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderLoanerLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Loaner Laptop\",\n provide_reason=provide_reason,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleTask#L1873-L1894","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1873,"end_line":1894,"context_start_line":1853,"context_end_line":1914,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleWithReasonTask#L1897-L1918","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1897,"end_line":1918,"context_start_line":1877,"context_end_line":1938,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleTask#L1921-L1942","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1921,"end_line":1942,"context_start_line":1901,"context_end_line":1962,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleWithReasonTask#L1945-L1966","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1945,"end_line":1966,"context_start_line":1925,"context_end_line":1986,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleTask#L1969-L1990","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1969,"end_line":1990,"context_start_line":1949,"context_end_line":2010,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleWithReasonTask#L1993-L2014","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1993,"end_line":2014,"context_start_line":1973,"context_end_line":2034,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n provide_reason=False,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleWithReasonTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleTask#L2017-L2038","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":2017,"end_line":2038,"context_start_line":1997,"context_end_line":2047,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_catalog_infeasible.__init__#L2020-L2038","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":2020,"end_line":2038,"context_start_line":2000,"context_end_line":2047,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderLoanerLaptopInfeasibleTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_catalog#L1-L1127","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_catalog","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":1,"end_line":1127,"context_start_line":1,"context_end_line":1127,"code":"from .dash_do_base import DashboardRetrieveCatalogAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\n\nclass DashboardRetrieveCatalogAndOrderDeveloperLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDeveloperLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Developer Laptop (Mac)\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadMiniTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadMiniTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad mini\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadProTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadProTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad pro\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderSalesLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderSalesLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Sales Laptop\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderStandardLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderStandardLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Standard Laptop\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleWatchTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleWatchTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple Watch\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOr\n# ... truncated ...","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderDeveloperLaptopTask#L21-L43","kind":"class","name":"DashboardRetrieveCatalogAndOrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":21,"end_line":43,"context_start_line":1,"context_end_line":63,"code":"from .dash_do_base import DashboardRetrieveCatalogAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\n\nclass DashboardRetrieveCatalogAndOrderDeveloperLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDeveloperLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Developer Laptop (Mac)\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopTask#L46-L66","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":46,"end_line":66,"context_start_line":26,"context_end_line":86,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDeveloperLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Developer Laptop (Mac)\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopTask#L69-L89","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":69,"end_line":89,"context_start_line":49,"context_end_line":109,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopTask#L92-L112","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":92,"end_line":112,"context_start_line":72,"context_end_line":132,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderDeveloperLaptopTask#L115-L135","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":115,"end_line":135,"context_start_line":95,"context_end_line":155,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDeveloperLaptopTask(\n DashboardRetrieveCatalogAndOrderDeveloperLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadMiniTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadMiniTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderiPadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderiPadMiniTask#L138-L160","kind":"class","name":"DashboardRetrieveCatalogAndOrderiPadMiniTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":138,"end_line":160,"context_start_line":118,"context_end_line":180,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadMiniTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadMiniTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad mini\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderiPadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderiPadMiniTask#L163-L183","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderiPadMiniTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":163,"end_line":183,"context_start_line":143,"context_end_line":203,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadMiniTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad mini\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderiPadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderiPadMiniTask#L186-L206","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderiPadMiniTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":186,"end_line":206,"context_start_line":166,"context_end_line":226,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderiPadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderiPadMiniTask#L209-L229","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderiPadMiniTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":209,"end_line":229,"context_start_line":189,"context_end_line":249,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderiPadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderiPadMiniTask#L232-L252","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderiPadMiniTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":232,"end_line":252,"context_start_line":212,"context_end_line":272,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadMiniTask(\n DashboardRetrieveCatalogAndOrderiPadMiniTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadProTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadProTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderiPadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderiPadProTask#L255-L277","kind":"class","name":"DashboardRetrieveCatalogAndOrderiPadProTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":255,"end_line":277,"context_start_line":235,"context_end_line":297,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderiPadProTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadProTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad pro\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderiPadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderiPadProTask#L280-L300","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderiPadProTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":280,"end_line":300,"context_start_line":260,"context_end_line":320,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderIpadProTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"iPad pro\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderiPadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderiPadProTask#L303-L323","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderiPadProTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":303,"end_line":323,"context_start_line":283,"context_end_line":343,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderiPadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderiPadProTask#L326-L346","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderiPadProTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":326,"end_line":346,"context_start_line":306,"context_end_line":366,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderiPadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderiPadProTask#L349-L369","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderiPadProTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":349,"end_line":369,"context_start_line":329,"context_end_line":389,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderiPadProTask(\n DashboardRetrieveCatalogAndOrderiPadProTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderSalesLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderSalesLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderSalesLaptopTask#L372-L394","kind":"class","name":"DashboardRetrieveCatalogAndOrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":372,"end_line":394,"context_start_line":352,"context_end_line":414,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderSalesLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderSalesLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Sales Laptop\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderSalesLaptopTask#L397-L417","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":397,"end_line":417,"context_start_line":377,"context_end_line":437,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderSalesLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Sales Laptop\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderSalesLaptopTask#L420-L440","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":420,"end_line":440,"context_start_line":400,"context_end_line":460,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderSalesLaptopTask#L443-L463","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":443,"end_line":463,"context_start_line":423,"context_end_line":483,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderSalesLaptopTask#L466-L486","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":466,"end_line":486,"context_start_line":446,"context_end_line":506,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderSalesLaptopTask(\n DashboardRetrieveCatalogAndOrderSalesLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderStandardLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderStandardLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderStandardLaptopTask#L489-L511","kind":"class","name":"DashboardRetrieveCatalogAndOrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":489,"end_line":511,"context_start_line":469,"context_end_line":531,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderStandardLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderStandardLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Standard Laptop\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderStandardLaptopTask#L514-L534","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":514,"end_line":534,"context_start_line":494,"context_end_line":554,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderStandardLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Standard Laptop\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderStandardLaptopTask#L537-L557","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":537,"end_line":557,"context_start_line":517,"context_end_line":577,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderStandardLaptopTask#L560-L580","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":560,"end_line":580,"context_start_line":540,"context_end_line":600,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderStandardLaptopTask#L583-L603","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":583,"end_line":603,"context_start_line":563,"context_end_line":623,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderStandardLaptopTask(\n DashboardRetrieveCatalogAndOrderStandardLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleWatchTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleWatchTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderAppleWatchTask#L606-L628","kind":"class","name":"DashboardRetrieveCatalogAndOrderAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":606,"end_line":628,"context_start_line":586,"context_end_line":648,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleWatchTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleWatchTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple Watch\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderAppleWatchTask#L631-L651","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":631,"end_line":651,"context_start_line":611,"context_end_line":671,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleWatchTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple Watch\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderAppleWatchTask#L654-L674","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":654,"end_line":674,"context_start_line":634,"context_end_line":694,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderAppleWatchTask#L677-L697","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":677,"end_line":697,"context_start_line":657,"context_end_line":717,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = 0,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderAppleWatchTask#L700-L720","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":700,"end_line":720,"context_start_line":680,"context_end_line":740,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleWatchTask(\n DashboardRetrieveCatalogAndOrderAppleWatchTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = 0,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleMacBookPro15Task\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task#L723-L745","kind":"class","name":"DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":723,"end_line":745,"context_start_line":703,"context_end_line":765,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = 0,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleMacBookPro15Task\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple MacBook Pro 15\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15Task(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15Task#L748-L768","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":748,"end_line":768,"context_start_line":728,"context_end_line":788,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderAppleMacBookPro15Task\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Apple MacBook Pro 15\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15Task(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15Task(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15Task#L771-L791","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":771,"end_line":791,"context_start_line":751,"context_end_line":811,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderAppleMacbookPro15Task(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15Task(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15Task#L794-L814","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":794,"end_line":814,"context_start_line":774,"context_end_line":834,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderAppleMacbookPro15Task(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15Task(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15Task#L817-L837","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":817,"end_line":837,"context_start_line":797,"context_end_line":857,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderAppleMacbookPro15Task(\n DashboardRetrieveCatalogAndOrderAppleMacbookPro15Task, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDevelopmentLaptopPCTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask#L840-L862","kind":"class","name":"DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":840,"end_line":862,"context_start_line":820,"context_end_line":882,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDevelopmentLaptopPCTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Development Laptop (PC)\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCTask#L865-L885","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":865,"end_line":885,"context_start_line":845,"context_end_line":905,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderDevelopmentLaptopPCTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Development Laptop (PC)\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCTask#L888-L908","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":888,"end_line":908,"context_start_line":868,"context_end_line":928,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderDevelopmentLaptopPCTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCTask#L911-L931","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":911,"end_line":931,"context_start_line":891,"context_end_line":951,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderDevelopmentLaptopPCTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCTask#L934-L954","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":934,"end_line":954,"context_start_line":914,"context_end_line":974,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderDevelopmentLaptopPCTask(\n DashboardRetrieveCatalogAndOrderDevelopmentLaptopPCTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderLoanerLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderLoanerLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndOrderLoanerLaptopTask#L957-L979","kind":"class","name":"DashboardRetrieveCatalogAndOrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":957,"end_line":979,"context_start_line":937,"context_end_line":999,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nclass DashboardRetrieveCatalogAndOrderLoanerLaptopTask(DashboardRetrieveCatalogAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderLoanerLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Loaner Laptop\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMaxOrderLoanerLaptopTask#L982-L1002","kind":"class","name":"DashboardRetrieveCatalogAndMaxOrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":982,"end_line":1002,"context_start_line":962,"context_end_line":1022,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n dashboard_class: AbstractServiceNowTask = SingleChartMinMaxRetrievalTask,\n question: str = None,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n self.order_item_class = OrderLoanerLaptopTask\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=dashboard_class,\n question=question,\n min_catalog_item=\"Loaner Laptop\",\n )\n\n\nclass DashboardRetrieveCatalogAndMaxOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMeanOrderLoanerLaptopTask#L1005-L1025","kind":"class","name":"DashboardRetrieveCatalogAndMeanOrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":1005,"end_line":1025,"context_start_line":985,"context_end_line":1045,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMinMaxRetrievalTask,\n question=\"max\",\n )\n\n\nclass DashboardRetrieveCatalogAndMeanOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndMedianOrderLoanerLaptopTask#L1028-L1048","kind":"class","name":"DashboardRetrieveCatalogAndMedianOrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":1028,"end_line":1048,"context_start_line":1008,"context_end_line":1068,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mean\",\n )\n\n\nclass DashboardRetrieveCatalogAndMedianOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_catalog.DashboardRetrieveCatalogAndModeOrderLoanerLaptopTask#L1051-L1071","kind":"class","name":"DashboardRetrieveCatalogAndModeOrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":1051,"end_line":1071,"context_start_line":1031,"context_end_line":1091,"code":" def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_AND_ORDER = [\n DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopTask,\n DashboardRetrieveCatalogAndMaxOrderiPadMiniTask,\n DashboardRetrieveCatalogAndMaxOrderiPadProTask,\n DashboardRetrieveCatalogAndMaxOrderSalesLaptopTask,\n DashboardRetrieveCatalogAndMaxOrderStandardLaptopTask,\n DashboardRetrieveCatalogAndMaxOrderAppleWatchTask,\n DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15Task,\n DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCTask,\n DashboardRetrieveCatalogAndMaxOrderLoanerLaptopTask,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_catalog.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_catalog.__init__#L1054-L1071","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":1054,"end_line":1071,"context_start_line":1034,"context_end_line":1091,"code":" seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"median\",\n )\n\n\nclass DashboardRetrieveCatalogAndModeOrderLoanerLaptopTask(\n DashboardRetrieveCatalogAndOrderLoanerLaptopTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve information based on incidents from the dashboard and do the task.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n question=\"mode\",\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_AND_ORDER = [\n DashboardRetrieveCatalogAndMaxOrderDeveloperLaptopTask,\n DashboardRetrieveCatalogAndMaxOrderiPadMiniTask,\n DashboardRetrieveCatalogAndMaxOrderiPadProTask,\n DashboardRetrieveCatalogAndMaxOrderSalesLaptopTask,\n DashboardRetrieveCatalogAndMaxOrderStandardLaptopTask,\n DashboardRetrieveCatalogAndMaxOrderAppleWatchTask,\n DashboardRetrieveCatalogAndMaxOrderAppleMacbookPro15Task,\n DashboardRetrieveCatalogAndMaxOrderDevelopmentLaptopPCTask,\n DashboardRetrieveCatalogAndMaxOrderLoanerLaptopTask,","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible#L1-L278","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":1,"end_line":278,"context_start_line":1,"context_end_line":278,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateIncidentTask\n\n\nclass DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n provide_reason: bool = True,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n self.task_description = \"\"\n self.short_description = (\n \"Create an incident for the worst performing employee from the list.\"\n )\n self.filter_than = \"lesser\"\n self.attribute_name = \"assigned_to\"\n self.prefix = \"ICI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n base_user = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n },\n )[\"result\"][0]\n self.user_name = base_user[\"first_name\"] + \" \" + base_user[\"last_name\"]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n incident_numbers = []\n for _ in range(len(agent_full_names)):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n while (\n incident_number in self.all_incident_numbers or incident_number in incident_numbers\n ):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n incident_numbers.append(incident_number)\n\n self.incident_numbers = incident_numbers\n\n create_incident_subtasks = []\n\n for agent_full_name, incident_number in zip(agent_full_names, incident_numbers):\n incident_config = {\n \"fields\": {\n \"caller_id\": \"Caller\",\n \"category\": \"Category\",\n \"description\": \"Description\",\n \"short_description\": \"Short description\",\n \"impact\": \"Impact\",\n \"number\": \"Number\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n },\n \"task_fields\": [\n \"caller_id\",\n \"category\",\n \"description\",\n \"short_description\",\n \"impact\",\n \"number\",\n \"urgency\",\n \"assigned_to\",\n ],\n \"template_record\": {\n \"caller_id\": self.user_name,\n \"category\": \"Inquiry / Help\",\n \"description\": \"Compulsory training for employee in probation\",\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1 - High\",\n \"number\": incident_number,\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n \"infeasible_task_fields\": [\n \"category\",\n \"description\",\n \"short_description\",\n \"impact\",\n \"number\",\n ],\n }\n\n incident_config, self.infeasible_reasons = self.function(\n config=incident_config, random=self.random\n )\n\n create_incident_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n # Create an incident\n CreateIncidentTask(\n instance=self.instance,\n fixed_config=incident_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n has_description=True,\n ),\n ]\n create_incident_subtasks += create_incident_subtask\n\n self.compositional_task = create_incident_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n incident_numbers_string = \", \".join(self.incident_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create incidents with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'.\\n\"\n + f\"Assign the incidents you create to the agents mentioned above. You can use the incident numbers: {incident_numbers_string}, one for each.\"\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the agents with number of incidents less than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"\\n3. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\n4. Create new incidents with the following field values:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation' and assign them to each of the agents. You will create as many incidents as there are agents.\\n\"\n + f\"\\nYou should use the following incident numbers for each incident (one for each): {incident_numbers_string}.\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )\n\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleTask(\n DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask#L18-L209","kind":"class","name":"DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":18,"end_line":209,"context_start_line":1,"context_end_line":229,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateIncidentTask\n\n\nclass DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n provide_reason: bool = True,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n self.task_description = \"\"\n self.short_description = (\n \"Create an incident for the worst performing employee from the list.\"\n )\n self.filter_than = \"lesser\"\n self.attribute_name = \"assigned_to\"\n self.prefix = \"ICI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n base_user = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n },\n )[\"result\"][0]\n self.user_name = base_user[\"first_name\"] + \" \" + base_user[\"last_name\"]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n incident_numbers = []\n for _ in range(len(agent_full_names)):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n while (\n incident_number in self.all_incident_numbers or incident_number in incident_numbers\n ):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n incident_numbers.append(incident_number)\n\n self.incident_numbers = incident_numbers\n\n create_incident_subtasks = []\n\n for agent_full_name, incident_number in zip(agent_full_names, incident_numbers):\n incident_config = {\n \"fields\": {\n \"caller_id\": \"Caller\",\n \"category\": \"Category\",\n \"description\": \"Description\",\n \"short_description\": \"Short description\",\n \"impact\": \"Impact\",\n \"number\": \"Number\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n },\n \"task_fields\": [\n \"caller_id\",\n \"category\",\n \"description\",\n \"short_description\",\n \"impact\",\n \"number\",\n \"urgency\",\n \"assigned_to\",\n ],\n \"template_record\": {\n \"caller_id\": self.user_name,\n \"category\": \"Inquiry / Help\",\n \"description\": \"Compulsory training for employee in probation\",\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1 - High\",\n \"number\": incident_number,\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n \"infeasible_task_fields\": [\n \"category\",\n \"description\",\n \"short_description\",\n \"impact\",\n \"number\",\n ],\n }\n\n incident_config, self.infeasible_reasons = self.function(\n config=incident_config, random=self.random\n )\n\n create_incident_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n # Create an incident\n CreateIncidentTask(\n instance=self.instance,\n fixed_config=incident_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n has_description=True,\n ),\n ]\n create_incident_subtasks += create_incident_subtask\n\n self.compositional_task = create_incident_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n incident_numbers_string = \", \".join(self.incident_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create incidents with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'.\\n\"\n + f\"Assign the incidents you create to the agents mentioned above. You can use the incident numbers: {incident_numbers_string}, one for each.\"\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the agents with number of incidents less than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"\\n3. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\n4. Create new incidents with the following field values:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation' and assign them to each of the agents. You will create as many incidents as there are agents.\\n\"\n + f\"\\nYou should use the following incident numbers for each incident (one for each): {incident_numbers_string}.\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )\n\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleWithReasonTask#L212-L239","kind":"class","name":"DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":212,"end_line":239,"context_start_line":192,"context_end_line":259,"code":" instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )\n\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleTask(\n DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleTask#L242-L269","kind":"class","name":"DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":242,"end_line":269,"context_start_line":222,"context_end_line":278,"code":" \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleTask(\n DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.__init__#L245-L269","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":245,"end_line":269,"context_start_line":225,"context_end_line":278,"code":" -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=True,\n )\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleTask(\n DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n provide_reason=False,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.set_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.set_compositional_task#L58-L156","kind":"function","name":"set_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":58,"end_line":156,"context_start_line":38,"context_end_line":176,"code":" A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n function=get_infeasible_form_config,\n provide_reason=provide_reason,\n )\n self.task_description = \"\"\n self.short_description = (\n \"Create an incident for the worst performing employee from the list.\"\n )\n self.filter_than = \"lesser\"\n self.attribute_name = \"assigned_to\"\n self.prefix = \"ICI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n base_user = table_api_call(\n instance=self.instance,\n table=\"sys_user\",\n params={\n \"sysparm_query\": f\"sys_id={self._base_user_sysid}\",\n },\n )[\"result\"][0]\n self.user_name = base_user[\"first_name\"] + \" \" + base_user[\"last_name\"]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n incident_numbers = []\n for _ in range(len(agent_full_names)):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n while (\n incident_number in self.all_incident_numbers or incident_number in incident_numbers\n ):\n incident_number = \"INC\" + str(random.randint(1000000, 9999999))\n incident_numbers.append(incident_number)\n\n self.incident_numbers = incident_numbers\n\n create_incident_subtasks = []\n\n for agent_full_name, incident_number in zip(agent_full_names, incident_numbers):\n incident_config = {\n \"fields\": {\n \"caller_id\": \"Caller\",\n \"category\": \"Category\",\n \"description\": \"Description\",\n \"short_description\": \"Short description\",\n \"impact\": \"Impact\",\n \"number\": \"Number\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n },\n \"task_fields\": [\n \"caller_id\",\n \"category\",\n \"description\",\n \"short_description\",\n \"impact\",\n \"number\",\n \"urgency\",\n \"assigned_to\",\n ],\n \"template_record\": {\n \"caller_id\": self.user_name,\n \"category\": \"Inquiry / Help\",\n \"description\": \"Compulsory training for employee in probation\",\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1 - High\",\n \"number\": incident_number,\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n \"infeasible_task_fields\": [\n \"category\",\n \"description\",\n \"short_description\",\n \"impact\",\n \"number\",\n ],\n }\n\n incident_config, self.infeasible_reasons = self.function(\n config=incident_config, random=self.random\n )\n\n create_incident_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n # Create an incident\n CreateIncidentTask(\n instance=self.instance,\n fixed_config=incident_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n has_description=True,\n ),\n ]\n create_incident_subtasks += create_incident_subtask\n\n self.compositional_task = create_incident_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n incident_numbers_string = \", \".join(self.incident_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create incidents with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'.\\n\"\n + f\"Assign the incidents you create to the agents mentioned above. You can use the incident numbers: {incident_numbers_string}, one for each.\"\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.setup_goal#L158-L187","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":158,"end_line":187,"context_start_line":138,"context_end_line":207,"code":" \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n has_description=False,\n ),\n # Create an incident\n CreateIncidentTask(\n instance=self.instance,\n fixed_config=incident_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n has_description=True,\n ),\n ]\n create_incident_subtasks += create_incident_subtask\n\n self.compositional_task = create_incident_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n incident_numbers_string = \", \".join(self.incident_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Less than or equal to the value.\\n\"\n + f\"Task: Create incidents with the following information: \\n\"\n + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'.\\n\"\n + f\"Assign the incidents you create to the agents mentioned above. You can use the incident numbers: {incident_numbers_string}, one for each.\"\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the agents with number of incidents less than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"\\n3. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\n4. Create new incidents with the following field values:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation' and assign them to each of the agents. You will create as many incidents as there are agents.\\n\"\n + f\"\\nYou should use the following incident numbers for each incident (one for each): {incident_numbers_string}.\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_incident_infeasible.teardown#L189-L209","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":189,"end_line":209,"context_start_line":169,"context_end_line":229,"code":" + f\"Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'.\\n\"\n + f\"Assign the incidents you create to the agents mentioned above. You can use the incident numbers: {incident_numbers_string}, one for each.\"\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n goal = (\n self.task_description\n + f\"\\n1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \\n\"\n + f\"\\n2. Find the agents with number of incidents less than or equal to the {self.description_mapping[self.question]} of the incidents assigned to every one. \\n\"\n + f\"\\n3. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\n4. Create new incidents with the following field values:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation' and assign them to each of the agents. You will create as many incidents as there are agents.\\n\"\n + f\"\\nYou should use the following incident numbers for each incident (one for each): {incident_numbers_string}.\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n for incident_number in self.incident_numbers:\n created_incident_response = table_api_call(\n instance=self.instance,\n table=\"incident\",\n params={\n \"sysparm_query\": f\"number={incident_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_incident_response) > 1:\n raise Exception(\"Multiple incidents created\")\n if len(created_incident_response) == 1:\n created_incident_sysid = created_incident_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"incident\",\n sys_id=created_incident_sysid,\n )\n\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateIncidentInfeasibleWithReasonTask(\n DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 3,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create an incident to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create an incident for the worst performing employee from the list\"","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.filter_and_do","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.filter_and_do#L1-L139","kind":"module","name":"src.browsergym.workarena.tasks.compositional.filter_and_do","path":"src/browsergym/workarena/tasks/compositional/filter_and_do.py","language":"python","start_line":1,"end_line":139,"context_start_line":1,"context_end_line":139,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom browsergym.workarena.tasks.list import FilterListTask\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\n\nfrom .base import CompositionalTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...instance import SNowInstance\n\n\nclass FilterAndDoTask(CompositionalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n navigation_config: dict = None,\n protocol_name: str = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Generic task to navigate to a specific page, run a filter and perform a task.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n navigation_config: dict\n Configuration to use for the navigation to the list that will be filtered. Contains application and module.\n URL is not necessary as the navigation steps are not validated\n protocol_name: str\n The name of the protocol to refer to in the task description for L3.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n\n Attributes:\n -----------\n filter_config: dict\n Configuration to use for the filter that will be applied to the list. Contains filter_columns, filter_values and filter_kind in addition to the path to the expected fields in the list.\n this is set by the _setup_list method.\n tasks: List[AbstractServiceNowTask]\n The tasks to perform after having filtered the list. Set by the child setup\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.navigation_config = navigation_config\n self.filter_config = None\n self.protocol_name = protocol_name\n self.task_description = None\n self.short_description = None\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"Used to create the necessary records in the list + setting up the list filter attribute before filtering it.\"\"\"\n raise NotImplementedError\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self._setup_list()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n list_url = self.filter_config[\"list_url\"]\n\n navigate_to_protocol_config = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n config = [\n # Navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the the list; the config it uses is set by the _setup_list method\n FilterListTask(\n instance=self.instance,\n list_url=list_url,\n fixed_config=self.filter_config,\n expected_fields_path=self.filter_config[\"expected_fields_path\"],\n is_validated=False,\n used_in_level_2=True,\n ),\n ] + self.tasks\n\n # To support the option of having no protocol\n if self.protocol_name:\n config = navigate_to_protocol_config + config\n\n return config","source_hash":"3c742a70117463a5777dc98a2235c9d00afd493bb98ab5d0bd6a4a14ed955c71","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.filter_and_do.FilterAndDoTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.filter_and_do.FilterAndDoTask#L18-L139","kind":"class","name":"FilterAndDoTask","path":"src/browsergym/workarena/tasks/compositional/filter_and_do.py","language":"python","start_line":18,"end_line":139,"context_start_line":1,"context_end_line":139,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom browsergym.workarena.tasks.list import FilterListTask\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\n\nfrom .base import CompositionalTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...instance import SNowInstance\n\n\nclass FilterAndDoTask(CompositionalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n navigation_config: dict = None,\n protocol_name: str = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Generic task to navigate to a specific page, run a filter and perform a task.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n navigation_config: dict\n Configuration to use for the navigation to the list that will be filtered. Contains application and module.\n URL is not necessary as the navigation steps are not validated\n protocol_name: str\n The name of the protocol to refer to in the task description for L3.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n\n Attributes:\n -----------\n filter_config: dict\n Configuration to use for the filter that will be applied to the list. Contains filter_columns, filter_values and filter_kind in addition to the path to the expected fields in the list.\n this is set by the _setup_list method.\n tasks: List[AbstractServiceNowTask]\n The tasks to perform after having filtered the list. Set by the child setup\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.navigation_config = navigation_config\n self.filter_config = None\n self.protocol_name = protocol_name\n self.task_description = None\n self.short_description = None\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"Used to create the necessary records in the list + setting up the list filter attribute before filtering it.\"\"\"\n raise NotImplementedError\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self._setup_list()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n list_url = self.filter_config[\"list_url\"]\n\n navigate_to_protocol_config = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n config = [\n # Navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the the list; the config it uses is set by the _setup_list method\n FilterListTask(\n instance=self.instance,\n list_url=list_url,\n fixed_config=self.filter_config,\n expected_fields_path=self.filter_config[\"expected_fields_path\"],\n is_validated=False,\n used_in_level_2=True,\n ),\n ] + self.tasks\n\n # To support the option of having no protocol\n if self.protocol_name:\n config = navigate_to_protocol_config + config\n\n return config","source_hash":"3c742a70117463a5777dc98a2235c9d00afd493bb98ab5d0bd6a4a14ed955c71","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.filter_and_do.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.filter_and_do.__init__#L19-L73","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/filter_and_do.py","language":"python","start_line":19,"end_line":73,"context_start_line":1,"context_end_line":93,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom browsergym.workarena.tasks.list import FilterListTask\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\n\nfrom .base import CompositionalTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...instance import SNowInstance\n\n\nclass FilterAndDoTask(CompositionalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n navigation_config: dict = None,\n protocol_name: str = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Generic task to navigate to a specific page, run a filter and perform a task.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n navigation_config: dict\n Configuration to use for the navigation to the list that will be filtered. Contains application and module.\n URL is not necessary as the navigation steps are not validated\n protocol_name: str\n The name of the protocol to refer to in the task description for L3.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n\n Attributes:\n -----------\n filter_config: dict\n Configuration to use for the filter that will be applied to the list. Contains filter_columns, filter_values and filter_kind in addition to the path to the expected fields in the list.\n this is set by the _setup_list method.\n tasks: List[AbstractServiceNowTask]\n The tasks to perform after having filtered the list. Set by the child setup\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.navigation_config = navigation_config\n self.filter_config = None\n self.protocol_name = protocol_name\n self.task_description = None\n self.short_description = None\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"Used to create the necessary records in the list + setting up the list filter attribute before filtering it.\"\"\"\n raise NotImplementedError\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self._setup_list()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n list_url = self.filter_config[\"list_url\"]\n\n navigate_to_protocol_config = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,","source_hash":"3c742a70117463a5777dc98a2235c9d00afd493bb98ab5d0bd6a4a14ed955c71","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.filter_and_do._setup_list","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.filter_and_do._setup_list#L75-L77","kind":"function","name":"_setup_list","path":"src/browsergym/workarena/tasks/compositional/filter_and_do.py","language":"python","start_line":75,"end_line":77,"context_start_line":55,"context_end_line":97,"code":" The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.navigation_config = navigation_config\n self.filter_config = None\n self.protocol_name = protocol_name\n self.task_description = None\n self.short_description = None\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"Used to create the necessary records in the list + setting up the list filter attribute before filtering it.\"\"\"\n raise NotImplementedError\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self._setup_list()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n list_url = self.filter_config[\"list_url\"]\n\n navigate_to_protocol_config = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",","source_hash":"3c742a70117463a5777dc98a2235c9d00afd493bb98ab5d0bd6a4a14ed955c71","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.filter_and_do.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.filter_and_do.setup_goal#L79-L85","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/filter_and_do.py","language":"python","start_line":79,"end_line":85,"context_start_line":59,"context_end_line":105,"code":" assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.navigation_config = navigation_config\n self.filter_config = None\n self.protocol_name = protocol_name\n self.task_description = None\n self.short_description = None\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"Used to create the necessary records in the list + setting up the list filter attribute before filtering it.\"\"\"\n raise NotImplementedError\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self._setup_list()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n list_url = self.filter_config[\"list_url\"]\n\n navigate_to_protocol_config = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={","source_hash":"3c742a70117463a5777dc98a2235c9d00afd493bb98ab5d0bd6a4a14ed955c71","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.filter_and_do._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.filter_and_do._get_config#L87-L139","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/filter_and_do.py","language":"python","start_line":87,"end_line":139,"context_start_line":67,"context_end_line":139,"code":" self.used_in_level_2 = self.level == 2\n self.navigation_config = navigation_config\n self.filter_config = None\n self.protocol_name = protocol_name\n self.task_description = None\n self.short_description = None\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"Used to create the necessary records in the list + setting up the list filter attribute before filtering it.\"\"\"\n raise NotImplementedError\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self._setup_list()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n list_url = self.filter_config[\"list_url\"]\n\n navigate_to_protocol_config = [\n # Navigate to the KB\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Self-Service\",\n \"module\": \"Knowledge\",\n \"url\": \"/now/nav/ui/classic/params/target/%24knowledge.do\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n # Find the protocol for on-boarding a new user\n KnowledgeBaseSearchTask(\n instance=self.instance,\n fixed_config={\n \"alternative_answers\": [],\n \"item\": f\"{self.protocol_name}\",\n \"question\": f'Can you find the \"{self.protocol_name}\" Protocol in the Knowledge Base?',\n \"value\": \"\",\n },\n is_validated=False,\n used_in_level_2=False,\n ),\n ]\n\n config = [\n # Navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter the the list; the config it uses is set by the _setup_list method\n FilterListTask(\n instance=self.instance,\n list_url=list_url,\n fixed_config=self.filter_config,\n expected_fields_path=self.filter_config[\"expected_fields_path\"],\n is_validated=False,\n used_in_level_2=True,\n ),\n ] + self.tasks\n\n # To support the option of having no protocol\n if self.protocol_name:\n config = navigate_to_protocol_config + config\n\n return config","source_hash":"3c742a70117463a5777dc98a2235c9d00afd493bb98ab5d0bd6a4a14ed955c71","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_filter#L1-L1600","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_filter","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1,"end_line":1600,"context_start_line":1,"context_end_line":1600,"code":"import random\nfrom playwright.sync_api._generated import Page\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterUserListTask,\n)\n\n\nclass DashboardRetrieveIncidentAndFilterListTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a list based on their assignments\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.prefix = \"DIF\"\n\n def get_filter_config(self, attribute_name, filter_than) -> dict:\n filter_values, agent_value_sysids = self.get_agent_values(\n attribute_name=attribute_name, filter_than=filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n if len(filter_values) == 1:\n filter_kind = \"AND\"\n else:\n filter_kind = \"OR\"\n\n filter_config = {\n \"filter_columns\": [self.attribute_name] * len(filter_values),\n \"filter_kind\": filter_kind,\n \"filter_values\": filter_values,\n }\n return filter_config\n\n\nclass DashboardRetrieveIncidentAndFilterAssetListTask(DashboardRetrieveIncidentAndFilterListTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_assets_per_agent: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.max_assets_per_agent = max_assets_per_agent\n self.attribute_name = \"assigned_to\"\n\n def set_compositional_task(self) -> None:\n filter_config = self.get_filter_config(\n attribute_name=self.attribute_name, filter_than=self.filter_than\n )\n\n filter_asset_list_subtask = [\n # Navigate to the asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_asset_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter asset list\n FilterAssetListTask(\n is_validated=True,\n list_name=\"alm_asset\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_asset_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n\n # We create dummy assets for the consumable and license categories here\n ### NOTE: We can create assets without any of the following information, save time, and still assign them to the user. The task should be fine.\n consumable_category_sysid = table_api_call(\n instance=self.instance,\n table=\"cmdb_model_category\",\n method=\"GET\",\n params={\"sysparm_query\": \"asset_class=alm_consumable\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0][\"sys_id\"]\n\n consumables = table_api_call(\n instance=self.instance,\n table=\"cmdb_model\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"cmdb_model_category={consumable_category_sysid}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n consumables_sysids = [consumable[\"sys_id\"] for consumable in consumables]\n\n license_category_sysid = table_api_call(\n instance=self.instance,\n table=\"cmdb_model_category\",\n method=\"GET\",\n params={\"sysparm_query\": \"asset_class=alm_license\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0][\"sys_id\"]\n\n licenses = table_api_call(\n instance=self.instance,\n table=\"cmdb_model\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"cmdb_model_category={license_category_sysid}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"][:10]\n license_sysids = [license[\"sys_id\"] for license in licenses]\n\n self.new_asset_sys_ids = []\n for agent_sysid in self.agent_sysids:\n num_assets = self.random.choice(range(1, self.max_assets_per_agent))\n for _ in range(num_assets):\n consumable_asset_data = {\n \"asset_tag\": \"CONSUMABLE\" + str(random.randint(100, 999)),\n \"model\": self.random.choice(consumables_sysids),\n \"model_category\": consumable_category_sysid,\n \"assigned_to\": agent_sysid,\n \"cost\": 1000.00,\n \"purchase_date\": \"2024-05-08\",\n \"substatus\": \"in_use\",\n }\n response = table_api_call(\n instance=self.instance,\n table=\"alm_asset\",\n json=consumable_asset_data,\n method=\"POST\",\n )\n self.new_asset_sys_ids.append(response[\"result\"][\"sys_id\"])\n license_asset_data = {\n \"asset_tag\": \"LICENSE\" + str(random.randint(100, 999)),\n \"model\": self.random.choice(license_sysids),\n \"model_category\": license_category_sysid,\n \"assigned_to\": agent_sysid,\n \"cost\": 1000.00,\n \"purchase_date\": \"2024-05-08\",\n \"substatus\": \"in_use\",\n }\n response = table_api_call(\n instance=self.instance,\n table=\"alm_asset\",\n json=license_asset_data,\n method=\"POST\",\n )\n self.new_asset_sys_ids.append(response[\"result\"][\"sys_id\"])\n\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the Asset List using the {self.attribute_name} field corresponding to the agents that fit the criteria above. \\n\"\n + f\"The list is present at Portfolios > All Assets. \\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"\\n3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"\\n3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Portfolios > All Assets. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete all assets\n for new_asset_sysid in self.new_asset_sys_ids:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_asset\",\n sys_id=new_asset_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterListTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_assets_per_agent: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.max_assets_per_agent = max_assets_per_agent\n self.attribute_name = \"assigned_to\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n\n def set_compositional_task(self) -> None:\n\n filter_config = self.get_filter_config(\n attribute_name=self.attribute_name, filter_than=self.filter_than\n )\n\n filter_hardware_asset_list_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter hardware list\n FilterHardwareListTask(\n is_validated=True,\n list_name=\"alm_hardware\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_hardware_asset_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n\n hardware_category_sysid = table_api_call(\n instance=self.instance,\n table=\"cmdb_model_category\",\n method=\"GET\",\n params={\"sysparm_query\": \"asset_class=alm_hardware\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0][\"sys_id\"]\n\n hardwares = table_api_call(\n instance=self.instance,\n table=\"cmdb_model\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"cmdb_model_category={hardware_category_sysid}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n hardware_sysids = [hardware[\"sys_id\"] for hardware in hardwares]\n self.new_asset_sysids = []\n for agent_sysid in self.agent_sysids:\n num_assets = self.random.choice(range(1, self.max_assets_per_agent))\n for _ in range(num_assets):\n hardware_asset_data = {\n \"asset_tag\": \"CONSUMABLE\" + str(random.randint(100, 999)),\n \"model\": self.random.choice(hardware_sysids),\n \"model_category\": hardware_category_sysid,\n \"assigned_to\": agent_sysid,\n \"cost\": 1000.00,\n \"purchase_date\": \"2024-05-08\",\n \"substatus\": \"in_use\",\n }\n response = table_api_call(\n instance=self.instance,\n table=\"alm_hardware\",\n json=hardware_asset_data,\n method=\"POST\",\n )\n self.new_asset_sysids.append(response[\"result\"][\"sys_id\"])\n\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the Hardware List using the {self.attribute_name} field corresponding to the agents that fit the criteria above. \\n\"\n + f\"The list is present at Portfolios > Hardware Assets. \\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"\\n3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"\\n3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Portfolios > Hardware Assets. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete all assets\n for new_asset_sysid in self.new_asset_sysids:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_hardware\",\n sys_id=new_asset_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterListTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.attribute_name = \"assigned_to\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n\n def set_compositional_task(self) -> None:\n\n filter_config = self.get_filter_config(\n attribute_name=self.attribute_name, filter_than=self.filter_than\n )\n\n filter_incident_list_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter incident list\n FilterIncidentListTask(\n is_validated=True,\n list_name=\"incident\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_incident_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the Incident\n# ... truncated ...","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterListTask#L21-L65","kind":"class","name":"DashboardRetrieveIncidentAndFilterListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":21,"end_line":65,"context_start_line":1,"context_end_line":85,"code":"import random\nfrom playwright.sync_api._generated import Page\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterUserListTask,\n)\n\n\nclass DashboardRetrieveIncidentAndFilterListTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a list based on their assignments\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.prefix = \"DIF\"\n\n def get_filter_config(self, attribute_name, filter_than) -> dict:\n filter_values, agent_value_sysids = self.get_agent_values(\n attribute_name=attribute_name, filter_than=filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n if len(filter_values) == 1:\n filter_kind = \"AND\"\n else:\n filter_kind = \"OR\"\n\n filter_config = {\n \"filter_columns\": [self.attribute_name] * len(filter_values),\n \"filter_kind\": filter_kind,\n \"filter_values\": filter_values,\n }\n return filter_config\n\n\nclass DashboardRetrieveIncidentAndFilterAssetListTask(DashboardRetrieveIncidentAndFilterListTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_assets_per_agent: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterAssetListTask#L68-L247","kind":"class","name":"DashboardRetrieveIncidentAndFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":68,"end_line":247,"context_start_line":48,"context_end_line":267,"code":" self.prefix = \"DIF\"\n\n def get_filter_config(self, attribute_name, filter_than) -> dict:\n filter_values, agent_value_sysids = self.get_agent_values(\n attribute_name=attribute_name, filter_than=filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n if len(filter_values) == 1:\n filter_kind = \"AND\"\n else:\n filter_kind = \"OR\"\n\n filter_config = {\n \"filter_columns\": [self.attribute_name] * len(filter_values),\n \"filter_kind\": filter_kind,\n \"filter_values\": filter_values,\n }\n return filter_config\n\n\nclass DashboardRetrieveIncidentAndFilterAssetListTask(DashboardRetrieveIncidentAndFilterListTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_assets_per_agent: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.max_assets_per_agent = max_assets_per_agent\n self.attribute_name = \"assigned_to\"\n\n def set_compositional_task(self) -> None:\n filter_config = self.get_filter_config(\n attribute_name=self.attribute_name, filter_than=self.filter_than\n )\n\n filter_asset_list_subtask = [\n # Navigate to the asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_asset_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter asset list\n FilterAssetListTask(\n is_validated=True,\n list_name=\"alm_asset\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_asset_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n\n # We create dummy assets for the consumable and license categories here\n ### NOTE: We can create assets without any of the following information, save time, and still assign them to the user. The task should be fine.\n consumable_category_sysid = table_api_call(\n instance=self.instance,\n table=\"cmdb_model_category\",\n method=\"GET\",\n params={\"sysparm_query\": \"asset_class=alm_consumable\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0][\"sys_id\"]\n\n consumables = table_api_call(\n instance=self.instance,\n table=\"cmdb_model\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"cmdb_model_category={consumable_category_sysid}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n consumables_sysids = [consumable[\"sys_id\"] for consumable in consumables]\n\n license_category_sysid = table_api_call(\n instance=self.instance,\n table=\"cmdb_model_category\",\n method=\"GET\",\n params={\"sysparm_query\": \"asset_class=alm_license\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0][\"sys_id\"]\n\n licenses = table_api_call(\n instance=self.instance,\n table=\"cmdb_model\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"cmdb_model_category={license_category_sysid}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"][:10]\n license_sysids = [license[\"sys_id\"] for license in licenses]\n\n self.new_asset_sys_ids = []\n for agent_sysid in self.agent_sysids:\n num_assets = self.random.choice(range(1, self.max_assets_per_agent))\n for _ in range(num_assets):\n consumable_asset_data = {\n \"asset_tag\": \"CONSUMABLE\" + str(random.randint(100, 999)),\n \"model\": self.random.choice(consumables_sysids),\n \"model_category\": consumable_category_sysid,\n \"assigned_to\": agent_sysid,\n \"cost\": 1000.00,\n \"purchase_date\": \"2024-05-08\",\n \"substatus\": \"in_use\",\n }\n response = table_api_call(\n instance=self.instance,\n table=\"alm_asset\",\n json=consumable_asset_data,\n method=\"POST\",\n )\n self.new_asset_sys_ids.append(response[\"result\"][\"sys_id\"])\n license_asset_data = {\n \"asset_tag\": \"LICENSE\" + str(random.randint(100, 999)),\n \"model\": self.random.choice(license_sysids),\n \"model_category\": license_category_sysid,\n \"assigned_to\": agent_sysid,\n \"cost\": 1000.00,\n \"purchase_date\": \"2024-05-08\",\n \"substatus\": \"in_use\",\n }\n response = table_api_call(\n instance=self.instance,\n table=\"alm_asset\",\n json=license_asset_data,\n method=\"POST\",\n )\n self.new_asset_sys_ids.append(response[\"result\"][\"sys_id\"])\n\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the Asset List using the {self.attribute_name} field corresponding to the agents that fit the criteria above. \\n\"\n + f\"The list is present at Portfolios > All Assets. \\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"\\n3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"\\n3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Portfolios > All Assets. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete all assets\n for new_asset_sysid in self.new_asset_sys_ids:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_asset\",\n sys_id=new_asset_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterListTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_assets_per_agent: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterHardwareListTask#L250-L395","kind":"class","name":"DashboardRetrieveIncidentAndFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":250,"end_line":395,"context_start_line":230,"context_end_line":415,"code":" + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Portfolios > All Assets. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete all assets\n for new_asset_sysid in self.new_asset_sys_ids:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_asset\",\n sys_id=new_asset_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterListTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_assets_per_agent: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.max_assets_per_agent = max_assets_per_agent\n self.attribute_name = \"assigned_to\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n\n def set_compositional_task(self) -> None:\n\n filter_config = self.get_filter_config(\n attribute_name=self.attribute_name, filter_than=self.filter_than\n )\n\n filter_hardware_asset_list_subtask = [\n # Navigate to the hardware asset list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n \"url\": \"/now/nav/ui/classic/params/target/alm_hardware_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter hardware list\n FilterHardwareListTask(\n is_validated=True,\n list_name=\"alm_hardware\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_hardware_asset_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n\n hardware_category_sysid = table_api_call(\n instance=self.instance,\n table=\"cmdb_model_category\",\n method=\"GET\",\n params={\"sysparm_query\": \"asset_class=alm_hardware\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0][\"sys_id\"]\n\n hardwares = table_api_call(\n instance=self.instance,\n table=\"cmdb_model\",\n method=\"GET\",\n params={\n \"sysparm_query\": f\"cmdb_model_category={hardware_category_sysid}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n hardware_sysids = [hardware[\"sys_id\"] for hardware in hardwares]\n self.new_asset_sysids = []\n for agent_sysid in self.agent_sysids:\n num_assets = self.random.choice(range(1, self.max_assets_per_agent))\n for _ in range(num_assets):\n hardware_asset_data = {\n \"asset_tag\": \"CONSUMABLE\" + str(random.randint(100, 999)),\n \"model\": self.random.choice(hardware_sysids),\n \"model_category\": hardware_category_sysid,\n \"assigned_to\": agent_sysid,\n \"cost\": 1000.00,\n \"purchase_date\": \"2024-05-08\",\n \"substatus\": \"in_use\",\n }\n response = table_api_call(\n instance=self.instance,\n table=\"alm_hardware\",\n json=hardware_asset_data,\n method=\"POST\",\n )\n self.new_asset_sysids.append(response[\"result\"][\"sys_id\"])\n\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the Hardware List using the {self.attribute_name} field corresponding to the agents that fit the criteria above. \\n\"\n + f\"The list is present at Portfolios > Hardware Assets. \\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"\\n3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"\\n3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Portfolios > Hardware Assets. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete all assets\n for new_asset_sysid in self.new_asset_sysids:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_hardware\",\n sys_id=new_asset_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterListTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterIncidentListTask#L398-L492","kind":"class","name":"DashboardRetrieveIncidentAndFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":398,"end_line":492,"context_start_line":378,"context_end_line":512,"code":" + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Portfolios > Hardware Assets. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete all assets\n for new_asset_sysid in self.new_asset_sysids:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_hardware\",\n sys_id=new_asset_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterListTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.attribute_name = \"assigned_to\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n\n def set_compositional_task(self) -> None:\n\n filter_config = self.get_filter_config(\n attribute_name=self.attribute_name, filter_than=self.filter_than\n )\n\n filter_incident_list_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n \"url\": \"/now/nav/ui/classic/params/target/incident_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter incident list\n FilterIncidentListTask(\n is_validated=True,\n list_name=\"incident\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_incident_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the Incident List using the {self.attribute_name} field corresponding to the agents that fit the criteria above. \\n\"\n + f\"The list is present at Service Desk > Incidents. \\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"\\n3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"\\n3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n\nclass DashboardRetrieveIncidentAndFilterUserListTask(DashboardRetrieveIncidentAndFilterListTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndFilterUserListTask#L495-L586","kind":"class","name":"DashboardRetrieveIncidentAndFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":495,"end_line":586,"context_start_line":475,"context_end_line":606,"code":" page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"\\n3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"\\n3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Service Desk > Incidents. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n\nclass DashboardRetrieveIncidentAndFilterUserListTask(DashboardRetrieveIncidentAndFilterListTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.attribute_name = \"first_name\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n\n def set_compositional_task(self) -> None:\n filter_config = self.get_filter_config(\n attribute_name=self.attribute_name, filter_than=self.filter_than\n )\n\n filter_user_list_subtask = [\n # Navigate to the user list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter user list\n FilterUserListTask(\n is_validated=True,\n list_name=\"user\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_user_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the User List using the {self.attribute_name} field corresponding to the agents that fit the criteria above. \\n\"\n + f\"The list is present at Organization > Users. \\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Organization > Users. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n\nclass DashboardRetrieveIncidentAndMaxFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMaxFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMaxFilterAssetListTask#L589-L616","kind":"class","name":"DashboardRetrieveIncidentAndMaxFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":589,"end_line":616,"context_start_line":569,"context_end_line":636,"code":" page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Organization > Users. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n\nclass DashboardRetrieveIncidentAndMaxFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMinFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMinFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMinFilterAssetListTask#L619-L646","kind":"class","name":"DashboardRetrieveIncidentAndMinFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":619,"end_line":646,"context_start_line":599,"context_end_line":666,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMinFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanGreaterFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanGreaterFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanGreaterFilterAssetListTask#L649-L676","kind":"class","name":"DashboardRetrieveIncidentAndMeanGreaterFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":649,"end_line":676,"context_start_line":629,"context_end_line":696,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanGreaterFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianGreaterFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianGreaterFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianGreaterFilterAssetListTask#L679-L706","kind":"class","name":"DashboardRetrieveIncidentAndMedianGreaterFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":679,"end_line":706,"context_start_line":659,"context_end_line":726,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianGreaterFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeGreaterFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeGreaterFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeGreaterFilterAssetListTask#L709-L736","kind":"class","name":"DashboardRetrieveIncidentAndModeGreaterFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":709,"end_line":736,"context_start_line":689,"context_end_line":756,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeGreaterFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanLesserFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanLesserFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanLesserFilterAssetListTask#L739-L766","kind":"class","name":"DashboardRetrieveIncidentAndMeanLesserFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":739,"end_line":766,"context_start_line":719,"context_end_line":786,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanLesserFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianLesserFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianLesserFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianLesserFilterAssetListTask#L769-L796","kind":"class","name":"DashboardRetrieveIncidentAndMedianLesserFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":769,"end_line":796,"context_start_line":749,"context_end_line":816,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianLesserFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeLesserFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeLesserFilterAssetListTask#L799-L826","kind":"class","name":"DashboardRetrieveIncidentAndModeLesserFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":799,"end_line":826,"context_start_line":779,"context_end_line":846,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMaxFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMaxFilterHardwareListTask#L829-L856","kind":"class","name":"DashboardRetrieveIncidentAndMaxFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":829,"end_line":856,"context_start_line":809,"context_end_line":876,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMinFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMinFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMinFilterHardwareListTask#L859-L886","kind":"class","name":"DashboardRetrieveIncidentAndMinFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":859,"end_line":886,"context_start_line":839,"context_end_line":906,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMinFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanGreaterFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanGreaterFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanGreaterFilterHardwareListTask#L889-L916","kind":"class","name":"DashboardRetrieveIncidentAndMeanGreaterFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":889,"end_line":916,"context_start_line":869,"context_end_line":936,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanGreaterFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianGreaterFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianGreaterFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianGreaterFilterHardwareListTask#L919-L946","kind":"class","name":"DashboardRetrieveIncidentAndMedianGreaterFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":919,"end_line":946,"context_start_line":899,"context_end_line":966,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianGreaterFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeGreaterFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeGreaterFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeGreaterFilterHardwareListTask#L949-L976","kind":"class","name":"DashboardRetrieveIncidentAndModeGreaterFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":949,"end_line":976,"context_start_line":929,"context_end_line":996,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeGreaterFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanLesserFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanLesserFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanLesserFilterHardwareListTask#L979-L1006","kind":"class","name":"DashboardRetrieveIncidentAndMeanLesserFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":979,"end_line":1006,"context_start_line":959,"context_end_line":1026,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanLesserFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianLesserFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianLesserFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianLesserFilterHardwareListTask#L1009-L1036","kind":"class","name":"DashboardRetrieveIncidentAndMedianLesserFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1009,"end_line":1036,"context_start_line":989,"context_end_line":1056,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianLesserFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeLesserFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeLesserFilterHardwareListTask#L1039-L1066","kind":"class","name":"DashboardRetrieveIncidentAndModeLesserFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1039,"end_line":1066,"context_start_line":1019,"context_end_line":1086,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterHardwareListTask(\n DashboardRetrieveIncidentAndFilterHardwareListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMaxFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMaxFilterIncidentListTask#L1069-L1096","kind":"class","name":"DashboardRetrieveIncidentAndMaxFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1069,"end_line":1096,"context_start_line":1049,"context_end_line":1116,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a hardware list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMinFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMinFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMinFilterIncidentListTask#L1099-L1126","kind":"class","name":"DashboardRetrieveIncidentAndMinFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1099,"end_line":1126,"context_start_line":1079,"context_end_line":1146,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMinFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanGreaterFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanGreaterFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanGreaterFilterIncidentListTask#L1129-L1156","kind":"class","name":"DashboardRetrieveIncidentAndMeanGreaterFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1129,"end_line":1156,"context_start_line":1109,"context_end_line":1176,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanGreaterFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianGreaterFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianGreaterFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianGreaterFilterIncidentListTask#L1159-L1186","kind":"class","name":"DashboardRetrieveIncidentAndMedianGreaterFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1159,"end_line":1186,"context_start_line":1139,"context_end_line":1206,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianGreaterFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeGreaterFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeGreaterFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeGreaterFilterIncidentListTask#L1189-L1216","kind":"class","name":"DashboardRetrieveIncidentAndModeGreaterFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1189,"end_line":1216,"context_start_line":1169,"context_end_line":1236,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeGreaterFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanLesserFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanLesserFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanLesserFilterIncidentListTask#L1219-L1246","kind":"class","name":"DashboardRetrieveIncidentAndMeanLesserFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1219,"end_line":1246,"context_start_line":1199,"context_end_line":1266,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanLesserFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianLesserFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianLesserFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianLesserFilterIncidentListTask#L1249-L1276","kind":"class","name":"DashboardRetrieveIncidentAndMedianLesserFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1249,"end_line":1276,"context_start_line":1229,"context_end_line":1296,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianLesserFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeLesserFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeLesserFilterIncidentListTask#L1279-L1306","kind":"class","name":"DashboardRetrieveIncidentAndModeLesserFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1279,"end_line":1306,"context_start_line":1259,"context_end_line":1326,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterIncidentListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMaxFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMaxFilterUserListTask#L1309-L1336","kind":"class","name":"DashboardRetrieveIncidentAndMaxFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1309,"end_line":1336,"context_start_line":1289,"context_end_line":1356,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter an incident list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMinFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMinFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMinFilterUserListTask#L1339-L1366","kind":"class","name":"DashboardRetrieveIncidentAndMinFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1339,"end_line":1366,"context_start_line":1319,"context_end_line":1386,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMinFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanGreaterFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanGreaterFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanGreaterFilterUserListTask#L1369-L1396","kind":"class","name":"DashboardRetrieveIncidentAndMeanGreaterFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1369,"end_line":1396,"context_start_line":1349,"context_end_line":1416,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = None\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanGreaterFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianGreaterFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianGreaterFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianGreaterFilterUserListTask#L1399-L1426","kind":"class","name":"DashboardRetrieveIncidentAndMedianGreaterFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1399,"end_line":1426,"context_start_line":1379,"context_end_line":1446,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianGreaterFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeGreaterFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeGreaterFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeGreaterFilterUserListTask#L1429-L1456","kind":"class","name":"DashboardRetrieveIncidentAndModeGreaterFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1429,"end_line":1456,"context_start_line":1409,"context_end_line":1476,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeGreaterFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanLesserFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanLesserFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMeanLesserFilterUserListTask#L1459-L1486","kind":"class","name":"DashboardRetrieveIncidentAndMeanLesserFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1459,"end_line":1486,"context_start_line":1439,"context_end_line":1506,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"greater\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanLesserFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianLesserFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianLesserFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndMedianLesserFilterUserListTask#L1489-L1516","kind":"class","name":"DashboardRetrieveIncidentAndMedianLesserFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1489,"end_line":1516,"context_start_line":1469,"context_end_line":1536,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianLesserFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeLesserFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_filter.DashboardRetrieveIncidentAndModeLesserFilterUserListTask#L1519-L1546","kind":"class","name":"DashboardRetrieveIncidentAndModeLesserFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1519,"end_line":1546,"context_start_line":1499,"context_end_line":1566,"code":" \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_COMPUTE_MAX_FILTER_LIST = [\n DashboardRetrieveIncidentAndMaxFilterAssetListTask,\n DashboardRetrieveIncidentAndMaxFilterHardwareListTask,\n DashboardRetrieveIncidentAndMaxFilterIncidentListTask,\n DashboardRetrieveIncidentAndMaxFilterUserListTask,\n]\nDASH_COMPUTE_MIN_FILTER_LIST = [\n DashboardRetrieveIncidentAndMinFilterAssetListTask,\n DashboardRetrieveIncidentAndMinFilterHardwareListTask,\n DashboardRetrieveIncidentAndMinFilterIncidentListTask,","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_filter.__init__#L1522-L1546","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1522,"end_line":1546,"context_start_line":1502,"context_end_line":1566,"code":" -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeLesserFilterUserListTask(\n DashboardRetrieveIncidentAndFilterUserListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.filter_than = \"lesser\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_COMPUTE_MAX_FILTER_LIST = [\n DashboardRetrieveIncidentAndMaxFilterAssetListTask,\n DashboardRetrieveIncidentAndMaxFilterHardwareListTask,\n DashboardRetrieveIncidentAndMaxFilterIncidentListTask,\n DashboardRetrieveIncidentAndMaxFilterUserListTask,\n]\nDASH_COMPUTE_MIN_FILTER_LIST = [\n DashboardRetrieveIncidentAndMinFilterAssetListTask,\n DashboardRetrieveIncidentAndMinFilterHardwareListTask,\n DashboardRetrieveIncidentAndMinFilterIncidentListTask,","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.get_filter_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_filter.get_filter_config#L50-L65","kind":"function","name":"get_filter_config","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":50,"end_line":65,"context_start_line":30,"context_end_line":85,"code":" ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a list based on their assignments\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.prefix = \"DIF\"\n\n def get_filter_config(self, attribute_name, filter_than) -> dict:\n filter_values, agent_value_sysids = self.get_agent_values(\n attribute_name=attribute_name, filter_than=filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n if len(filter_values) == 1:\n filter_kind = \"AND\"\n else:\n filter_kind = \"OR\"\n\n filter_config = {\n \"filter_columns\": [self.attribute_name] * len(filter_values),\n \"filter_kind\": filter_kind,\n \"filter_values\": filter_values,\n }\n return filter_config\n\n\nclass DashboardRetrieveIncidentAndFilterAssetListTask(DashboardRetrieveIncidentAndFilterListTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n max_assets_per_agent: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.set_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_filter.set_compositional_task#L524-L550","kind":"function","name":"set_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":524,"end_line":550,"context_start_line":504,"context_end_line":570,"code":" ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter a user list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Retrieve the best or worst performing agent and filter a user list based on their assignments.\"\n \"\"\"\n self.attribute_name = \"first_name\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n\n def set_compositional_task(self) -> None:\n filter_config = self.get_filter_config(\n attribute_name=self.attribute_name, filter_than=self.filter_than\n )\n\n filter_user_list_subtask = [\n # Navigate to the user list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter user list\n FilterUserListTask(\n is_validated=True,\n list_name=\"user\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_user_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the User List using the {self.attribute_name} field corresponding to the agents that fit the criteria above. \\n\"\n + f\"The list is present at Organization > Users. \\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_filter.setup_goal#L552-L586","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":552,"end_line":586,"context_start_line":532,"context_end_line":606,"code":" instance=self.instance,\n fixed_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n \"url\": \"/now/nav/ui/classic/params/target/sys_user_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Filter user list\n FilterUserListTask(\n is_validated=True,\n list_name=\"user\",\n used_in_level_2=True,\n fixed_config=filter_config,\n ),\n ]\n\n self.compositional_task = filter_user_list_subtask\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n filter_than = f\"{self.filter_than} than or \" if self.filter_than else \"\"\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have {filter_than}equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have {filter_than}equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: Filter the User List using the {self.attribute_name} field corresponding to the agents that fit the criteria above. \\n\"\n + f\"The list is present at Organization > Users. \\n\\n\"\n + self.final_private_task_instructions\n )\n\n goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Organization > Users. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n\nclass DashboardRetrieveIncidentAndMaxFilterAssetListTask(\n DashboardRetrieveIncidentAndFilterAssetListTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an asset list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list based on incidents assigned to an employee\"","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_filter.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_filter.teardown#L387-L395","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":387,"end_line":395,"context_start_line":367,"context_end_line":415,"code":" goal, info = super().setup_goal(\n page=page, config=config, build_pretty_print_description=False\n )\n\n if self.level == 2:\n if self.filter_than:\n step_3 = f\"\\n3. Find the agents with number of incidents {self.filter_than} than or equal to the {self.description_mapping[self.question]} value of the number of incidents assigned across agents. \\n\"\n else:\n step_3 = f\"\\n3. Find the agent with the {self.description_mapping[self.question]} assigned incidents. \\n\"\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + step_3\n + f\"\\n4. Navigate to Portfolios > Hardware Assets. \\n\"\n + f\"\\nUsing the field {self.attribute_name} for the agent/ agents that fit the critera above, filter the list.\\n\"\n )\n\n return goal, info\n\n def teardown(self) -> None:\n # Delete all assets\n for new_asset_sysid in self.new_asset_sysids:\n db_delete_from_table(\n instance=self.instance,\n table=\"alm_hardware\",\n sys_id=new_asset_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndFilterIncidentListTask(\n DashboardRetrieveIncidentAndFilterListTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best or worst performing agent and filter an incident list based on their assignments.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.expense_management#L1-L598","kind":"module","name":"src.browsergym.workarena.tasks.compositional.expense_management","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":1,"end_line":598,"context_start_line":1,"context_end_line":598,"code":"import re\n\nfrom datetime import timedelta\nfrom faker import Faker\nfrom typing import List, Tuple\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import HumanEvalTask\nfrom .delete_record import DeleteExpenseLineExpenseManagementTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.change_request import create_change_request\nfrom ...api.expense_line import create_expense_line\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass ExpenseManagementTask(FilterAndDoTask):\n \"\"\"Task to manage expenses.\n Args:\n\n num_duplicates: int\n The number of duplicate expenses to create\n extra_expenses: int\n The number of extra expenses to create (total expenses will be num_duplicates + extra_expenses)\n goal_type: str\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\".\n - \"base\": one expense is linked to a change request, others are not and are expected to be deleted\n - \"date\": none of the expenses are linked to change requests; the oldest one is expeted to be deleted\n - \"amount\": none of the expenses are linked to change requests and they are all created on the same date;\n the most expensive one is expeted to be deleted\n - \"any\": any of the expenses can be deleted\n \"\"\"\n\n min_allowed_amount = 100\n max_allowed_amount = 10000\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n goal_type: str = \"base\",\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Expense Lines\",\n \"application\": \"Cost\",\n },\n level=level,\n protocol_name=\"Managing Your Existing Expenses\",\n )\n self.num_duplicates = num_duplicates\n self.extra_expenses = extra_expenses\n self.total_expenses = num_duplicates + extra_expenses\n self.goal_type = goal_type\n self.change_request_sysids = []\n\n # mappings between number -> (is_duplicate, sys_id)\n self.expense_lines = {}\n self.expense_to_keep_number = None # The number of the expense that will be kept; i.e. not deleted by the cheat/agent if successful\n\n self.expense_hashtag = \"#SERIES-\" + self.unique_id[:10]\n self.short_description = f\"Managing Your Existing Expenses\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) manage your expenses with short description containing hashtag {self.expense_hashtag}. '\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"The setup might be a bit complex on a first read. To understand it better, refer to the protocol for this task.\"\"\"\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n \"expected_fields_path\": EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.expense_hashtag}\",\n ],\n }\n\n # Short description to use for duplicate expenses\n duplicate_short_description = f\"{fake.sentence(4)}\"\n\n # Set the default amount and date in case uniform_amount and uniform_date are True\n amount = round(self.random.uniform(self.min_allowed_amount, self.max_allowed_amount), 2)\n start_date = fake.date_this_decade(before_today=True, after_today=False)\n date = start_date\n\n most_expensive_amount = float(\"-inf\")\n\n most_expensive_duplicate_expense_number = None\n oldest_duplicate_expense_number = None\n only_expense_with_change_request = None\n # id of expenses will be this id + their order in the creation\n unique_id = str(int(self.unique_id.replace(\"-\", \"\"), 16))[:10]\n for i in range(self.total_expenses):\n expense_number = f\"EXP-{i}{unique_id }\"\n is_duplicate = i < self.num_duplicates\n # set task sys_id to empty string if no change request is created\n task_sys_id = \"\"\n\n # Set a random date between start_date and today\n if self.goal_type in [\"base\", \"date\"] and i > 0:\n date = str(\n fake.date_between(start_date=start_date + timedelta(1), end_date=\"today\")\n )\n else:\n date = start_date\n if i == 0:\n oldest_duplicate_expense_number = expense_number\n\n # In the 'any' case, there are no change requests, all dates are the same and the prices are the same\n if self.goal_type != \"any\":\n amount = round(\n self.random.uniform(self.min_allowed_amount, self.max_allowed_amount), 2\n )\n if is_duplicate and amount > most_expensive_amount:\n most_expensive_amount = amount\n most_expensive_duplicate_expense_number = expense_number\n\n # Create a change request for the base case\n if self.goal_type == \"base\" and i == 0:\n task_sys_id, _ = create_change_request(\n instance=self.instance,\n user_sys_id=self._base_user_sysid,\n hashtag=self.expense_hashtag,\n impact=2,\n risk=2,\n random=self.random,\n )\n self.change_request_sysids.append(task_sys_id)\n only_expense_with_change_request = expense_number\n\n # Set the short description for the duplicate expenses; otherwise pass None, which will generate a random one\n short_description = duplicate_short_description if i < self.num_duplicates else None\n\n expense_sys_id, _ = create_expense_line(\n instance=self.instance,\n amount=amount,\n number=expense_number,\n date=str(date),\n short_description=short_description,\n expense_hashtag=self.expense_hashtag,\n user_sys_id=self._base_user_sysid,\n task_sys_id=task_sys_id,\n )\n self.expense_lines[expense_number] = (is_duplicate, expense_sys_id)\n\n # keep the number of the expense that will be linked to the change request\n if self.goal_type == \"base\":\n self.expense_to_keep_number = only_expense_with_change_request\n # keep the oldest expense\n elif self.goal_type == \"date\":\n self.expense_to_keep_number = oldest_duplicate_expense_number\n elif self.goal_type == \"amount\":\n self.expense_to_keep_number = most_expensive_duplicate_expense_number\n else:\n self.expense_to_keep_number = oldest_duplicate_expense_number\n\n # As the task description redundant, we keep only the first one and skip the rest\n skip_description = False\n # Create the tasks to delete the extra expenses\n for expense_number, (is_duplicate, expense_sys_id) in self.expense_lines.items():\n if expense_number == self.expense_to_keep_number or not is_duplicate:\n continue\n self.tasks.append(\n DeleteExpenseLineExpenseManagementTask(\n instance=self.instance,\n fixed_config={\n \"field_name\": \"number\",\n \"field_value\": f\"{expense_number}\",\n },\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=expense_sys_id,\n record_number=expense_number,\n level=self.level,\n skip_description=skip_description,\n goal_type=self.goal_type,\n )\n )\n skip_description = True\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n # There should remain only one duplicate expense after the task is completed and the extra expenses should reamin\n target_num_expenses = self.extra_expenses + 1\n # Check that only one of the duplicated expenses exists and it is the right one\n if len(expenses) != target_num_expenses:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Wrong number of expenses.\"},\n )\n\n existing_expense_numbers = {expense[\"number\"] for expense in expenses}\n for expense_number, (is_duplicate, _) in self.expense_lines.items():\n # Check that only one of the duplicated expenses exists and it is the right one\n if expense_number == self.expense_to_keep_number:\n if expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The expected duplicate to keep is missing.\"},\n )\n\n # Check that other duplicates have been deleted\n elif is_duplicate and expense_number in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An unexpected duplicate is present.\"},\n )\n # Check that the extra expenses have not been deleted\n elif not is_duplicate and expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An extra expense has been deleted.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for _, expense_sys_id in self.expense_lines.values():\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={expense_sys_id}\"},\n )[\"result\"]\n if not record_exists:\n continue\n db_delete_from_table(\n instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n for change_request_sys_id in self.change_request_sysids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if not record_exists:\n continue\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass BasicExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"any\",\n level=level,\n )\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n # There should remain only one expense after the task is completed and the extra expenses should reamin\n target_num_expenses = self.extra_expenses + 1\n # Check that only one of the duplicated expenses exists and it is the right one\n if len(expenses) != target_num_expenses:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Wrong number of expenses.\"},\n )\n\n existing_expense_numbers = {expense[\"number\"] for expense in expenses}\n for expense_number, (is_duplicate, _) in self.expense_lines.items():\n if not is_duplicate and expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An extra expense has been deleted.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = FilterAndDoTask.validate(self, page, chat_messages)\n return reward, done, message, info\n\n\nclass EasyExpenseManagementSmallTask(EasyExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )\n\n\nclass BasicExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementMediumTask(EasyExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )\n\n\nclass BasicExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNo\n# ... truncated ...","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.ExpenseManagementTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.ExpenseManagementTask#L27-L281","kind":"class","name":"ExpenseManagementTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":27,"end_line":281,"context_start_line":7,"context_end_line":301,"code":"fake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import HumanEvalTask\nfrom .delete_record import DeleteExpenseLineExpenseManagementTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.change_request import create_change_request\nfrom ...api.expense_line import create_expense_line\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n\nclass ExpenseManagementTask(FilterAndDoTask):\n \"\"\"Task to manage expenses.\n Args:\n\n num_duplicates: int\n The number of duplicate expenses to create\n extra_expenses: int\n The number of extra expenses to create (total expenses will be num_duplicates + extra_expenses)\n goal_type: str\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\".\n - \"base\": one expense is linked to a change request, others are not and are expected to be deleted\n - \"date\": none of the expenses are linked to change requests; the oldest one is expeted to be deleted\n - \"amount\": none of the expenses are linked to change requests and they are all created on the same date;\n the most expensive one is expeted to be deleted\n - \"any\": any of the expenses can be deleted\n \"\"\"\n\n min_allowed_amount = 100\n max_allowed_amount = 10000\n\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n goal_type: str = \"base\",\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"module\": \"Expense Lines\",\n \"application\": \"Cost\",\n },\n level=level,\n protocol_name=\"Managing Your Existing Expenses\",\n )\n self.num_duplicates = num_duplicates\n self.extra_expenses = extra_expenses\n self.total_expenses = num_duplicates + extra_expenses\n self.goal_type = goal_type\n self.change_request_sysids = []\n\n # mappings between number -> (is_duplicate, sys_id)\n self.expense_lines = {}\n self.expense_to_keep_number = None # The number of the expense that will be kept; i.e. not deleted by the cheat/agent if successful\n\n self.expense_hashtag = \"#SERIES-\" + self.unique_id[:10]\n self.short_description = f\"Managing Your Existing Expenses\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) manage your expenses with short description containing hashtag {self.expense_hashtag}. '\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"The setup might be a bit complex on a first read. To understand it better, refer to the protocol for this task.\"\"\"\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n \"expected_fields_path\": EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.expense_hashtag}\",\n ],\n }\n\n # Short description to use for duplicate expenses\n duplicate_short_description = f\"{fake.sentence(4)}\"\n\n # Set the default amount and date in case uniform_amount and uniform_date are True\n amount = round(self.random.uniform(self.min_allowed_amount, self.max_allowed_amount), 2)\n start_date = fake.date_this_decade(before_today=True, after_today=False)\n date = start_date\n\n most_expensive_amount = float(\"-inf\")\n\n most_expensive_duplicate_expense_number = None\n oldest_duplicate_expense_number = None\n only_expense_with_change_request = None\n # id of expenses will be this id + their order in the creation\n unique_id = str(int(self.unique_id.replace(\"-\", \"\"), 16))[:10]\n for i in range(self.total_expenses):\n expense_number = f\"EXP-{i}{unique_id }\"\n is_duplicate = i < self.num_duplicates\n # set task sys_id to empty string if no change request is created\n task_sys_id = \"\"\n\n # Set a random date between start_date and today\n if self.goal_type in [\"base\", \"date\"] and i > 0:\n date = str(\n fake.date_between(start_date=start_date + timedelta(1), end_date=\"today\")\n )\n else:\n date = start_date\n if i == 0:\n oldest_duplicate_expense_number = expense_number\n\n # In the 'any' case, there are no change requests, all dates are the same and the prices are the same\n if self.goal_type != \"any\":\n amount = round(\n self.random.uniform(self.min_allowed_amount, self.max_allowed_amount), 2\n )\n if is_duplicate and amount > most_expensive_amount:\n most_expensive_amount = amount\n most_expensive_duplicate_expense_number = expense_number\n\n # Create a change request for the base case\n if self.goal_type == \"base\" and i == 0:\n task_sys_id, _ = create_change_request(\n instance=self.instance,\n user_sys_id=self._base_user_sysid,\n hashtag=self.expense_hashtag,\n impact=2,\n risk=2,\n random=self.random,\n )\n self.change_request_sysids.append(task_sys_id)\n only_expense_with_change_request = expense_number\n\n # Set the short description for the duplicate expenses; otherwise pass None, which will generate a random one\n short_description = duplicate_short_description if i < self.num_duplicates else None\n\n expense_sys_id, _ = create_expense_line(\n instance=self.instance,\n amount=amount,\n number=expense_number,\n date=str(date),\n short_description=short_description,\n expense_hashtag=self.expense_hashtag,\n user_sys_id=self._base_user_sysid,\n task_sys_id=task_sys_id,\n )\n self.expense_lines[expense_number] = (is_duplicate, expense_sys_id)\n\n # keep the number of the expense that will be linked to the change request\n if self.goal_type == \"base\":\n self.expense_to_keep_number = only_expense_with_change_request\n # keep the oldest expense\n elif self.goal_type == \"date\":\n self.expense_to_keep_number = oldest_duplicate_expense_number\n elif self.goal_type == \"amount\":\n self.expense_to_keep_number = most_expensive_duplicate_expense_number\n else:\n self.expense_to_keep_number = oldest_duplicate_expense_number\n\n # As the task description redundant, we keep only the first one and skip the rest\n skip_description = False\n # Create the tasks to delete the extra expenses\n for expense_number, (is_duplicate, expense_sys_id) in self.expense_lines.items():\n if expense_number == self.expense_to_keep_number or not is_duplicate:\n continue\n self.tasks.append(\n DeleteExpenseLineExpenseManagementTask(\n instance=self.instance,\n fixed_config={\n \"field_name\": \"number\",\n \"field_value\": f\"{expense_number}\",\n },\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=expense_sys_id,\n record_number=expense_number,\n level=self.level,\n skip_description=skip_description,\n goal_type=self.goal_type,\n )\n )\n skip_description = True\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n # There should remain only one duplicate expense after the task is completed and the extra expenses should reamin\n target_num_expenses = self.extra_expenses + 1\n # Check that only one of the duplicated expenses exists and it is the right one\n if len(expenses) != target_num_expenses:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Wrong number of expenses.\"},\n )\n\n existing_expense_numbers = {expense[\"number\"] for expense in expenses}\n for expense_number, (is_duplicate, _) in self.expense_lines.items():\n # Check that only one of the duplicated expenses exists and it is the right one\n if expense_number == self.expense_to_keep_number:\n if expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"The expected duplicate to keep is missing.\"},\n )\n\n # Check that other duplicates have been deleted\n elif is_duplicate and expense_number in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An unexpected duplicate is present.\"},\n )\n # Check that the extra expenses have not been deleted\n elif not is_duplicate and expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An extra expense has been deleted.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for _, expense_sys_id in self.expense_lines.values():\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={expense_sys_id}\"},\n )[\"result\"]\n if not record_exists:\n continue\n db_delete_from_table(\n instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n for change_request_sys_id in self.change_request_sysids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if not record_exists:\n continue\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass BasicExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.BasicExpenseManagementSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.BasicExpenseManagementSmallTask#L284-L302","kind":"class","name":"BasicExpenseManagementSmallTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":284,"end_line":302,"context_start_line":264,"context_end_line":322,"code":" instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n for change_request_sys_id in self.change_request_sysids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if not record_exists:\n continue\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass BasicExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.DateBasedExpenseManagementSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.DateBasedExpenseManagementSmallTask#L305-L323","kind":"class","name":"DateBasedExpenseManagementSmallTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":305,"end_line":323,"context_start_line":285,"context_end_line":343,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.AmountBasedExpenseManagementSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.AmountBasedExpenseManagementSmallTask#L326-L344","kind":"class","name":"AmountBasedExpenseManagementSmallTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":326,"end_line":344,"context_start_line":306,"context_end_line":364,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"any\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.EasyExpenseManagementTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.EasyExpenseManagementTask#L347-L399","kind":"class","name":"EasyExpenseManagementTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":347,"end_line":399,"context_start_line":327,"context_end_line":419,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"any\",\n level=level,\n )\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n # There should remain only one expense after the task is completed and the extra expenses should reamin\n target_num_expenses = self.extra_expenses + 1\n # Check that only one of the duplicated expenses exists and it is the right one\n if len(expenses) != target_num_expenses:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Wrong number of expenses.\"},\n )\n\n existing_expense_numbers = {expense[\"number\"] for expense in expenses}\n for expense_number, (is_duplicate, _) in self.expense_lines.items():\n if not is_duplicate and expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An extra expense has been deleted.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = FilterAndDoTask.validate(self, page, chat_messages)\n return reward, done, message, info\n\n\nclass EasyExpenseManagementSmallTask(EasyExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.EasyExpenseManagementSmallTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.EasyExpenseManagementSmallTask#L402-L419","kind":"class","name":"EasyExpenseManagementSmallTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":402,"end_line":419,"context_start_line":382,"context_end_line":439,"code":" False,\n \"\",\n {\"message\": \"Wrong number of expenses.\"},\n )\n\n existing_expense_numbers = {expense[\"number\"] for expense in expenses}\n for expense_number, (is_duplicate, _) in self.expense_lines.items():\n if not is_duplicate and expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An extra expense has been deleted.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = FilterAndDoTask.validate(self, page, chat_messages)\n return reward, done, message, info\n\n\nclass EasyExpenseManagementSmallTask(EasyExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )\n\n\nclass BasicExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.BasicExpenseManagementMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.BasicExpenseManagementMediumTask#L422-L440","kind":"class","name":"BasicExpenseManagementMediumTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":422,"end_line":440,"context_start_line":402,"context_end_line":460,"code":"class EasyExpenseManagementSmallTask(EasyExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )\n\n\nclass BasicExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.DateBasedExpenseManagementMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.DateBasedExpenseManagementMediumTask#L443-L461","kind":"class","name":"DateBasedExpenseManagementMediumTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":443,"end_line":461,"context_start_line":423,"context_end_line":481,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.AmountBasedExpenseManagementMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.AmountBasedExpenseManagementMediumTask#L464-L482","kind":"class","name":"AmountBasedExpenseManagementMediumTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":464,"end_line":482,"context_start_line":444,"context_end_line":502,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementMediumTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementMediumTask(EasyExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.EasyExpenseManagementMediumTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.EasyExpenseManagementMediumTask#L485-L502","kind":"class","name":"EasyExpenseManagementMediumTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":485,"end_line":502,"context_start_line":465,"context_end_line":522,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementMediumTask(EasyExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )\n\n\nclass BasicExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.BasicExpenseManagementLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.BasicExpenseManagementLargeTask#L505-L523","kind":"class","name":"BasicExpenseManagementLargeTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":505,"end_line":523,"context_start_line":485,"context_end_line":543,"code":"class EasyExpenseManagementMediumTask(EasyExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 4,\n extra_expenses: int = 4,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )\n\n\nclass BasicExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.DateBasedExpenseManagementLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.DateBasedExpenseManagementLargeTask#L526-L544","kind":"class","name":"DateBasedExpenseManagementLargeTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":526,"end_line":544,"context_start_line":506,"context_end_line":564,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,\n )\n\n\nclass DateBasedExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.AmountBasedExpenseManagementLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.AmountBasedExpenseManagementLargeTask#L547-L565","kind":"class","name":"AmountBasedExpenseManagementLargeTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":547,"end_line":565,"context_start_line":527,"context_end_line":585,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"date\",\n level=level,\n )\n\n\nclass AmountBasedExpenseManagementLargeTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementLargeTask(EasyExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.EasyExpenseManagementLargeTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.expense_management.EasyExpenseManagementLargeTask#L568-L585","kind":"class","name":"EasyExpenseManagementLargeTask","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":568,"end_line":585,"context_start_line":548,"context_end_line":598,"code":" def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementLargeTask(EasyExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not ExpenseManagementTask\n and var is not EasyExpenseManagementTask\n]","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.expense_management.__init__#L569-L585","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":569,"end_line":585,"context_start_line":549,"context_end_line":598,"code":" self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"amount\",\n level=level,\n )\n\n\nclass EasyExpenseManagementLargeTask(EasyExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 6,\n extra_expenses: int = 6,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, FilterAndDoTask)\n and var is not FilterAndDoTask\n and var is not ExpenseManagementTask\n and var is not EasyExpenseManagementTask\n]","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management._setup_list","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.expense_management._setup_list#L83-L199","kind":"function","name":"_setup_list","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":83,"end_line":199,"context_start_line":63,"context_end_line":219,"code":" \"application\": \"Cost\",\n },\n level=level,\n protocol_name=\"Managing Your Existing Expenses\",\n )\n self.num_duplicates = num_duplicates\n self.extra_expenses = extra_expenses\n self.total_expenses = num_duplicates + extra_expenses\n self.goal_type = goal_type\n self.change_request_sysids = []\n\n # mappings between number -> (is_duplicate, sys_id)\n self.expense_lines = {}\n self.expense_to_keep_number = None # The number of the expense that will be kept; i.e. not deleted by the cheat/agent if successful\n\n self.expense_hashtag = \"#SERIES-\" + self.unique_id[:10]\n self.short_description = f\"Managing Your Existing Expenses\"\n self.task_description = f'Referring to company protocol \"{self.protocol_name}\" (located in the \"Company Protocols\" knowledge base) manage your expenses with short description containing hashtag {self.expense_hashtag}. '\n self.tasks = []\n\n def _setup_list(self) -> None:\n \"\"\"The setup might be a bit complex on a first read. To understand it better, refer to the protocol for this task.\"\"\"\n self.filter_config = {\n \"list_url\": \"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n \"expected_fields_path\": EXPECTED_EXPENSE_LINE_COLUMNS_PATH,\n \"filter_columns\": [\n \"short_description\",\n ],\n \"filter_kind\": \"AND\",\n \"filter_operators\": [\"contains\"],\n \"filter_values\": [\n f\"{self.expense_hashtag}\",\n ],\n }\n\n # Short description to use for duplicate expenses\n duplicate_short_description = f\"{fake.sentence(4)}\"\n\n # Set the default amount and date in case uniform_amount and uniform_date are True\n amount = round(self.random.uniform(self.min_allowed_amount, self.max_allowed_amount), 2)\n start_date = fake.date_this_decade(before_today=True, after_today=False)\n date = start_date\n\n most_expensive_amount = float(\"-inf\")\n\n most_expensive_duplicate_expense_number = None\n oldest_duplicate_expense_number = None\n only_expense_with_change_request = None\n # id of expenses will be this id + their order in the creation\n unique_id = str(int(self.unique_id.replace(\"-\", \"\"), 16))[:10]\n for i in range(self.total_expenses):\n expense_number = f\"EXP-{i}{unique_id }\"\n is_duplicate = i < self.num_duplicates\n # set task sys_id to empty string if no change request is created\n task_sys_id = \"\"\n\n # Set a random date between start_date and today\n if self.goal_type in [\"base\", \"date\"] and i > 0:\n date = str(\n fake.date_between(start_date=start_date + timedelta(1), end_date=\"today\")\n )\n else:\n date = start_date\n if i == 0:\n oldest_duplicate_expense_number = expense_number\n\n # In the 'any' case, there are no change requests, all dates are the same and the prices are the same\n if self.goal_type != \"any\":\n amount = round(\n self.random.uniform(self.min_allowed_amount, self.max_allowed_amount), 2\n )\n if is_duplicate and amount > most_expensive_amount:\n most_expensive_amount = amount\n most_expensive_duplicate_expense_number = expense_number\n\n # Create a change request for the base case\n if self.goal_type == \"base\" and i == 0:\n task_sys_id, _ = create_change_request(\n instance=self.instance,\n user_sys_id=self._base_user_sysid,\n hashtag=self.expense_hashtag,\n impact=2,\n risk=2,\n random=self.random,\n )\n self.change_request_sysids.append(task_sys_id)\n only_expense_with_change_request = expense_number\n\n # Set the short description for the duplicate expenses; otherwise pass None, which will generate a random one\n short_description = duplicate_short_description if i < self.num_duplicates else None\n\n expense_sys_id, _ = create_expense_line(\n instance=self.instance,\n amount=amount,\n number=expense_number,\n date=str(date),\n short_description=short_description,\n expense_hashtag=self.expense_hashtag,\n user_sys_id=self._base_user_sysid,\n task_sys_id=task_sys_id,\n )\n self.expense_lines[expense_number] = (is_duplicate, expense_sys_id)\n\n # keep the number of the expense that will be linked to the change request\n if self.goal_type == \"base\":\n self.expense_to_keep_number = only_expense_with_change_request\n # keep the oldest expense\n elif self.goal_type == \"date\":\n self.expense_to_keep_number = oldest_duplicate_expense_number\n elif self.goal_type == \"amount\":\n self.expense_to_keep_number = most_expensive_duplicate_expense_number\n else:\n self.expense_to_keep_number = oldest_duplicate_expense_number\n\n # As the task description redundant, we keep only the first one and skip the rest\n skip_description = False\n # Create the tasks to delete the extra expenses\n for expense_number, (is_duplicate, expense_sys_id) in self.expense_lines.items():\n if expense_number == self.expense_to_keep_number or not is_duplicate:\n continue\n self.tasks.append(\n DeleteExpenseLineExpenseManagementTask(\n instance=self.instance,\n fixed_config={\n \"field_name\": \"number\",\n \"field_value\": f\"{expense_number}\",\n },\n is_validated=False,\n used_in_level_2=True,\n record_sys_id=expense_sys_id,\n record_number=expense_number,\n level=self.level,\n skip_description=skip_description,\n goal_type=self.goal_type,\n )\n )\n skip_description = True\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n # There should remain only one duplicate expense after the task is completed and the extra expenses should reamin\n target_num_expenses = self.extra_expenses + 1\n # Check that only one of the duplicated expenses exists and it is the right one\n if len(expenses) != target_num_expenses:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Wrong number of expenses.\"},\n )","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.expense_management.validate#L367-L399","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":367,"end_line":399,"context_start_line":347,"context_end_line":419,"code":"class EasyExpenseManagementTask(ExpenseManagementTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"any\",\n level=level,\n )\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n expenses = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\n \"sysparm_query\": f\"short_descriptionLIKE{self.expense_hashtag}\",\n \"sysparm_fields\": \"number,amount,sys_id\",\n },\n )[\"result\"]\n # There should remain only one expense after the task is completed and the extra expenses should reamin\n target_num_expenses = self.extra_expenses + 1\n # Check that only one of the duplicated expenses exists and it is the right one\n if len(expenses) != target_num_expenses:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"Wrong number of expenses.\"},\n )\n\n existing_expense_numbers = {expense[\"number\"] for expense in expenses}\n for expense_number, (is_duplicate, _) in self.expense_lines.items():\n if not is_duplicate and expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An extra expense has been deleted.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = FilterAndDoTask.validate(self, page, chat_messages)\n return reward, done, message, info\n\n\nclass EasyExpenseManagementSmallTask(EasyExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n level=level,\n )","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.expense_management.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.expense_management.teardown#L254-L281","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":254,"end_line":281,"context_start_line":234,"context_end_line":301,"code":" elif is_duplicate and expense_number in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An unexpected duplicate is present.\"},\n )\n # Check that the extra expenses have not been deleted\n elif not is_duplicate and expense_number not in existing_expense_numbers:\n return (\n 0,\n False,\n \"\",\n {\"message\": \"An extra expense has been deleted.\"},\n )\n\n # Validate final_l3 tasks\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for _, expense_sys_id in self.expense_lines.values():\n record_exists = table_api_call(\n instance=self.instance,\n table=\"fm_expense_line\",\n params={\"sysparm_query\": f\"sys_id={expense_sys_id}\"},\n )[\"result\"]\n if not record_exists:\n continue\n db_delete_from_table(\n instance=self.instance,\n table=\"fm_expense_line\",\n sys_id=expense_sys_id,\n )\n for change_request_sys_id in self.change_request_sysids:\n record_exists = table_api_call(\n instance=self.instance,\n table=\"change_request\",\n params={\"sysparm_query\": f\"sys_id={change_request_sys_id}\"},\n )[\"result\"]\n if not record_exists:\n continue\n db_delete_from_table(\n instance=self.instance,\n table=\"change_request\",\n sys_id=change_request_sys_id,\n )\n super().teardown()\n\n\nclass BasicExpenseManagementSmallTask(ExpenseManagementTask, HumanEvalTask):\n def __init__(\n self,\n seed: int,\n instance: SNowInstance = None,\n fixed_config: List[AbstractServiceNowTask] = None,\n num_duplicates: int = 2,\n extra_expenses: int = 2,\n level: int = 2,\n ) -> None:\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n num_duplicates=num_duplicates,\n extra_expenses=extra_expenses,\n goal_type=\"base\",\n level=level,","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_request_item#L1-L1315","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_request_item","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1,"end_line":1315,"context_start_line":1,"context_end_line":1315,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateItemRequestTask\n\n\nclass DashboardRetrieveIncidentAndRequestItemTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n item: str = None,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an item for them.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"\"Order an item for the best performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n if not item:\n raise Exception(\"No item passed to assign\")\n self.item = item\n self.attribute_name = \"assigned_to\" # Return full name\n self.filter_than = \"greater\"\n self.prefix = \"DRI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n requested_items = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n method=\"GET\",\n )[\"result\"]\n current_requested_items_numbers = [\n requested_item[\"number\"] for requested_item in requested_items\n ]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n\n requested_item_numbers = []\n\n for _ in range(len(agent_full_names)):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n while (\n requested_item_number in current_requested_items_numbers\n or requested_item_number in requested_item_numbers\n ):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n requested_item_numbers.append(requested_item_number)\n\n self.requested_item_numbers = requested_item_numbers\n\n create_item_request_subtasks = []\n\n for agent_full_name, requested_item_number in zip(agent_full_names, requested_item_numbers):\n request_item_config = {\n \"fields\": {\n \"number\": \"Number\",\n \"cat_item\": \"Item\",\n \"requested_for\": \"Requested for\",\n \"quantity\": \"Quantity\",\n },\n \"task_fields\": [\"number\", \"cat_item\", \"requested_for\", \"quantity\"],\n \"template_record\": {\n \"number\": requested_item_number,\n \"cat_item\": self.item,\n \"requested_for\": agent_full_name,\n \"quantity\": \"1\",\n },\n }\n\n create_item_request_subtask = [\n # Navigate to the item request list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Open Records\",\n \"module\": \"Open Records > Items\",\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an item request\n CreateItemRequestTask(\n instance=self.instance,\n fixed_config=request_item_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_item_request_subtasks += create_item_request_subtask\n\n self.compositional_task = create_item_request_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n requested_item_numbers_string = \", \".join(self.requested_item_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have greater than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have greater than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create an 'item request' with the following information (only fill these fields and the 'request item number' from below) and 'request it' for them using the 'Requested for' field: \\n\"\n + f\"\\t\\t Item: {self.item}, Quantity: 1, Requested for: .\\n\"\n + f\"\\t Importantly, you should override the default request item numbers in the form and instead use one request item number from the following list for each item request you create: {requested_item_numbers_string}.\\n\\n\"\n + f\"Note that you will create as many item requests as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned greater than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have greater than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to Open Records > Items. \\n\"\n + f\"\\n5. You have to create new 'item requests' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new item request:- Item: {self.item}, Quantity: 1 and 'request' them for each agent using the 'Requested For' field.\\n\\n\"\n + f\"Importantly, you should override the default request item numbers in the form and instead use one request item number from the following list for each item request you create: {requested_item_numbers_string}.\\n\"\n + f\"Note that you will create as many item requests as there are agents matching the above criteria.\\n\"\n + \"For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n for requested_item_number in self.requested_item_numbers:\n created_request_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n \"sysparm_fields\": \"requested_for,cat_item,quantity\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_request_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"No request item created with number {requested_item_number}.\"},\n )\n elif len(created_request_item_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple request items created with number {requested_item_number}.\"\n },\n )\n created_request_item_response = created_request_item_response[0]\n if (\n created_request_item_response[\"requested_for\"][\"value\"]\n not in self.agent_value_sysids\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} created for a random agent.\"\n },\n )\n if str(created_request_item_response[\"quantity\"]) != \"1\":\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} requested incorrect number of items.\"\n },\n )\n cat_item = created_request_item_response[\"cat_item\"]\n if not cat_item:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Request item {requested_item_number} did not request an item.\"},\n )\n cat_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\n \"sysparm_query\": f\"sys_id={cat_item['value']}\",\n \"sysparm_fields\": \"sys_name\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(cat_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Request item {requested_item_number} did not request an item.\"},\n )\n\n if cat_item_response[0][\"sys_name\"] != self.item:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} requested an incorrect item.\"\n },\n )\n\n for agent_sysid in self.agent_value_sysids:\n created_request_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"requested_for={agent_sysid}\",\n \"sysparm_fields\": \"requested_for\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_request_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No request created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_request_item_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple requests created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for requested_item_number in self.requested_item_numbers:\n created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__\n# ... truncated ...","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndRequestItemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndRequestItemTask#L17-L294","kind":"class","name":"DashboardRetrieveIncidentAndRequestItemTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":17,"end_line":294,"context_start_line":1,"context_end_line":314,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateItemRequestTask\n\n\nclass DashboardRetrieveIncidentAndRequestItemTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n item: str = None,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an item for them.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"\"Order an item for the best performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n if not item:\n raise Exception(\"No item passed to assign\")\n self.item = item\n self.attribute_name = \"assigned_to\" # Return full name\n self.filter_than = \"greater\"\n self.prefix = \"DRI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n requested_items = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n method=\"GET\",\n )[\"result\"]\n current_requested_items_numbers = [\n requested_item[\"number\"] for requested_item in requested_items\n ]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n\n requested_item_numbers = []\n\n for _ in range(len(agent_full_names)):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n while (\n requested_item_number in current_requested_items_numbers\n or requested_item_number in requested_item_numbers\n ):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n requested_item_numbers.append(requested_item_number)\n\n self.requested_item_numbers = requested_item_numbers\n\n create_item_request_subtasks = []\n\n for agent_full_name, requested_item_number in zip(agent_full_names, requested_item_numbers):\n request_item_config = {\n \"fields\": {\n \"number\": \"Number\",\n \"cat_item\": \"Item\",\n \"requested_for\": \"Requested for\",\n \"quantity\": \"Quantity\",\n },\n \"task_fields\": [\"number\", \"cat_item\", \"requested_for\", \"quantity\"],\n \"template_record\": {\n \"number\": requested_item_number,\n \"cat_item\": self.item,\n \"requested_for\": agent_full_name,\n \"quantity\": \"1\",\n },\n }\n\n create_item_request_subtask = [\n # Navigate to the item request list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Open Records\",\n \"module\": \"Open Records > Items\",\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an item request\n CreateItemRequestTask(\n instance=self.instance,\n fixed_config=request_item_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_item_request_subtasks += create_item_request_subtask\n\n self.compositional_task = create_item_request_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n requested_item_numbers_string = \", \".join(self.requested_item_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have greater than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have greater than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create an 'item request' with the following information (only fill these fields and the 'request item number' from below) and 'request it' for them using the 'Requested for' field: \\n\"\n + f\"\\t\\t Item: {self.item}, Quantity: 1, Requested for: .\\n\"\n + f\"\\t Importantly, you should override the default request item numbers in the form and instead use one request item number from the following list for each item request you create: {requested_item_numbers_string}.\\n\\n\"\n + f\"Note that you will create as many item requests as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned greater than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have greater than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to Open Records > Items. \\n\"\n + f\"\\n5. You have to create new 'item requests' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new item request:- Item: {self.item}, Quantity: 1 and 'request' them for each agent using the 'Requested For' field.\\n\\n\"\n + f\"Importantly, you should override the default request item numbers in the form and instead use one request item number from the following list for each item request you create: {requested_item_numbers_string}.\\n\"\n + f\"Note that you will create as many item requests as there are agents matching the above criteria.\\n\"\n + \"For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n for requested_item_number in self.requested_item_numbers:\n created_request_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n \"sysparm_fields\": \"requested_for,cat_item,quantity\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_request_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"No request item created with number {requested_item_number}.\"},\n )\n elif len(created_request_item_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple request items created with number {requested_item_number}.\"\n },\n )\n created_request_item_response = created_request_item_response[0]\n if (\n created_request_item_response[\"requested_for\"][\"value\"]\n not in self.agent_value_sysids\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} created for a random agent.\"\n },\n )\n if str(created_request_item_response[\"quantity\"]) != \"1\":\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} requested incorrect number of items.\"\n },\n )\n cat_item = created_request_item_response[\"cat_item\"]\n if not cat_item:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Request item {requested_item_number} did not request an item.\"},\n )\n cat_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\n \"sysparm_query\": f\"sys_id={cat_item['value']}\",\n \"sysparm_fields\": \"sys_name\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(cat_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Request item {requested_item_number} did not request an item.\"},\n )\n\n if cat_item_response[0][\"sys_name\"] != self.item:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} requested an incorrect item.\"\n },\n )\n\n for agent_sysid in self.agent_value_sysids:\n created_request_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"requested_for={agent_sysid}\",\n \"sysparm_fields\": \"requested_for\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_request_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No request created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_request_item_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple requests created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for requested_item_number in self.requested_item_numbers:\n created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleWatchTask#L297-L318","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":297,"end_line":318,"context_start_line":277,"context_end_line":338,"code":" created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleWatchTask#L321-L342","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":321,"end_line":342,"context_start_line":301,"context_end_line":362,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleWatchTask#L345-L366","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":345,"end_line":366,"context_start_line":325,"context_end_line":386,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleWatchTask#L369-L390","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":369,"end_line":390,"context_start_line":349,"context_end_line":410,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleWatch2Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleWatch2Task#L393-L414","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleWatch2Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":393,"end_line":414,"context_start_line":373,"context_end_line":434,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleWatch2Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleWatch2Task#L417-L438","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestAppleWatch2Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":417,"end_line":438,"context_start_line":397,"context_end_line":458,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleWatch2Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleWatch2Task#L441-L462","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestAppleWatch2Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":441,"end_line":462,"context_start_line":421,"context_end_line":482,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleWatch2Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleWatch2Task#L465-L486","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestAppleWatch2Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":465,"end_line":486,"context_start_line":445,"context_end_line":506,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleWatch2Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleIpad3Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleIpad3Task#L489-L510","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIpad3Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":489,"end_line":510,"context_start_line":469,"context_end_line":530,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple Watch Series 2 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple Watch Series 2\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleIpad3Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleIpad3Task#L513-L534","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestAppleIpad3Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":513,"end_line":534,"context_start_line":493,"context_end_line":554,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleIpad3Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleIpad3Task#L537-L558","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestAppleIpad3Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":537,"end_line":558,"context_start_line":517,"context_end_line":578,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleIpad3Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleIpad3Task#L561-L582","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestAppleIpad3Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":561,"end_line":582,"context_start_line":541,"context_end_line":602,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleIpad3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13proTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleIphone13proTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleIphone13proTask#L585-L606","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIphone13proTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":585,"end_line":606,"context_start_line":565,"context_end_line":626,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPad 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPad 3\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13proTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleIphone13proTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleIphone13proTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleIphone13proTask#L609-L630","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestAppleIphone13proTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":609,"end_line":630,"context_start_line":589,"context_end_line":650,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleIphone13proTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleIphone13proTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleIphone13proTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleIphone13proTask#L633-L654","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestAppleIphone13proTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":633,"end_line":654,"context_start_line":613,"context_end_line":674,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleIphone13proTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleIphone13proTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleIphone13proTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleIphone13proTask#L657-L678","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestAppleIphone13proTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":657,"end_line":678,"context_start_line":637,"context_end_line":698,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleIphone13proTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleIphone13Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestAppleIphone13Task#L681-L702","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestAppleIphone13Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":681,"end_line":702,"context_start_line":661,"context_end_line":722,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 pro for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13 pro\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleIphone13Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleIphone13Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleIphone13Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestAppleIphone13Task#L705-L726","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestAppleIphone13Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":705,"end_line":726,"context_start_line":685,"context_end_line":746,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestAppleIphone13Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleIphone13Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleIphone13Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestAppleIphone13Task#L729-L750","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestAppleIphone13Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":729,"end_line":750,"context_start_line":709,"context_end_line":770,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestAppleIphone13Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleIphone13Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleIphone13Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestAppleIphone13Task#L753-L774","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestAppleIphone13Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":753,"end_line":774,"context_start_line":733,"context_end_line":794,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestAppleIphone13Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGalaxyNote20Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestGalaxyNote20Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestGalaxyNote20Task#L777-L798","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestGalaxyNote20Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":777,"end_line":798,"context_start_line":757,"context_end_line":818,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Apple iPhone 13 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Apple iPhone 13\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGalaxyNote20Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestGalaxyNote20Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestGalaxyNote20Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestGalaxyNote20Task#L801-L822","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestGalaxyNote20Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":801,"end_line":822,"context_start_line":781,"context_end_line":842,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestGalaxyNote20Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestGalaxyNote20Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestGalaxyNote20Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestGalaxyNote20Task#L825-L846","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestGalaxyNote20Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":825,"end_line":846,"context_start_line":805,"context_end_line":866,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestGalaxyNote20Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestGalaxyNote20Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestGalaxyNote20Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestGalaxyNote20Task#L849-L870","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestGalaxyNote20Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":849,"end_line":870,"context_start_line":829,"context_end_line":890,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestGalaxyNote20Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGoogleNexus7Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestGoogleNexus7Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestGoogleNexus7Task#L873-L894","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestGoogleNexus7Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":873,"end_line":894,"context_start_line":853,"context_end_line":914,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Galaxy Note 20 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Galaxy Note 20\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestGoogleNexus7Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestGoogleNexus7Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestGoogleNexus7Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestGoogleNexus7Task#L897-L918","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestGoogleNexus7Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":897,"end_line":918,"context_start_line":877,"context_end_line":938,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestGoogleNexus7Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestGoogleNexus7Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestGoogleNexus7Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestGoogleNexus7Task#L921-L942","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestGoogleNexus7Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":921,"end_line":942,"context_start_line":901,"context_end_line":962,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestGoogleNexus7Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestGoogleNexus7Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestGoogleNexus7Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestGoogleNexus7Task#L945-L966","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestGoogleNexus7Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":945,"end_line":966,"context_start_line":925,"context_end_line":986,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestGoogleNexus7Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3Task#L969-L990","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":969,"end_line":990,"context_start_line":949,"context_end_line":1010,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Google Nexus 7 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Google Nexus 7\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestMicrosoftSurfacePro3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestMicrosoftSurfacePro3Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestMicrosoftSurfacePro3Task#L993-L1014","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestMicrosoftSurfacePro3Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":993,"end_line":1014,"context_start_line":973,"context_end_line":1034,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestMicrosoftSurfacePro3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestMicrosoftSurfacePro3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestMicrosoftSurfacePro3Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestMicrosoftSurfacePro3Task#L1017-L1038","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestMicrosoftSurfacePro3Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1017,"end_line":1038,"context_start_line":997,"context_end_line":1058,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestMicrosoftSurfacePro3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestMicrosoftSurfacePro3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestMicrosoftSurfacePro3Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestMicrosoftSurfacePro3Task#L1041-L1062","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestMicrosoftSurfacePro3Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1041,"end_line":1062,"context_start_line":1021,"context_end_line":1082,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestMicrosoftSurfacePro3Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestPixel4aTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestPixel4aTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestPixel4aTask#L1065-L1086","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestPixel4aTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1065,"end_line":1086,"context_start_line":1045,"context_end_line":1106,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Microsoft Surface Pro 3 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Microsoft Surface Pro 3\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestPixel4aTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestPixel4aTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestPixel4aTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestPixel4aTask#L1089-L1110","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestPixel4aTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1089,"end_line":1110,"context_start_line":1069,"context_end_line":1130,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestPixel4aTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestPixel4aTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestPixel4aTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestPixel4aTask#L1113-L1134","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestPixel4aTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1113,"end_line":1134,"context_start_line":1093,"context_end_line":1154,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestPixel4aTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestPixel4aTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestPixel4aTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestPixel4aTask#L1137-L1158","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestPixel4aTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1137,"end_line":1158,"context_start_line":1117,"context_end_line":1178,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestPixel4aTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4Task#L1161-L1182","kind":"class","name":"DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1161,"end_line":1182,"context_start_line":1141,"context_end_line":1202,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an Pixel 4a for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Pixel 4a\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestWindowsSurfacePro4Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMeanRequestWindowsSurfacePro4Task#L1185-L1206","kind":"class","name":"DashboardRetrieveIncidentAndMeanRequestWindowsSurfacePro4Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1185,"end_line":1206,"context_start_line":1165,"context_end_line":1226,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"max\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestWindowsSurfacePro4Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndMedianRequestWindowsSurfacePro4Task#L1209-L1230","kind":"class","name":"DashboardRetrieveIncidentAndMedianRequestWindowsSurfacePro4Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1209,"end_line":1230,"context_start_line":1189,"context_end_line":1250,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestWindowsSurfacePro4Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_request_item.DashboardRetrieveIncidentAndModeRequestWindowsSurfacePro4Task#L1233-L1254","kind":"class","name":"DashboardRetrieveIncidentAndModeRequestWindowsSurfacePro4Task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1233,"end_line":1254,"context_start_line":1213,"context_end_line":1274,"code":" self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\n\nDASH_AND_REQUEST = [\n DashboardRetrieveIncidentAndMaxRequestAppleWatchTask,\n DashboardRetrieveIncidentAndMaxRequestAppleWatch2Task,\n DashboardRetrieveIncidentAndMaxRequestAppleIpad3Task,\n DashboardRetrieveIncidentAndMaxRequestAppleIphone13proTask,\n DashboardRetrieveIncidentAndMaxRequestAppleIphone13Task,\n DashboardRetrieveIncidentAndMaxRequestGalaxyNote20Task,\n DashboardRetrieveIncidentAndMaxRequestGoogleNexus7Task,\n DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3Task,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item.__init__#L1236-L1254","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1236,"end_line":1254,"context_start_line":1216,"context_end_line":1274,"code":" fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeRequestWindowsSurfacePro4Task(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request a Windows Surface Pro 4 for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n item=\"Windows Surface Pro 4\",\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\n\nDASH_AND_REQUEST = [\n DashboardRetrieveIncidentAndMaxRequestAppleWatchTask,\n DashboardRetrieveIncidentAndMaxRequestAppleWatch2Task,\n DashboardRetrieveIncidentAndMaxRequestAppleIpad3Task,\n DashboardRetrieveIncidentAndMaxRequestAppleIphone13proTask,\n DashboardRetrieveIncidentAndMaxRequestAppleIphone13Task,\n DashboardRetrieveIncidentAndMaxRequestGalaxyNote20Task,\n DashboardRetrieveIncidentAndMaxRequestGoogleNexus7Task,\n DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3Task,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.set_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item.set_compositional_task#L52-L123","kind":"function","name":"set_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":52,"end_line":123,"context_start_line":32,"context_end_line":143,"code":" task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"\"Order an item for the best performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n if not item:\n raise Exception(\"No item passed to assign\")\n self.item = item\n self.attribute_name = \"assigned_to\" # Return full name\n self.filter_than = \"greater\"\n self.prefix = \"DRI\"\n\n def set_compositional_task(self) -> None:\n # The unique name for the user is created once the task is instantiated\n requested_items = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n method=\"GET\",\n )[\"result\"]\n current_requested_items_numbers = [\n requested_item[\"number\"] for requested_item in requested_items\n ]\n\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n\n requested_item_numbers = []\n\n for _ in range(len(agent_full_names)):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n while (\n requested_item_number in current_requested_items_numbers\n or requested_item_number in requested_item_numbers\n ):\n requested_item_number = \"RITM\" + str(random.randint(1000000, 9999999))\n requested_item_numbers.append(requested_item_number)\n\n self.requested_item_numbers = requested_item_numbers\n\n create_item_request_subtasks = []\n\n for agent_full_name, requested_item_number in zip(agent_full_names, requested_item_numbers):\n request_item_config = {\n \"fields\": {\n \"number\": \"Number\",\n \"cat_item\": \"Item\",\n \"requested_for\": \"Requested for\",\n \"quantity\": \"Quantity\",\n },\n \"task_fields\": [\"number\", \"cat_item\", \"requested_for\", \"quantity\"],\n \"template_record\": {\n \"number\": requested_item_number,\n \"cat_item\": self.item,\n \"requested_for\": agent_full_name,\n \"quantity\": \"1\",\n },\n }\n\n create_item_request_subtask = [\n # Navigate to the item request list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Open Records\",\n \"module\": \"Open Records > Items\",\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an item request\n CreateItemRequestTask(\n instance=self.instance,\n fixed_config=request_item_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_item_request_subtasks += create_item_request_subtask\n\n self.compositional_task = create_item_request_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n requested_item_numbers_string = \", \".join(self.requested_item_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have greater than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have greater than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create an 'item request' with the following information (only fill these fields and the 'request item number' from below) and 'request it' for them using the 'Requested for' field: \\n\"\n + f\"\\t\\t Item: {self.item}, Quantity: 1, Requested for: .\\n\"\n + f\"\\t Importantly, you should override the default request item numbers in the form and instead use one request item number from the following list for each item request you create: {requested_item_numbers_string}.\\n\\n\"\n + f\"Note that you will create as many item requests as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item.setup_goal#L125-L158","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":125,"end_line":158,"context_start_line":105,"context_end_line":178,"code":" \"application\": \"Open Records\",\n \"module\": \"Open Records > Items\",\n \"url\": \"/now/nav/ui/classic/params/target/sc_req_item_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create an item request\n CreateItemRequestTask(\n instance=self.instance,\n fixed_config=request_item_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_item_request_subtasks += create_item_request_subtask\n\n self.compositional_task = create_item_request_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report()\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n requested_item_numbers_string = \", \".join(self.requested_item_numbers)\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have greater than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have greater than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create an 'item request' with the following information (only fill these fields and the 'request item number' from below) and 'request it' for them using the 'Requested for' field: \\n\"\n + f\"\\t\\t Item: {self.item}, Quantity: 1, Requested for: .\\n\"\n + f\"\\t Importantly, you should override the default request item numbers in the form and instead use one request item number from the following list for each item request you create: {requested_item_numbers_string}.\\n\\n\"\n + f\"Note that you will create as many item requests as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned greater than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have greater than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to Open Records > Items. \\n\"\n + f\"\\n5. You have to create new 'item requests' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new item request:- Item: {self.item}, Quantity: 1 and 'request' them for each agent using the 'Requested For' field.\\n\\n\"\n + f\"Importantly, you should override the default request item numbers in the form and instead use one request item number from the following list for each item request you create: {requested_item_numbers_string}.\\n\"\n + f\"Note that you will create as many item requests as there are agents matching the above criteria.\\n\"\n + \"For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n for requested_item_number in self.requested_item_numbers:\n created_request_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n \"sysparm_fields\": \"requested_for,cat_item,quantity\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_request_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"No request item created with number {requested_item_number}.\"},\n )\n elif len(created_request_item_response) > 1:","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item.validate#L160-L273","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":160,"end_line":273,"context_start_line":140,"context_end_line":293,"code":" + f\"\\t For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned greater than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have greater than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to Open Records > Items. \\n\"\n + f\"\\n5. You have to create new 'item requests' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new item request:- Item: {self.item}, Quantity: 1 and 'request' them for each agent using the 'Requested For' field.\\n\\n\"\n + f\"Importantly, you should override the default request item numbers in the form and instead use one request item number from the following list for each item request you create: {requested_item_numbers_string}.\\n\"\n + f\"Note that you will create as many item requests as there are agents matching the above criteria.\\n\"\n + \"For example, consider the above case and say you have 3 agents with greater than or equal to 2 incidents assigned to them in the chart. You will be creating '3' item requests here, one for each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n for requested_item_number in self.requested_item_numbers:\n created_request_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n \"sysparm_fields\": \"requested_for,cat_item,quantity\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_request_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"No request item created with number {requested_item_number}.\"},\n )\n elif len(created_request_item_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple request items created with number {requested_item_number}.\"\n },\n )\n created_request_item_response = created_request_item_response[0]\n if (\n created_request_item_response[\"requested_for\"][\"value\"]\n not in self.agent_value_sysids\n ):\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} created for a random agent.\"\n },\n )\n if str(created_request_item_response[\"quantity\"]) != \"1\":\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} requested incorrect number of items.\"\n },\n )\n cat_item = created_request_item_response[\"cat_item\"]\n if not cat_item:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Request item {requested_item_number} did not request an item.\"},\n )\n cat_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_cat_item\",\n params={\n \"sysparm_query\": f\"sys_id={cat_item['value']}\",\n \"sysparm_fields\": \"sys_name\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(cat_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\"message\": f\"Request item {requested_item_number} did not request an item.\"},\n )\n\n if cat_item_response[0][\"sys_name\"] != self.item:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Request item {requested_item_number} requested an incorrect item.\"\n },\n )\n\n for agent_sysid in self.agent_value_sysids:\n created_request_item_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"requested_for={agent_sysid}\",\n \"sysparm_fields\": \"requested_for\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_request_item_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No request created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_request_item_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple requests created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for requested_item_number in self.requested_item_numbers:\n created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_request_item.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_request_item.teardown#L275-L294","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":275,"end_line":294,"context_start_line":255,"context_end_line":314,"code":" return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No request created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_request_item_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple requests created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for requested_item_number in self.requested_item_numbers:\n created_item_request_response = table_api_call(\n instance=self.instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"number={requested_item_number}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_item_request_response) > 1:\n raise Exception(\"Multiple request items created\")\n if len(created_item_request_response) == 1:\n created_item_request_sysid = created_item_request_response[0][\"sys_id\"]\n db_delete_from_table(\n instance=self.instance,\n table=\"sc_req_item\",\n sys_id=created_item_request_sysid,\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMaxRequestAppleWatchTask(\n DashboardRetrieveIncidentAndRequestItemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the best performing agent and request an apple watch for them.\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible#L1-L2100","kind":"module","name":"src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1,"end_line":2100,"context_start_line":1,"context_end_line":2100,"code":"from faker import Faker\n\nfake = Faker()\nfrom functools import partial\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.form import (\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,\n CreateUserTask,\n)\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterChangeRequestListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterServiceCatalogItemListTask,\n FilterUserListTask,\n SortAssetListTask,\n SortChangeRequestListTask,\n SortHardwareListTask,\n SortIncidentListTask,\n SortServiceCatalogItemListTask,\n SortUserListTask,\n)\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nfrom .base import HumanEvalTask, InfeasibleCompositionalTask\nfrom .utils.infeasible_configs import (\n get_infeasible_form_config,\n get_infeasible_service_catalog_config,\n get_infeasible_filter_config,\n get_infeasible_sort_config,\n)\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...instance import SNowInstance\n\n\nclass InfeasibleNavigateAndDoTask(InfeasibleCompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n function: callable = None,\n provide_reason: bool = True,\n navigation_config: dict = None,\n level: int = 2,\n task_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Generic task to navigate to a specific page and perform a task.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n function: callable\n Function that takes a valid config and renders it infeasible.\n provide_reason: bool\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason.\n navigation_config: dict\n Configuration to use for the navigation task. Contains the application and the module; the URL is not necessary as the\n nav step is not validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n task: AbstractServiceNowTask\n The task to perform after navigating to the page.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.task_class = task_class\n self.task_description = None\n self.short_description = None\n # Get the navigation configuration; there is only one configuration for each application and module combo\n self.navigation_config = navigation_config\n self.function = partial(function, provide_reason=provide_reason)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n config = self.fixed_config if self.fixed_config else self._get_config()\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n valid_task_config = self.random.choice(self.task_class.all_configs())\n infeasible_task_config, self.infeasible_reasons = self.function(\n config=valid_task_config, random=self.random\n )\n config = [\n # Infeasible version of navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=infeasible_task_config,\n is_validated=False,\n has_description=True,\n used_in_level_2=self.used_in_level_2,\n ),\n ]\n\n return config\n\n\nclass InfeasibleNavigateAndCreateUserWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateUserTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass InfeasibleNavigateAndCreateUserTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateUserTask,\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass InfeasibleNavigateAndCreateIncidentWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateIncidentTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass InfeasibleNavigateAndCreateIncidentTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateIncidentTask,\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass InfeasibleNavigateAndCreateChangeRequestWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateChangeRequestTask,\n provide_reason=True,\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass InfeasibleNavigateAndCreateChangeRequestTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateChangeRequestTask,\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass InfeasibleNavigateAndCreateProblemWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateProblemTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass InfeasibleNavigateAndCreateProblemTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateProblemTask,\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass InfeasibleNavigateAndCreateHardwareAssetWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateHardwareAssetTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass InfeasibleNavigateAndCreateHardwareAssetTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateHardwareAssetTask,\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass InfeasibleNavigateAndOrderStandardLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderStandardLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderStandardLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderStandardLaptopTask,\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the servi\n# ... truncated ...","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":true} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndDoTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndDoTask#L55-L144","kind":"class","name":"InfeasibleNavigateAndDoTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":55,"end_line":144,"context_start_line":35,"context_end_line":164,"code":" OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nfrom .base import HumanEvalTask, InfeasibleCompositionalTask\nfrom .utils.infeasible_configs import (\n get_infeasible_form_config,\n get_infeasible_service_catalog_config,\n get_infeasible_filter_config,\n get_infeasible_sort_config,\n)\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...instance import SNowInstance\n\n\nclass InfeasibleNavigateAndDoTask(InfeasibleCompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n function: callable = None,\n provide_reason: bool = True,\n navigation_config: dict = None,\n level: int = 2,\n task_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Generic task to navigate to a specific page and perform a task.\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to run the task on.\n fixed_config: list[AbstractServiceNowTask]\n A list of tuples, each containing a subtask\n function: callable\n Function that takes a valid config and renders it infeasible.\n provide_reason: bool\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason.\n navigation_config: dict\n Configuration to use for the navigation task. Contains the application and the module; the URL is not necessary as the\n nav step is not validated.\n level: int\n The level of the task; choice between 2 and 3. L2 will have all the info in the the goal and start in the SNOW home page.\n L3 will start in a private task page describing the information needed to complete the task and the related company protocol\n to complete it.\n task: AbstractServiceNowTask\n The task to perform after navigating to the page.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.task_class = task_class\n self.task_description = None\n self.short_description = None\n # Get the navigation configuration; there is only one configuration for each application and module combo\n self.navigation_config = navigation_config\n self.function = partial(function, provide_reason=provide_reason)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n config = self.fixed_config if self.fixed_config else self._get_config()\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n valid_task_config = self.random.choice(self.task_class.all_configs())\n infeasible_task_config, self.infeasible_reasons = self.function(\n config=valid_task_config, random=self.random\n )\n config = [\n # Infeasible version of navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=infeasible_task_config,\n is_validated=False,\n has_description=True,\n used_in_level_2=self.used_in_level_2,\n ),\n ]\n\n return config\n\n\nclass InfeasibleNavigateAndCreateUserWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateUserWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateUserWithReasonTask#L147-L179","kind":"class","name":"InfeasibleNavigateAndCreateUserWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":147,"end_line":179,"context_start_line":127,"context_end_line":199,"code":" AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=infeasible_task_config,\n is_validated=False,\n has_description=True,\n used_in_level_2=self.used_in_level_2,\n ),\n ]\n\n return config\n\n\nclass InfeasibleNavigateAndCreateUserWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateUserTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass InfeasibleNavigateAndCreateUserTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateUserTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateUserTask#L182-L214","kind":"class","name":"InfeasibleNavigateAndCreateUserTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":182,"end_line":214,"context_start_line":162,"context_end_line":234,"code":" short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateUserTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass InfeasibleNavigateAndCreateUserTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateUserTask,\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass InfeasibleNavigateAndCreateIncidentWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateIncidentWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateIncidentWithReasonTask#L217-L249","kind":"class","name":"InfeasibleNavigateAndCreateIncidentWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":217,"end_line":249,"context_start_line":197,"context_end_line":269,"code":" short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateUserTask,\n )\n self.task_description = \"Create a new user with the required information. \\n\"\n self.short_description = \"Create a new user\"\n\n\nclass InfeasibleNavigateAndCreateIncidentWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateIncidentTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass InfeasibleNavigateAndCreateIncidentTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateIncidentTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateIncidentTask#L252-L284","kind":"class","name":"InfeasibleNavigateAndCreateIncidentTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":252,"end_line":284,"context_start_line":232,"context_end_line":304,"code":" short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateIncidentTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass InfeasibleNavigateAndCreateIncidentTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and create a new incident.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateIncidentTask,\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass InfeasibleNavigateAndCreateChangeRequestWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateChangeRequestWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateChangeRequestWithReasonTask#L287-L321","kind":"class","name":"InfeasibleNavigateAndCreateChangeRequestWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":287,"end_line":321,"context_start_line":267,"context_end_line":341,"code":" short_description: str\n A short description of the task to be completed. \"Create a new incident\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateIncidentTask,\n )\n self.task_description = \"Create a new incident with the required information. \\n\"\n self.short_description = \"Create a new incident\"\n\n\nclass InfeasibleNavigateAndCreateChangeRequestWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateChangeRequestTask,\n provide_reason=True,\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass InfeasibleNavigateAndCreateChangeRequestTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateChangeRequestTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateChangeRequestTask#L324-L358","kind":"class","name":"InfeasibleNavigateAndCreateChangeRequestTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":324,"end_line":358,"context_start_line":304,"context_end_line":378,"code":" \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateChangeRequestTask,\n provide_reason=True,\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass InfeasibleNavigateAndCreateChangeRequestTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and create a new change request.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new change request\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateChangeRequestTask,\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass InfeasibleNavigateAndCreateProblemWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateProblemWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateProblemWithReasonTask#L361-L393","kind":"class","name":"InfeasibleNavigateAndCreateProblemWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":361,"end_line":393,"context_start_line":341,"context_end_line":413,"code":" \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateChangeRequestTask,\n )\n self.task_description = (\n 'Create a new \"Normal\" change request with the required information. \\n'\n )\n self.short_description = 'Create a new \"Normal\" change request'\n\n\nclass InfeasibleNavigateAndCreateProblemWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateProblemTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass InfeasibleNavigateAndCreateProblemTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateProblemTask#L396-L428","kind":"class","name":"InfeasibleNavigateAndCreateProblemTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":396,"end_line":428,"context_start_line":376,"context_end_line":448,"code":" short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateProblemTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass InfeasibleNavigateAndCreateProblemTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the problem list page and create a new problem.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateProblemTask,\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass InfeasibleNavigateAndCreateHardwareAssetWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateHardwareAssetWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateHardwareAssetWithReasonTask#L431-L463","kind":"class","name":"InfeasibleNavigateAndCreateHardwareAssetWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":431,"end_line":463,"context_start_line":411,"context_end_line":483,"code":" short_description: str\n A short description of the task to be completed. \"Create a new problem\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateProblemTask,\n )\n self.task_description = \"Create a new problem with the required information. \\n\"\n self.short_description = \"Create a new problem\"\n\n\nclass InfeasibleNavigateAndCreateHardwareAssetWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateHardwareAssetTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass InfeasibleNavigateAndCreateHardwareAssetTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateHardwareAssetTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndCreateHardwareAssetTask#L466-L498","kind":"class","name":"InfeasibleNavigateAndCreateHardwareAssetTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":466,"end_line":498,"context_start_line":446,"context_end_line":518,"code":" short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n function=get_infeasible_form_config,\n task_class=CreateHardwareAssetTask,\n provide_reason=True,\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass InfeasibleNavigateAndCreateHardwareAssetTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and create a new hardware asset.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateHardwareAssetTask,\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass InfeasibleNavigateAndOrderStandardLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderStandardLaptopWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderStandardLaptopWithReasonTask#L501-L533","kind":"class","name":"InfeasibleNavigateAndOrderStandardLaptopWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":501,"end_line":533,"context_start_line":481,"context_end_line":553,"code":" short_description: str\n A short description of the task to be completed. \"Create a new hardware asset\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_form_config,\n task_class=CreateHardwareAssetTask,\n )\n self.task_description = \"Create a new hardware asset with the required information. \\n\"\n self.short_description = \"Create a new hardware asset\"\n\n\nclass InfeasibleNavigateAndOrderStandardLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderStandardLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderStandardLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderStandardLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderStandardLaptopTask#L536-L568","kind":"class","name":"InfeasibleNavigateAndOrderStandardLaptopTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":536,"end_line":568,"context_start_line":516,"context_end_line":588,"code":" short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderStandardLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderStandardLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a standard laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderStandardLaptopTask,\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderSalesLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a sales laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderSalesLaptopWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderSalesLaptopWithReasonTask#L571-L603","kind":"class","name":"InfeasibleNavigateAndOrderSalesLaptopWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":571,"end_line":603,"context_start_line":551,"context_end_line":623,"code":" short_description: str\n A short description of the task to be completed. \"Order a standard laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderStandardLaptopTask,\n )\n self.task_description = \"Order a standard laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a standard laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderSalesLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a sales laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderSalesLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a sales laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a sales laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderSalesLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a sales laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderSalesLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderSalesLaptopTask#L606-L638","kind":"class","name":"InfeasibleNavigateAndOrderSalesLaptopTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":606,"end_line":638,"context_start_line":586,"context_end_line":658,"code":" short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderSalesLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a sales laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a sales laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderSalesLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a sales laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderSalesLaptopTask,\n )\n self.task_description = \"Order a sales laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a sales laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderDeveloperLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a developer laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderDeveloperLaptopWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderDeveloperLaptopWithReasonTask#L641-L673","kind":"class","name":"InfeasibleNavigateAndOrderDeveloperLaptopWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":641,"end_line":673,"context_start_line":621,"context_end_line":693,"code":" short_description: str\n A short description of the task to be completed. \"Order a sales laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderSalesLaptopTask,\n )\n self.task_description = \"Order a sales laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a sales laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderDeveloperLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a developer laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderDeveloperLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a developer laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a developer laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderDeveloperLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a developer laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderDeveloperLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderDeveloperLaptopTask#L676-L708","kind":"class","name":"InfeasibleNavigateAndOrderDeveloperLaptopTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":676,"end_line":708,"context_start_line":656,"context_end_line":728,"code":" short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderDeveloperLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a developer laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a developer laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderDeveloperLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a developer laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderDeveloperLaptopTask,\n )\n self.task_description = \"Order a developer laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a developer laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderIpadProWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an iPad Pro.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderIpadProWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderIpadProWithReasonTask#L711-L743","kind":"class","name":"InfeasibleNavigateAndOrderIpadProWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":711,"end_line":743,"context_start_line":691,"context_end_line":763,"code":" short_description: str\n A short description of the task to be completed. \"Order a developer laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderDeveloperLaptopTask,\n )\n self.task_description = \"Order a developer laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a developer laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderIpadProWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an iPad Pro.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderIpadProTask,\n provide_reason=True,\n )\n self.task_description = \"Order an iPad Pro from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Pro from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderIpadProTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an iPad Pro.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderIpadProTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderIpadProTask#L746-L778","kind":"class","name":"InfeasibleNavigateAndOrderIpadProTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":746,"end_line":778,"context_start_line":726,"context_end_line":798,"code":" short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderIpadProTask,\n provide_reason=True,\n )\n self.task_description = \"Order an iPad Pro from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Pro from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderIpadProTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an iPad Pro.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderIpadProTask,\n )\n self.task_description = \"Order an iPad Pro from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Pro from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderIpadMiniWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an iPad Mini.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderIpadMiniWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderIpadMiniWithReasonTask#L781-L813","kind":"class","name":"InfeasibleNavigateAndOrderIpadMiniWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":781,"end_line":813,"context_start_line":761,"context_end_line":833,"code":" short_description: str\n A short description of the task to be completed. \"Order an iPad Pro\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderIpadProTask,\n )\n self.task_description = \"Order an iPad Pro from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Pro from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderIpadMiniWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an iPad Mini.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderIpadMiniTask,\n provide_reason=True,\n )\n self.task_description = \"Order an iPad Mini from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Mini from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderIpadMiniTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an iPad Mini.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderIpadMiniTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderIpadMiniTask#L816-L848","kind":"class","name":"InfeasibleNavigateAndOrderIpadMiniTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":816,"end_line":848,"context_start_line":796,"context_end_line":868,"code":" short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderIpadMiniTask,\n provide_reason=True,\n )\n self.task_description = \"Order an iPad Mini from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Mini from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderIpadMiniTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an iPad Mini.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderIpadMiniTask,\n )\n self.task_description = \"Order an iPad Mini from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Mini from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderAppleWatchWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an Apple Watch.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderAppleWatchWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderAppleWatchWithReasonTask#L851-L883","kind":"class","name":"InfeasibleNavigateAndOrderAppleWatchWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":851,"end_line":883,"context_start_line":831,"context_end_line":903,"code":" short_description: str\n A short description of the task to be completed. \"Order an iPad Mini\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderIpadMiniTask,\n )\n self.task_description = \"Order an iPad Mini from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an iPad Mini from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderAppleWatchWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an Apple Watch.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderAppleWatchTask,\n provide_reason=True,\n )\n self.task_description = \"Order an Apple Watch from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an Apple Watch from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderAppleWatchTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an Apple Watch.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderAppleWatchTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderAppleWatchTask#L886-L918","kind":"class","name":"InfeasibleNavigateAndOrderAppleWatchTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":886,"end_line":918,"context_start_line":866,"context_end_line":938,"code":" short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderAppleWatchTask,\n provide_reason=True,\n )\n self.task_description = \"Order an Apple Watch from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an Apple Watch from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderAppleWatchTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an Apple Watch.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderAppleWatchTask,\n )\n self.task_description = \"Order an Apple Watch from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an Apple Watch from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderAppleMacBookPro15WithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an Apple MacBook Pro 15\".\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderAppleMacBookPro15WithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderAppleMacBookPro15WithReasonTask#L921-L953","kind":"class","name":"InfeasibleNavigateAndOrderAppleMacBookPro15WithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":921,"end_line":953,"context_start_line":901,"context_end_line":973,"code":" short_description: str\n A short description of the task to be completed. \"Order an Apple Watch\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderAppleWatchTask,\n )\n self.task_description = \"Order an Apple Watch from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order an Apple Watch from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderAppleMacBookPro15WithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an Apple MacBook Pro 15\".\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderAppleMacBookPro15Task,\n provide_reason=True,\n )\n self.task_description = 'Order an Apple MacBook Pro 15\" from the service catalog with the required configuration if applicable. \\n'\n self.short_description = 'Order an Apple MacBook Pro 15\" from the service catalog'\n\n\nclass InfeasibleNavigateAndOrderAppleMacBookPro15Task(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an Apple MacBook Pro 15\".\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderAppleMacBookPro15Task","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderAppleMacBookPro15Task#L956-L988","kind":"class","name":"InfeasibleNavigateAndOrderAppleMacBookPro15Task","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":956,"end_line":988,"context_start_line":936,"context_end_line":1008,"code":" short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderAppleMacBookPro15Task,\n provide_reason=True,\n )\n self.task_description = 'Order an Apple MacBook Pro 15\" from the service catalog with the required configuration if applicable. \\n'\n self.short_description = 'Order an Apple MacBook Pro 15\" from the service catalog'\n\n\nclass InfeasibleNavigateAndOrderAppleMacBookPro15Task(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order an Apple MacBook Pro 15\".\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderAppleMacBookPro15Task,\n )\n self.task_description = 'Order an Apple MacBook Pro 15\" from the service catalog with the required configuration if applicable. \\n'\n self.short_description = 'Order an Apple MacBook Pro 15\" from the service catalog'\n\n\nclass InfeasibleNavigateAndOrderDevelopmentLaptopPCWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a development laptop PC.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderDevelopmentLaptopPCWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderDevelopmentLaptopPCWithReasonTask#L991-L1023","kind":"class","name":"InfeasibleNavigateAndOrderDevelopmentLaptopPCWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":991,"end_line":1023,"context_start_line":971,"context_end_line":1043,"code":" short_description: str\n A short description of the task to be completed. \"Order an Apple MacBook Pro 15\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderAppleMacBookPro15Task,\n )\n self.task_description = 'Order an Apple MacBook Pro 15\" from the service catalog with the required configuration if applicable. \\n'\n self.short_description = 'Order an Apple MacBook Pro 15\" from the service catalog'\n\n\nclass InfeasibleNavigateAndOrderDevelopmentLaptopPCWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a development laptop PC.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderDevelopmentLaptopPCTask,\n provide_reason=True,\n )\n self.task_description = \"Order a development laptop PC from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a development laptop PC from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderDevelopmentLaptopPCTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a development laptop PC.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderDevelopmentLaptopPCTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderDevelopmentLaptopPCTask#L1026-L1058","kind":"class","name":"InfeasibleNavigateAndOrderDevelopmentLaptopPCTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1026,"end_line":1058,"context_start_line":1006,"context_end_line":1078,"code":" short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderDevelopmentLaptopPCTask,\n provide_reason=True,\n )\n self.task_description = \"Order a development laptop PC from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a development laptop PC from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderDevelopmentLaptopPCTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a development laptop PC.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderDevelopmentLaptopPCTask,\n )\n self.task_description = \"Order a development laptop PC from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a development laptop PC from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderLoanerLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a loaner laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderLoanerLaptopWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderLoanerLaptopWithReasonTask#L1061-L1093","kind":"class","name":"InfeasibleNavigateAndOrderLoanerLaptopWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1061,"end_line":1093,"context_start_line":1041,"context_end_line":1113,"code":" short_description: str\n A short description of the task to be completed. \"Order a development laptop PC\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderDevelopmentLaptopPCTask,\n )\n self.task_description = \"Order a development laptop PC from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a development laptop PC from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderLoanerLaptopWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a loaner laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderLoanerLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a loaner laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a loaner laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderLoanerLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a loaner laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderLoanerLaptopTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndOrderLoanerLaptopTask#L1096-L1128","kind":"class","name":"InfeasibleNavigateAndOrderLoanerLaptopTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1096,"end_line":1128,"context_start_line":1076,"context_end_line":1148,"code":" short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n function=get_infeasible_service_catalog_config,\n task_class=OrderLoanerLaptopTask,\n provide_reason=True,\n )\n self.task_description = \"Order a loaner laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a loaner laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndOrderLoanerLaptopTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and order a loaner laptop.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderLoanerLaptopTask,\n )\n self.task_description = \"Order a loaner laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a loaner laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndFilterAssetListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterAssetListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterAssetListWithReasonTask#L1131-L1165","kind":"class","name":"InfeasibleNavigateAndFilterAssetListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1131,"end_line":1165,"context_start_line":1111,"context_end_line":1185,"code":" short_description: str\n A short description of the task to be completed. \"Order a loaner laptop\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Self-Service\",\n \"module\": \"Service Catalog\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_service_catalog_config,\n task_class=OrderLoanerLaptopTask,\n )\n self.task_description = \"Order a loaner laptop from the service catalog with the required configuration if applicable. \\n\"\n self.short_description = \"Order a loaner laptop from the service catalog\"\n\n\nclass InfeasibleNavigateAndFilterAssetListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterAssetListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Filter the asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterAssetListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterAssetListTask#L1168-L1202","kind":"class","name":"InfeasibleNavigateAndFilterAssetListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1168,"end_line":1202,"context_start_line":1148,"context_end_line":1222,"code":" A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterAssetListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Filter the asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterAssetListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterAssetListTask,\n )\n self.task_description = \"Filter the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Filter the asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterUserListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the user list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterUserListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterUserListWithReasonTask#L1205-L1239","kind":"class","name":"InfeasibleNavigateAndFilterUserListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1205,"end_line":1239,"context_start_line":1185,"context_end_line":1259,"code":" A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterAssetListTask,\n )\n self.task_description = \"Filter the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Filter the asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterUserListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterUserListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the user list based on specific criteria. \\n\"\n self.short_description = \"Filter the user list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterUserListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the user list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterUserListTask#L1242-L1276","kind":"class","name":"InfeasibleNavigateAndFilterUserListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1242,"end_line":1276,"context_start_line":1222,"context_end_line":1296,"code":" A short description of the task to be completed. \"Filter the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterUserListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the user list based on specific criteria. \\n\"\n self.short_description = \"Filter the user list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterUserListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterUserListTask,\n )\n self.task_description = \"Filter the user list based on specific criteria. \\n\"\n self.short_description = \"Filter the user list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterIncidentListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the incident list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterIncidentListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterIncidentListWithReasonTask#L1279-L1313","kind":"class","name":"InfeasibleNavigateAndFilterIncidentListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1279,"end_line":1313,"context_start_line":1259,"context_end_line":1333,"code":" A short description of the task to be completed. \"Filter the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterUserListTask,\n )\n self.task_description = \"Filter the user list based on specific criteria. \\n\"\n self.short_description = \"Filter the user list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterIncidentListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterIncidentListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the incident list based on specific criteria. \\n\"\n self.short_description = \"Filter the incident list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterIncidentListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the incident list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterIncidentListTask#L1316-L1350","kind":"class","name":"InfeasibleNavigateAndFilterIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1316,"end_line":1350,"context_start_line":1296,"context_end_line":1370,"code":" A short description of the task to be completed. \"Filter the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterIncidentListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the incident list based on specific criteria. \\n\"\n self.short_description = \"Filter the incident list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterIncidentListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterIncidentListTask,\n )\n self.task_description = \"Filter the incident list based on specific criteria. \\n\"\n self.short_description = \"Filter the incident list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterChangeRequestListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the change request list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterChangeRequestListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterChangeRequestListWithReasonTask#L1353-L1387","kind":"class","name":"InfeasibleNavigateAndFilterChangeRequestListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1353,"end_line":1387,"context_start_line":1333,"context_end_line":1407,"code":" A short description of the task to be completed. \"Filter the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterIncidentListTask,\n )\n self.task_description = \"Filter the incident list based on specific criteria. \\n\"\n self.short_description = \"Filter the incident list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterChangeRequestListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterChangeRequestListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the change request list based on specific criteria. \\n\"\n self.short_description = \"Filter the change request list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterChangeRequestListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the change request list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterChangeRequestListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterChangeRequestListTask#L1390-L1424","kind":"class","name":"InfeasibleNavigateAndFilterChangeRequestListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1390,"end_line":1424,"context_start_line":1370,"context_end_line":1444,"code":" A short description of the task to be completed. \"Filter the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterChangeRequestListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the change request list based on specific criteria. \\n\"\n self.short_description = \"Filter the change request list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterChangeRequestListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterChangeRequestListTask,\n )\n self.task_description = \"Filter the change request list based on specific criteria. \\n\"\n self.short_description = \"Filter the change request list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterHardwareListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the hardware asset list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterHardwareListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterHardwareListWithReasonTask#L1427-L1461","kind":"class","name":"InfeasibleNavigateAndFilterHardwareListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1427,"end_line":1461,"context_start_line":1407,"context_end_line":1481,"code":" A short description of the task to be completed. \"Filter the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterChangeRequestListTask,\n )\n self.task_description = \"Filter the change request list based on specific criteria. \\n\"\n self.short_description = \"Filter the change request list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterHardwareListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterHardwareListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Filter the hardware asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterHardwareListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the hardware asset list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterHardwareListTask#L1464-L1498","kind":"class","name":"InfeasibleNavigateAndFilterHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1464,"end_line":1498,"context_start_line":1444,"context_end_line":1518,"code":" A short description of the task to be completed. \"Filter the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterHardwareListTask,\n provide_reason=True,\n )\n self.task_description = \"Filter the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Filter the hardware asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterHardwareListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterHardwareListTask,\n )\n self.task_description = \"Filter the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Filter the hardware asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterServiceCatalogItemListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the service catalog item list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterServiceCatalogItemListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterServiceCatalogItemListWithReasonTask#L1501-L1537","kind":"class","name":"InfeasibleNavigateAndFilterServiceCatalogItemListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1501,"end_line":1537,"context_start_line":1481,"context_end_line":1557,"code":" A short description of the task to be completed. \"Filter the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterHardwareListTask,\n )\n self.task_description = \"Filter the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Filter the hardware asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterServiceCatalogItemListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterServiceCatalogItemListTask,\n provide_reason=True,\n )\n self.task_description = (\n \"Filter the service catalog item list based on specific criteria. \\n\"\n )\n self.short_description = \"Filter the service catalog item list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterServiceCatalogItemListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the service catalog item list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterServiceCatalogItemListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndFilterServiceCatalogItemListTask#L1540-L1576","kind":"class","name":"InfeasibleNavigateAndFilterServiceCatalogItemListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1540,"end_line":1576,"context_start_line":1520,"context_end_line":1596,"code":" super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n function=get_infeasible_filter_config,\n task_class=FilterServiceCatalogItemListTask,\n provide_reason=True,\n )\n self.task_description = (\n \"Filter the service catalog item list based on specific criteria. \\n\"\n )\n self.short_description = \"Filter the service catalog item list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndFilterServiceCatalogItemListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and filter the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterServiceCatalogItemListTask,\n )\n self.task_description = (\n \"Filter the service catalog item list based on specific criteria. \\n\"\n )\n self.short_description = \"Filter the service catalog item list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortAssetListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortAssetListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortAssetListWithReasonTask#L1579-L1613","kind":"class","name":"InfeasibleNavigateAndSortAssetListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1579,"end_line":1613,"context_start_line":1559,"context_end_line":1633,"code":" super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_filter_config,\n task_class=FilterServiceCatalogItemListTask,\n )\n self.task_description = (\n \"Filter the service catalog item list based on specific criteria. \\n\"\n )\n self.short_description = \"Filter the service catalog item list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortAssetListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortAssetListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Sort the asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortAssetListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortAssetListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortAssetListTask#L1616-L1650","kind":"class","name":"InfeasibleNavigateAndSortAssetListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1616,"end_line":1650,"context_start_line":1596,"context_end_line":1670,"code":" A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortAssetListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Sort the asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortAssetListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"alm_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortAssetListTask,\n )\n self.task_description = \"Sort the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Sort the asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortUserListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the user list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortUserListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortUserListWithReasonTask#L1653-L1687","kind":"class","name":"InfeasibleNavigateAndSortUserListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1653,"end_line":1687,"context_start_line":1633,"context_end_line":1707,"code":" A short description of the task to be completed. \"Filter the asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > All Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortAssetListTask,\n )\n self.task_description = \"Sort the asset list - in Asset > Portflios > All Assets - based on specific criteria. \\n\"\n self.short_description = \"Sort the asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortUserListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortUserListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the user list based on specific criteria. \\n\"\n self.short_description = \"Sort the user list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortUserListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the user list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortUserListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortUserListTask#L1690-L1724","kind":"class","name":"InfeasibleNavigateAndSortUserListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1690,"end_line":1724,"context_start_line":1670,"context_end_line":1744,"code":" A short description of the task to be completed. \"Sort the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortUserListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the user list based on specific criteria. \\n\"\n self.short_description = \"Sort the user list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortUserListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"user\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortUserListTask,\n )\n self.task_description = \"Sort the user list based on specific criteria. \\n\"\n self.short_description = \"Sort the user list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortIncidentListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the incident list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortIncidentListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortIncidentListWithReasonTask#L1727-L1761","kind":"class","name":"InfeasibleNavigateAndSortIncidentListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1727,"end_line":1761,"context_start_line":1707,"context_end_line":1781,"code":" A short description of the task to be completed. \"Sort the user list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Organization\",\n \"module\": \"Users\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortUserListTask,\n )\n self.task_description = \"Sort the user list based on specific criteria. \\n\"\n self.short_description = \"Sort the user list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortIncidentListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortIncidentListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the incident list based on specific criteria. \\n\"\n self.short_description = \"Sort the incident list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortIncidentListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the incident list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortIncidentListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortIncidentListTask#L1764-L1798","kind":"class","name":"InfeasibleNavigateAndSortIncidentListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1764,"end_line":1798,"context_start_line":1744,"context_end_line":1818,"code":" A short description of the task to be completed. \"Sort the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortIncidentListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the incident list based on specific criteria. \\n\"\n self.short_description = \"Sort the incident list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortIncidentListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"incident\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the incident list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortIncidentListTask,\n )\n self.task_description = \"Sort the incident list based on specific criteria. \\n\"\n self.short_description = \"Sort the incident list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortChangeRequestListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the change request list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortChangeRequestListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortChangeRequestListWithReasonTask#L1801-L1835","kind":"class","name":"InfeasibleNavigateAndSortChangeRequestListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1801,"end_line":1835,"context_start_line":1781,"context_end_line":1855,"code":" A short description of the task to be completed. \"Sort the incident list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Desk\",\n \"module\": \"Incidents\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortIncidentListTask,\n )\n self.task_description = \"Sort the incident list based on specific criteria. \\n\"\n self.short_description = \"Sort the incident list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortChangeRequestListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortChangeRequestListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the change request list based on specific criteria. \\n\"\n self.short_description = \"Sort the change request list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortChangeRequestListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the change request list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortChangeRequestListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortChangeRequestListTask#L1838-L1872","kind":"class","name":"InfeasibleNavigateAndSortChangeRequestListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1838,"end_line":1872,"context_start_line":1818,"context_end_line":1892,"code":" A short description of the task to be completed. \"Sort the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortChangeRequestListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the change request list based on specific criteria. \\n\"\n self.short_description = \"Sort the change request list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortChangeRequestListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"change_request\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the change request list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortChangeRequestListTask,\n )\n self.task_description = \"Sort the change request list based on specific criteria. \\n\"\n self.short_description = \"Sort the change request list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortHardwareListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the hardware asset list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortHardwareListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortHardwareListWithReasonTask#L1875-L1909","kind":"class","name":"InfeasibleNavigateAndSortHardwareListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1875,"end_line":1909,"context_start_line":1855,"context_end_line":1929,"code":" A short description of the task to be completed. \"Sort the change request list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Change\",\n \"module\": \"All\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortChangeRequestListTask,\n )\n self.task_description = \"Sort the change request list based on specific criteria. \\n\"\n self.short_description = \"Sort the change request list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortHardwareListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortHardwareListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Sort the hardware asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortHardwareListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the hardware asset list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortHardwareListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortHardwareListTask#L1912-L1946","kind":"class","name":"InfeasibleNavigateAndSortHardwareListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1912,"end_line":1946,"context_start_line":1892,"context_end_line":1966,"code":" A short description of the task to be completed. \"Sort the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortHardwareListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Sort the hardware asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortHardwareListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"hardware_asset\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the hardware asset list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortHardwareListTask,\n )\n self.task_description = \"Sort the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Sort the hardware asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortServiceCatalogItemListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the service catalog item list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortServiceCatalogItemListWithReasonTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortServiceCatalogItemListWithReasonTask#L1949-L1983","kind":"class","name":"InfeasibleNavigateAndSortServiceCatalogItemListWithReasonTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1949,"end_line":1983,"context_start_line":1929,"context_end_line":2003,"code":" A short description of the task to be completed. \"Sort the hardware asset list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Asset\",\n \"module\": \"Portfolios > Hardware Assets\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortHardwareListTask,\n )\n self.task_description = \"Sort the hardware asset list based on specific criteria. \\n\"\n self.short_description = \"Sort the hardware asset list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortServiceCatalogItemListWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortServiceCatalogItemListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the service catalog item list based on specific criteria. \\n\"\n self.short_description = \"Sort the service catalog item list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortServiceCatalogItemListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the service catalog item list\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortServiceCatalogItemListTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.InfeasibleNavigateAndSortServiceCatalogItemListTask#L1986-L2020","kind":"class","name":"InfeasibleNavigateAndSortServiceCatalogItemListTask","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1986,"end_line":2020,"context_start_line":1966,"context_end_line":2040,"code":" A short description of the task to be completed. \"Sort the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortServiceCatalogItemListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the service catalog item list based on specific criteria. \\n\"\n self.short_description = \"Sort the service catalog item list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortServiceCatalogItemListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortServiceCatalogItemListTask,\n )\n self.task_description = \"Sort the service catalog item list based on specific criteria. \\n\"\n self.short_description = \"Sort the service catalog item list.\"\n self.list_name = list_name\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, InfeasibleNavigateAndDoTask)\n and var is not InfeasibleNavigateAndDoTask\n]\n\nINFEASIBLE_NAVIGATE_AND_CREATE_WITH_REASON = [\n InfeasibleNavigateAndCreateUserWithReasonTask,\n InfeasibleNavigateAndCreateIncidentWithReasonTask,\n InfeasibleNavigateAndCreateChangeRequestWithReasonTask,\n InfeasibleNavigateAndCreateProblemWithReasonTask,\n InfeasibleNavigateAndCreateHardwareAssetWithReasonTask,\n]\nINFEASIBLE_NAVIGATE_AND_CREATE = [","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.__init__#L1987-L2020","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1987,"end_line":2020,"context_start_line":1967,"context_end_line":2040,"code":" \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n function=get_infeasible_sort_config,\n task_class=SortServiceCatalogItemListTask,\n provide_reason=True,\n )\n self.task_description = \"Sort the service catalog item list based on specific criteria. \\n\"\n self.short_description = \"Sort the service catalog item list.\"\n self.list_name = list_name\n\n\nclass InfeasibleNavigateAndSortServiceCatalogItemListTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n list_name: str = \"service_catalog_item\",\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the service catalog item list page and sort the list based on a specific criteria.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Sort the service catalog item list\"\n \"\"\"\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n navigation_config={\n \"application\": \"Service Catalog\",\n \"module\": \"Catalog Definitions > Maintain Items\",\n },\n level=level,\n provide_reason=False,\n function=get_infeasible_sort_config,\n task_class=SortServiceCatalogItemListTask,\n )\n self.task_description = \"Sort the service catalog item list based on specific criteria. \\n\"\n self.short_description = \"Sort the service catalog item list.\"\n self.list_name = list_name\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type)\n and issubclass(var, InfeasibleNavigateAndDoTask)\n and var is not InfeasibleNavigateAndDoTask\n]\n\nINFEASIBLE_NAVIGATE_AND_CREATE_WITH_REASON = [\n InfeasibleNavigateAndCreateUserWithReasonTask,\n InfeasibleNavigateAndCreateIncidentWithReasonTask,\n InfeasibleNavigateAndCreateChangeRequestWithReasonTask,\n InfeasibleNavigateAndCreateProblemWithReasonTask,\n InfeasibleNavigateAndCreateHardwareAssetWithReasonTask,\n]\nINFEASIBLE_NAVIGATE_AND_CREATE = [","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible.setup_goal#L114-L118","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":114,"end_line":118,"context_start_line":94,"context_end_line":138,"code":" The start of the task description to be completed. Provided by the child class.\n short_description: str\n A short description of the task to be completed. \"Create a new user\". Provided by the child class.\n \"\"\"\n assert level in [2, 3], \"Level must be either 2 or 3\"\n self.level = level\n super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.task_class = task_class\n self.task_description = None\n self.short_description = None\n # Get the navigation configuration; there is only one configuration for each application and module combo\n self.navigation_config = navigation_config\n self.function = partial(function, provide_reason=provide_reason)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n config = self.fixed_config if self.fixed_config else self._get_config()\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n valid_task_config = self.random.choice(self.task_class.all_configs())\n infeasible_task_config, self.infeasible_reasons = self.function(\n config=valid_task_config, random=self.random\n )\n config = [\n # Infeasible version of navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=infeasible_task_config,\n is_validated=False,","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible._get_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.navigate_and_do_infeasible._get_config#L120-L144","kind":"function","name":"_get_config","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":120,"end_line":144,"context_start_line":100,"context_end_line":164,"code":" super().__init__(\n seed=seed,\n instance=instance,\n fixed_config=fixed_config,\n level=level,\n )\n self.used_in_level_2 = self.level == 2\n self.task_class = task_class\n self.task_description = None\n self.short_description = None\n # Get the navigation configuration; there is only one configuration for each application and module combo\n self.navigation_config = navigation_config\n self.function = partial(function, provide_reason=provide_reason)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n config = self.fixed_config if self.fixed_config else self._get_config()\n goal, info = super().setup_goal(page=page, config=config)\n\n return goal, info\n\n def _get_config(self) -> list[AbstractServiceNowTask]:\n valid_task_config = self.random.choice(self.task_class.all_configs())\n infeasible_task_config, self.infeasible_reasons = self.function(\n config=valid_task_config, random=self.random\n )\n config = [\n # Infeasible version of navigate to the task start page\n AllMenuTask(\n instance=self.instance,\n fixed_config=self.navigation_config,\n is_validated=False,\n used_in_level_2=True,\n has_description=True,\n ),\n self.task_class(\n seed=self.seed,\n instance=self.instance,\n fixed_config=infeasible_task_config,\n is_validated=False,\n has_description=True,\n used_in_level_2=self.used_in_level_2,\n ),\n ]\n\n return config\n\n\nclass InfeasibleNavigateAndCreateUserWithReasonTask(InfeasibleNavigateAndDoTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Infeasible version of navigate to the user list page and create a new user.\n\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a new user\"\n \"\"\"","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.delete_record#L1-L341","kind":"module","name":"src.browsergym.workarena.tasks.compositional.delete_record","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":1,"end_line":341,"context_start_line":1,"context_end_line":341,"code":"import faker\n\nfaker = faker.Faker()\nimport json\n\nfrom playwright.sync_api import Page\nfrom typing import List, Tuple\n\nfrom .base import AbstractServiceNowTask\n\nfrom ..utils.utils import check_url_suffix_match\n\nfrom ...api.utils import db_delete_from_table, table_api_call\n\n\nclass DeleteRecordTask(AbstractServiceNowTask):\n \"\"\"\n Delete a record from a list.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the list containing the record to delete.\n list_name: str\n The displayed name of the list containing the record to delete.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n all_configs: list[dict]\n A list of all possible configurations to use for the task.\n record_sys_id: str\n The sys_id of the record to delete. If not provided, a record will be created during the setup.\n record_number: str\n The number of the record to delete; used in the cheat. If not provided, the cheat will select the last one.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n start_rel_url: str = \"\",\n list_name: str = \"\",\n fixed_config: dict = None,\n all_configs: list[dict] = None,\n record_sys_id: str = None,\n record_number: str = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.list_name = list_name\n self.table_name = start_rel_url.split(\"/\")[-1].split(\"_list.do\")[0]\n self.fixed_config = fixed_config\n self.config = None\n self.pretty_printed_field_name = None\n self.field_name = None\n self.field_value = None\n self.other_fields = None\n self.all_configs = all_configs\n # If the record_sys_id is not provided, it will be created during the setup\n self.record_sys_id = record_sys_id\n self.record_number = record_number\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.field_name = self.config.get(\"field_name\")\n self.pretty_printed_field_name = self.config.get(\"pretty_printed_field_name\")\n self.field_value = self.config.get(\"field_value\")\n self.other_fields = self.config.get(\"other_fields\")\n if self.record_sys_id is None:\n # First, check if the record already exists\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n if len(record) > 0:\n raise ValueError(\n f\"Record already with {self.field_name} = {self.field_value} exists. Please delete it before proceeding.\"\n )\n\n self.record_sys_id = table_api_call(\n instance=self.instance,\n table=self.table_name,\n data=json.dumps(\n {\n self.field_name: self.field_value,\n **self.other_fields,\n }\n ),\n method=\"POST\",\n )[\"result\"][\"sys_id\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Delete the record with {self.pretty_printed_field_name}={self.field_value} from the {self.list_name} list.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n\n # If the record number is provided, click on the record with that number...\n if self.record_number is not None:\n frame.locator(f\"[aria-label='Preview record: {self.record_number}']\").click()\n page.wait_for_timeout(500)\n frame.get_by_text(\"Open Record\").click()\n # ....Otherwise, otherwise filter the list and click on the record\n else:\n # Search for the record\n frame.get_by_label(\n f\"Search a specific field of the {self.list_name} list\"\n ).select_option(f\"{self.field_name}\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(self.field_value)\n search_input.press(\"Enter\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n # Click on the record to open it\n # The first 2 displays of the record are in the search bar; the 3rd and last will be the link to open it\n frame.get_by_label(self.field_value).last.click()\n\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Click on delete, then confirm delete in the popup\n frame.get_by_text(\"delete\").first.click()\n frame.wait_for_selector('header[aria-label=\"Confirmation\"]')\n page.keyboard.press(\"Enter\")\n # Wait for record to be updated in the DB\n record_deleted = False\n while not record_deleted:\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n record_deleted = len(record) == 0\n page.wait_for_timeout(3000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\"sysparm_query\": f\"{self.field_name}={self.field_value}\"},\n )[\"result\"]\n if len(record) > 0:\n return 0, False, \"\", {\"message\": \"Record was not deleted.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Record was deleted successfully.\"}\n\n def teardown(self) -> None:\n super().teardown()\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )\n if len(result[\"result\"]) > 0:\n db_delete_from_table(\n instance=self.instance,\n table=self.table_name,\n sys_id=self.record_sys_id,\n )\n\n\nclass DeleteUserTask(DeleteRecordTask):\n def __init__(self, instance=None, fixed_config=None, record_sys_id=None, **kwargs) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/sys_user_list.do\",\n list_name=\"Users\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n if fixed_config is None:\n first_name = faker.first_name()\n last_name = faker.last_name()\n email = first_name.lower() + \".\" + last_name.lower() + \"@workarena.com\"\n self.fixed_config = {\n \"field_name\": \"user_name\",\n \"pretty_printed_field_name\": \"User ID\",\n \"field_value\": first_name + \" \" + last_name,\n \"other_fields\": {\"email\": email},\n }\n\n\nclass DeleteExpenseLineExpenseManagementTask(DeleteRecordTask):\n \"\"\"\n Delete one row from the expense lines list\n\n Args:\n --------\n goal_type (str):\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\"\n level (int):\n The level of the task\n skip_description (bool):\n Whether to skip the description of the task\n\n \"\"\"\n\n def __init__(\n self,\n instance=None,\n fixed_config=None,\n record_sys_id=None,\n goal_type=\"base\",\n level=2,\n skip_description=False,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n list_name=\"Expense Lines\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n self.goal_type = goal_type\n self.level = level\n self.skip_description = skip_description\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"Delete expense lines with duplicated short descriptions\"\n if self.skip_description:\n task_info = \"\"\n elif self.level == 3:\n task_info += f\" according to the protocol.\"\n elif self.goal_type == \"base\":\n task_info += f\" where the duplicated expense lines are not associated with tasks.\"\n elif self.goal_type == \"date\":\n task_info += f\", keeping only the one that has the oldest date.\"\n elif self.goal_type == \"amount\":\n task_info += f\", keeping only the most expensive duplicate.\"\n elif self.goal_type == \"any\":\n task_info += f\", keeping only one.\"\n\n return task_info\n\n\nclass DeleteExpenseLineKnapsack(DeleteRecordTask):\n \"\"\"\n Delete one row from the expense lines list\n\n Args:\n --------\n goal_type (str):\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\"\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n level (int):\n The level of the task\n skip_description (bool):\n Whether to skip the description of the task\n\n \"\"\"\n\n def __init__(\n self,\n instance=None,\n fixed_config=None,\n record_sys_id=None,\n goal_type=\"base\",\n level=2,\n answer_format=None,\n skip_description=False,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n list_name=\"Expense Lines\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n self.goal_type = goal_type\n self.level = level\n self.answer_format = answer_format\n self.skip_description = skip_description\n\n def get_pretty_printed_description(self) -> str:\n if self.skip_description:\n return \"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget}. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the number of the investments in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the numbers of the investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain as well as returning their total value in the chat.\"\n\n return task_info\n\n\n__TASKS__ = [DeleteUserTask]","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.DeleteRecordTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.delete_record.DeleteRecordTask#L16-L195","kind":"class","name":"DeleteRecordTask","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":16,"end_line":195,"context_start_line":1,"context_end_line":215,"code":"import faker\n\nfaker = faker.Faker()\nimport json\n\nfrom playwright.sync_api import Page\nfrom typing import List, Tuple\n\nfrom .base import AbstractServiceNowTask\n\nfrom ..utils.utils import check_url_suffix_match\n\nfrom ...api.utils import db_delete_from_table, table_api_call\n\n\nclass DeleteRecordTask(AbstractServiceNowTask):\n \"\"\"\n Delete a record from a list.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the list containing the record to delete.\n list_name: str\n The displayed name of the list containing the record to delete.\n fixed_config: dict\n Configuration to use for the task. If provided, the task will use the provided configuration instead of\n selecting a random one. See browsergym/workarena/data_files/task_configs/filter_change_request_list_task.json\n for an example of a configuration file.\n all_configs: list[dict]\n A list of all possible configurations to use for the task.\n record_sys_id: str\n The sys_id of the record to delete. If not provided, a record will be created during the setup.\n record_number: str\n The number of the record to delete; used in the cheat. If not provided, the cheat will select the last one.\n \"\"\"\n\n def __init__(\n self,\n seed: int = None,\n instance=None,\n start_rel_url: str = \"\",\n list_name: str = \"\",\n fixed_config: dict = None,\n all_configs: list[dict] = None,\n record_sys_id: str = None,\n record_number: str = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.list_name = list_name\n self.table_name = start_rel_url.split(\"/\")[-1].split(\"_list.do\")[0]\n self.fixed_config = fixed_config\n self.config = None\n self.pretty_printed_field_name = None\n self.field_name = None\n self.field_value = None\n self.other_fields = None\n self.all_configs = all_configs\n # If the record_sys_id is not provided, it will be created during the setup\n self.record_sys_id = record_sys_id\n self.record_number = record_number\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.field_name = self.config.get(\"field_name\")\n self.pretty_printed_field_name = self.config.get(\"pretty_printed_field_name\")\n self.field_value = self.config.get(\"field_value\")\n self.other_fields = self.config.get(\"other_fields\")\n if self.record_sys_id is None:\n # First, check if the record already exists\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n if len(record) > 0:\n raise ValueError(\n f\"Record already with {self.field_name} = {self.field_value} exists. Please delete it before proceeding.\"\n )\n\n self.record_sys_id = table_api_call(\n instance=self.instance,\n table=self.table_name,\n data=json.dumps(\n {\n self.field_name: self.field_value,\n **self.other_fields,\n }\n ),\n method=\"POST\",\n )[\"result\"][\"sys_id\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Delete the record with {self.pretty_printed_field_name}={self.field_value} from the {self.list_name} list.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n\n # If the record number is provided, click on the record with that number...\n if self.record_number is not None:\n frame.locator(f\"[aria-label='Preview record: {self.record_number}']\").click()\n page.wait_for_timeout(500)\n frame.get_by_text(\"Open Record\").click()\n # ....Otherwise, otherwise filter the list and click on the record\n else:\n # Search for the record\n frame.get_by_label(\n f\"Search a specific field of the {self.list_name} list\"\n ).select_option(f\"{self.field_name}\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(self.field_value)\n search_input.press(\"Enter\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n # Click on the record to open it\n # The first 2 displays of the record are in the search bar; the 3rd and last will be the link to open it\n frame.get_by_label(self.field_value).last.click()\n\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Click on delete, then confirm delete in the popup\n frame.get_by_text(\"delete\").first.click()\n frame.wait_for_selector('header[aria-label=\"Confirmation\"]')\n page.keyboard.press(\"Enter\")\n # Wait for record to be updated in the DB\n record_deleted = False\n while not record_deleted:\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n record_deleted = len(record) == 0\n page.wait_for_timeout(3000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\"sysparm_query\": f\"{self.field_name}={self.field_value}\"},\n )[\"result\"]\n if len(record) > 0:\n return 0, False, \"\", {\"message\": \"Record was not deleted.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Record was deleted successfully.\"}\n\n def teardown(self) -> None:\n super().teardown()\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )\n if len(result[\"result\"]) > 0:\n db_delete_from_table(\n instance=self.instance,\n table=self.table_name,\n sys_id=self.record_sys_id,\n )\n\n\nclass DeleteUserTask(DeleteRecordTask):\n def __init__(self, instance=None, fixed_config=None, record_sys_id=None, **kwargs) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/sys_user_list.do\",\n list_name=\"Users\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n if fixed_config is None:\n first_name = faker.first_name()\n last_name = faker.last_name()\n email = first_name.lower() + \".\" + last_name.lower() + \"@workarena.com\"\n self.fixed_config = {\n \"field_name\": \"user_name\",\n \"pretty_printed_field_name\": \"User ID\",\n \"field_value\": first_name + \" \" + last_name,","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.DeleteUserTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.delete_record.DeleteUserTask#L198-L217","kind":"class","name":"DeleteUserTask","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":198,"end_line":217,"context_start_line":178,"context_end_line":237,"code":" return 1, True, \"Nice work, thank you!\", {\"message\": \"Record was deleted successfully.\"}\n\n def teardown(self) -> None:\n super().teardown()\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )\n if len(result[\"result\"]) > 0:\n db_delete_from_table(\n instance=self.instance,\n table=self.table_name,\n sys_id=self.record_sys_id,\n )\n\n\nclass DeleteUserTask(DeleteRecordTask):\n def __init__(self, instance=None, fixed_config=None, record_sys_id=None, **kwargs) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/sys_user_list.do\",\n list_name=\"Users\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n if fixed_config is None:\n first_name = faker.first_name()\n last_name = faker.last_name()\n email = first_name.lower() + \".\" + last_name.lower() + \"@workarena.com\"\n self.fixed_config = {\n \"field_name\": \"user_name\",\n \"pretty_printed_field_name\": \"User ID\",\n \"field_value\": first_name + \" \" + last_name,\n \"other_fields\": {\"email\": email},\n }\n\n\nclass DeleteExpenseLineExpenseManagementTask(DeleteRecordTask):\n \"\"\"\n Delete one row from the expense lines list\n\n Args:\n --------\n goal_type (str):\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\"\n level (int):\n The level of the task\n skip_description (bool):\n Whether to skip the description of the task\n\n \"\"\"\n\n def __init__(\n self,\n instance=None,","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.DeleteExpenseLineExpenseManagementTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.delete_record.DeleteExpenseLineExpenseManagementTask#L220-L276","kind":"class","name":"DeleteExpenseLineExpenseManagementTask","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":220,"end_line":276,"context_start_line":200,"context_end_line":296,"code":" super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/sys_user_list.do\",\n list_name=\"Users\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n if fixed_config is None:\n first_name = faker.first_name()\n last_name = faker.last_name()\n email = first_name.lower() + \".\" + last_name.lower() + \"@workarena.com\"\n self.fixed_config = {\n \"field_name\": \"user_name\",\n \"pretty_printed_field_name\": \"User ID\",\n \"field_value\": first_name + \" \" + last_name,\n \"other_fields\": {\"email\": email},\n }\n\n\nclass DeleteExpenseLineExpenseManagementTask(DeleteRecordTask):\n \"\"\"\n Delete one row from the expense lines list\n\n Args:\n --------\n goal_type (str):\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\"\n level (int):\n The level of the task\n skip_description (bool):\n Whether to skip the description of the task\n\n \"\"\"\n\n def __init__(\n self,\n instance=None,\n fixed_config=None,\n record_sys_id=None,\n goal_type=\"base\",\n level=2,\n skip_description=False,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n list_name=\"Expense Lines\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n self.goal_type = goal_type\n self.level = level\n self.skip_description = skip_description\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"Delete expense lines with duplicated short descriptions\"\n if self.skip_description:\n task_info = \"\"\n elif self.level == 3:\n task_info += f\" according to the protocol.\"\n elif self.goal_type == \"base\":\n task_info += f\" where the duplicated expense lines are not associated with tasks.\"\n elif self.goal_type == \"date\":\n task_info += f\", keeping only the one that has the oldest date.\"\n elif self.goal_type == \"amount\":\n task_info += f\", keeping only the most expensive duplicate.\"\n elif self.goal_type == \"any\":\n task_info += f\", keeping only one.\"\n\n return task_info\n\n\nclass DeleteExpenseLineKnapsack(DeleteRecordTask):\n \"\"\"\n Delete one row from the expense lines list\n\n Args:\n --------\n goal_type (str):\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\"\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n level (int):\n The level of the task\n skip_description (bool):\n Whether to skip the description of the task\n\n \"\"\"\n\n def __init__(","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.DeleteExpenseLineKnapsack","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.delete_record.DeleteExpenseLineKnapsack#L279-L338","kind":"class","name":"DeleteExpenseLineKnapsack","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":279,"end_line":338,"context_start_line":259,"context_end_line":341,"code":" Get the task info for this task when used in a private task; Used in compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"Delete expense lines with duplicated short descriptions\"\n if self.skip_description:\n task_info = \"\"\n elif self.level == 3:\n task_info += f\" according to the protocol.\"\n elif self.goal_type == \"base\":\n task_info += f\" where the duplicated expense lines are not associated with tasks.\"\n elif self.goal_type == \"date\":\n task_info += f\", keeping only the one that has the oldest date.\"\n elif self.goal_type == \"amount\":\n task_info += f\", keeping only the most expensive duplicate.\"\n elif self.goal_type == \"any\":\n task_info += f\", keeping only one.\"\n\n return task_info\n\n\nclass DeleteExpenseLineKnapsack(DeleteRecordTask):\n \"\"\"\n Delete one row from the expense lines list\n\n Args:\n --------\n goal_type (str):\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\"\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n level (int):\n The level of the task\n skip_description (bool):\n Whether to skip the description of the task\n\n \"\"\"\n\n def __init__(\n self,\n instance=None,\n fixed_config=None,\n record_sys_id=None,\n goal_type=\"base\",\n level=2,\n answer_format=None,\n skip_description=False,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n list_name=\"Expense Lines\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n self.goal_type = goal_type\n self.level = level\n self.answer_format = answer_format\n self.skip_description = skip_description\n\n def get_pretty_printed_description(self) -> str:\n if self.skip_description:\n return \"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget}. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the number of the investments in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the numbers of the investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain as well as returning their total value in the chat.\"\n\n return task_info\n\n\n__TASKS__ = [DeleteUserTask]","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.delete_record.__init__#L296-L318","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":296,"end_line":318,"context_start_line":276,"context_end_line":338,"code":" return task_info\n\n\nclass DeleteExpenseLineKnapsack(DeleteRecordTask):\n \"\"\"\n Delete one row from the expense lines list\n\n Args:\n --------\n goal_type (str):\n The type of goal to generate. Choice of \"base\", \"date\", \"amount\", \"any\"\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n level (int):\n The level of the task\n skip_description (bool):\n Whether to skip the description of the task\n\n \"\"\"\n\n def __init__(\n self,\n instance=None,\n fixed_config=None,\n record_sys_id=None,\n goal_type=\"base\",\n level=2,\n answer_format=None,\n skip_description=False,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n list_name=\"Expense Lines\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n self.goal_type = goal_type\n self.level = level\n self.answer_format = answer_format\n self.skip_description = skip_description\n\n def get_pretty_printed_description(self) -> str:\n if self.skip_description:\n return \"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget}. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the number of the investments in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the numbers of the investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain as well as returning their total value in the chat.\"\n\n return task_info","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.delete_record.setup_goal#L67-L104","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":67,"end_line":104,"context_start_line":47,"context_end_line":124,"code":" all_configs: list[dict] = None,\n record_sys_id: str = None,\n record_number: str = None,\n **kwargs,\n ) -> None:\n super().__init__(seed=seed, instance=instance, start_rel_url=start_rel_url)\n self.list_name = list_name\n self.table_name = start_rel_url.split(\"/\")[-1].split(\"_list.do\")[0]\n self.fixed_config = fixed_config\n self.config = None\n self.pretty_printed_field_name = None\n self.field_name = None\n self.field_value = None\n self.other_fields = None\n self.all_configs = all_configs\n # If the record_sys_id is not provided, it will be created during the setup\n self.record_sys_id = record_sys_id\n self.record_number = record_number\n self.__dict__.update(kwargs)\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.config = (\n self.fixed_config if self.fixed_config else self.random.choice(self.all_configs)\n )\n self.field_name = self.config.get(\"field_name\")\n self.pretty_printed_field_name = self.config.get(\"pretty_printed_field_name\")\n self.field_value = self.config.get(\"field_value\")\n self.other_fields = self.config.get(\"other_fields\")\n if self.record_sys_id is None:\n # First, check if the record already exists\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n if len(record) > 0:\n raise ValueError(\n f\"Record already with {self.field_name} = {self.field_value} exists. Please delete it before proceeding.\"\n )\n\n self.record_sys_id = table_api_call(\n instance=self.instance,\n table=self.table_name,\n data=json.dumps(\n {\n self.field_name: self.field_value,\n **self.other_fields,\n }\n ),\n method=\"POST\",\n )[\"result\"][\"sys_id\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Delete the record with {self.pretty_printed_field_name}={self.field_value} from the {self.list_name} list.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n\n # If the record number is provided, click on the record with that number...\n if self.record_number is not None:\n frame.locator(f\"[aria-label='Preview record: {self.record_number}']\").click()","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.get_init_scripts","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.delete_record.get_init_scripts#L106-L107","kind":"function","name":"get_init_scripts","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":106,"end_line":107,"context_start_line":86,"context_end_line":127,"code":" raise ValueError(\n f\"Record already with {self.field_name} = {self.field_value} exists. Please delete it before proceeding.\"\n )\n\n self.record_sys_id = table_api_call(\n instance=self.instance,\n table=self.table_name,\n data=json.dumps(\n {\n self.field_name: self.field_value,\n **self.other_fields,\n }\n ),\n method=\"POST\",\n )[\"result\"][\"sys_id\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Delete the record with {self.pretty_printed_field_name}={self.field_value} from the {self.list_name} list.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n\n # If the record number is provided, click on the record with that number...\n if self.record_number is not None:\n frame.locator(f\"[aria-label='Preview record: {self.record_number}']\").click()\n page.wait_for_timeout(500)\n frame.get_by_text(\"Open Record\").click()\n # ....Otherwise, otherwise filter the list and click on the record","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.get_pretty_printed_description","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.delete_record.get_pretty_printed_description#L320-L338","kind":"function","name":"get_pretty_printed_description","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":320,"end_line":338,"context_start_line":300,"context_end_line":341,"code":" record_sys_id=None,\n goal_type=\"base\",\n level=2,\n answer_format=None,\n skip_description=False,\n **kwargs,\n ) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/fm_expense_line_list.do\",\n list_name=\"Expense Lines\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n self.goal_type = goal_type\n self.level = level\n self.answer_format = answer_format\n self.skip_description = skip_description\n\n def get_pretty_printed_description(self) -> str:\n if self.skip_description:\n return \"\"\n if self.level == 3:\n task_info = \"Allocate the budget to maximize revenue.\"\n elif self.level == 2:\n task_info = f\"Allocate the budget to maximize revenue. This involves going over expense lines and identifying the ones maximizing revenue while fitting in the allowed budget of {self.budget}. The returns are written in their short description.\"\n if self.answer_format == \"total_return_only\":\n task_info += \" Provide only the total return of the investments in the chat.\"\n if self.answer_format == \"total_return_and_investments\":\n task_info += \" Provide the total return of the investments as well as the number of the investments in the chat.\"\n if self.answer_format == \"investments_only\":\n task_info += \" Provide only the numbers of the investments in the chat.\"\n if self.answer_format == \"cleanup\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain.\"\n if self.answer_format == \"cleanup_and_return\":\n task_info += \" Delete the investments that will not be kept so that only the selected investments remain as well as returning their total value in the chat.\"\n\n return task_info\n\n\n__TASKS__ = [DeleteUserTask]","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.delete_record.cheat#L118-L164","kind":"function","name":"cheat","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":118,"end_line":164,"context_start_line":98,"context_end_line":184,"code":" ),\n method=\"POST\",\n )[\"result\"][\"sys_id\"]\n\n goal = self.get_pretty_printed_description()\n\n return goal, {}\n\n def get_init_scripts(self) -> List[str]:\n return super().get_init_scripts() + [\"registerGsftMainLoaded();\"]\n\n def get_pretty_printed_description(self) -> str:\n \"\"\"\n Get the task info for this task when used in a private task; Used in L3 compositional tasks.\n called by subclasses\n \"\"\"\n task_info = f\"- Delete the record with {self.pretty_printed_field_name}={self.field_value} from the {self.list_name} list.\"\n\n return task_info\n\n def cheat(self, page: Page, chat_messages: list[str]) -> None:\n super().cheat(page, chat_messages)\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n\n # If the record number is provided, click on the record with that number...\n if self.record_number is not None:\n frame.locator(f\"[aria-label='Preview record: {self.record_number}']\").click()\n page.wait_for_timeout(500)\n frame.get_by_text(\"Open Record\").click()\n # ....Otherwise, otherwise filter the list and click on the record\n else:\n # Search for the record\n frame.get_by_label(\n f\"Search a specific field of the {self.list_name} list\"\n ).select_option(f\"{self.field_name}\")\n search_input = frame.locator('input[aria-label=\"Search\"]')\n search_input.click()\n search_input.fill(self.field_value)\n search_input.press(\"Enter\")\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n # Click on the record to open it\n # The first 2 displays of the record are in the search bar; the 3rd and last will be the link to open it\n frame.get_by_label(self.field_value).last.click()\n\n page.wait_for_function(\n \"typeof window.gsft_main !== 'undefined' && window.gsft_main.WORKARENA_LOAD_COMPLETE\"\n )\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Click on delete, then confirm delete in the popup\n frame.get_by_text(\"delete\").first.click()\n frame.wait_for_selector('header[aria-label=\"Confirmation\"]')\n page.keyboard.press(\"Enter\")\n # Wait for record to be updated in the DB\n record_deleted = False\n while not record_deleted:\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n record_deleted = len(record) == 0\n page.wait_for_timeout(3000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\"sysparm_query\": f\"{self.field_name}={self.field_value}\"},\n )[\"result\"]\n if len(record) > 0:\n return 0, False, \"\", {\"message\": \"Record was not deleted.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Record was deleted successfully.\"}\n\n def teardown(self) -> None:\n super().teardown()\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.delete_record.validate#L166-L178","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":166,"end_line":178,"context_start_line":146,"context_end_line":198,"code":" )\n frame = page.wait_for_selector('iframe[name=\"gsft_main\"]').content_frame()\n # Click on delete, then confirm delete in the popup\n frame.get_by_text(\"delete\").first.click()\n frame.wait_for_selector('header[aria-label=\"Confirmation\"]')\n page.keyboard.press(\"Enter\")\n # Wait for record to be updated in the DB\n record_deleted = False\n while not record_deleted:\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n record_deleted = len(record) == 0\n page.wait_for_timeout(3000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\"sysparm_query\": f\"{self.field_name}={self.field_value}\"},\n )[\"result\"]\n if len(record) > 0:\n return 0, False, \"\", {\"message\": \"Record was not deleted.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Record was deleted successfully.\"}\n\n def teardown(self) -> None:\n super().teardown()\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )\n if len(result[\"result\"]) > 0:\n db_delete_from_table(\n instance=self.instance,\n table=self.table_name,\n sys_id=self.record_sys_id,\n )\n\n\nclass DeleteUserTask(DeleteRecordTask):","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.delete_record.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.delete_record.teardown#L180-L195","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":180,"end_line":195,"context_start_line":160,"context_end_line":215,"code":" \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n record_deleted = len(record) == 0\n page.wait_for_timeout(3000)\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n \"\"\"\n Validate the solution\n \"\"\"\n record = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\"sysparm_query\": f\"{self.field_name}={self.field_value}\"},\n )[\"result\"]\n if len(record) > 0:\n return 0, False, \"\", {\"message\": \"Record was not deleted.\"}\n\n return 1, True, \"Nice work, thank you!\", {\"message\": \"Record was deleted successfully.\"}\n\n def teardown(self) -> None:\n super().teardown()\n result = table_api_call(\n instance=self.instance,\n table=self.table_name,\n params={\n \"sysparm_query\": f\"{self.field_name}={self.field_value}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )\n if len(result[\"result\"]) > 0:\n db_delete_from_table(\n instance=self.instance,\n table=self.table_name,\n sys_id=self.record_sys_id,\n )\n\n\nclass DeleteUserTask(DeleteRecordTask):\n def __init__(self, instance=None, fixed_config=None, record_sys_id=None, **kwargs) -> None:\n super().__init__(\n instance=instance,\n start_rel_url=\"/now/nav/ui/classic/params/target/sys_user_list.do\",\n list_name=\"Users\",\n fixed_config=fixed_config,\n record_sys_id=record_sys_id,\n **kwargs,\n )\n if fixed_config is None:\n first_name = faker.first_name()\n last_name = faker.last_name()\n email = first_name.lower() + \".\" + last_name.lower() + \"@workarena.com\"\n self.fixed_config = {\n \"field_name\": \"user_name\",\n \"pretty_printed_field_name\": \"User ID\",\n \"field_value\": first_name + \" \" + last_name,","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.dash_do_create_problem#L1-L336","kind":"module","name":"src.browsergym.workarena.tasks.compositional.dash_do_create_problem","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":1,"end_line":336,"context_start_line":1,"context_end_line":336,"code":"from playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateProblemTask\n\n\nclass DashboardRetrieveIncidentAndCreateProblemTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.attribute_name = \"assigned_to\"\n self.filter_than = \"lesser\"\n self.prefix = \"DCP\"\n\n def set_compositional_task(self) -> None:\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n create_problem_subtasks = []\n self.short_description = \"Compulsory training for employee in probation\"\n for agent_full_name in agent_full_names:\n problem_config = {\n \"fields\": {\n \"short_description\": \"Problem statement\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n \"impact\": \"Impact\",\n },\n \"task_fields\": [\n \"short_description\",\n \"urgency\",\n \"assigned_to\",\n \"impact\",\n ],\n \"template_record\": {\n \"short_description\": self.short_description,\n \"impact\": \"1 - High\",\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n }\n\n create_problem_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a problem\n CreateProblemTask(\n instance=self.instance,\n fixed_config=problem_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_problem_subtasks += create_problem_subtask\n\n self.compositional_task = create_problem_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report(\n user_roles=[\n \"itil\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ]\n )\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create a 'problem' with the following information (only fill these fields) and assign it to them using the 'Assigned to' field: \\n\"\n + f\"\\t\\t Impact: '1 - High', Urgency: '1 - High', Problem statement: 'Compulsory training for employee in probation'.\\n\"\n + f\"Note that you will create as many problems as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' problems here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to All > Problems. \\n\"\n + f\"\\n5. You have to create new 'problems' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new problem:- Impact: '1 - High', Urgency: '1 - High', Problem statement: 'Compulsory training for employee in probation' and 'assign' them to each agent.\\n\\n\"\n + f\"Note that you will create as many problems as there are agents matching the above criteria.\"\n + \"\\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' problems here, one assigned to each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n fixed_template_record = {\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1\",\n \"urgency\": \"1\",\n }\n for agent_sysid in self.agent_value_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}^short_description={self.short_description}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_problem_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No problem created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_problem_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple problems created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n created_problem_response = created_problem_response[0]\n for key, value in fixed_template_record.items():\n if str(created_problem_response[key]).lower() != str(value).lower():\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Problem for agent {self.agents[agent_sysid]['user_name']} assigned incorrect value to field {key}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_AND_CREATE_PROBLEM = [DashboardRetrieveIncidentAndMinCreateProblemTask]\nDASH_COMPUTE_AND_CREATE_PROBLEM = [\n DashboardRetrieveIncidentAndMeanCreateProblemTask,\n DashboardRetrieveIncidentAndMedianCreateProblemTask,\n DashboardRetrieveIncidentAndModeCreateProblemTask,\n]","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndCreateProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndCreateProblemTask#L16-L204","kind":"class","name":"DashboardRetrieveIncidentAndCreateProblemTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":16,"end_line":204,"context_start_line":1,"context_end_line":224,"code":"from playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateProblemTask\n\n\nclass DashboardRetrieveIncidentAndCreateProblemTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n question: str = None,\n dashboard_class: AbstractServiceNowTask = None,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.attribute_name = \"assigned_to\"\n self.filter_than = \"lesser\"\n self.prefix = \"DCP\"\n\n def set_compositional_task(self) -> None:\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n create_problem_subtasks = []\n self.short_description = \"Compulsory training for employee in probation\"\n for agent_full_name in agent_full_names:\n problem_config = {\n \"fields\": {\n \"short_description\": \"Problem statement\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n \"impact\": \"Impact\",\n },\n \"task_fields\": [\n \"short_description\",\n \"urgency\",\n \"assigned_to\",\n \"impact\",\n ],\n \"template_record\": {\n \"short_description\": self.short_description,\n \"impact\": \"1 - High\",\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n }\n\n create_problem_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a problem\n CreateProblemTask(\n instance=self.instance,\n fixed_config=problem_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_problem_subtasks += create_problem_subtask\n\n self.compositional_task = create_problem_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report(\n user_roles=[\n \"itil\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ]\n )\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create a 'problem' with the following information (only fill these fields) and assign it to them using the 'Assigned to' field: \\n\"\n + f\"\\t\\t Impact: '1 - High', Urgency: '1 - High', Problem statement: 'Compulsory training for employee in probation'.\\n\"\n + f\"Note that you will create as many problems as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' problems here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to All > Problems. \\n\"\n + f\"\\n5. You have to create new 'problems' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new problem:- Impact: '1 - High', Urgency: '1 - High', Problem statement: 'Compulsory training for employee in probation' and 'assign' them to each agent.\\n\\n\"\n + f\"Note that you will create as many problems as there are agents matching the above criteria.\"\n + \"\\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' problems here, one assigned to each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n fixed_template_record = {\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1\",\n \"urgency\": \"1\",\n }\n for agent_sysid in self.agent_value_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}^short_description={self.short_description}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_problem_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No problem created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_problem_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple problems created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n created_problem_response = created_problem_response[0]\n for key, value in fixed_template_record.items():\n if str(created_problem_response[key]).lower() != str(value).lower():\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Problem for agent {self.agents[agent_sysid]['user_name']} assigned incorrect value to field {key}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndMinCreateProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndMinCreateProblemTask#L207-L233","kind":"class","name":"DashboardRetrieveIncidentAndMinCreateProblemTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":207,"end_line":233,"context_start_line":187,"context_end_line":253,"code":"\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndMeanCreateProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndMeanCreateProblemTask#L236-L262","kind":"class","name":"DashboardRetrieveIncidentAndMeanCreateProblemTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":236,"end_line":262,"context_start_line":216,"context_end_line":282,"code":" ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"min\",\n dashboard_class=SingleChartMinMaxRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMeanCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndMedianCreateProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndMedianCreateProblemTask#L265-L291","kind":"class","name":"DashboardRetrieveIncidentAndMedianCreateProblemTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":265,"end_line":291,"context_start_line":245,"context_end_line":311,"code":" ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mean\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndMedianCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndModeCreateProblemTask","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.DashboardRetrieveIncidentAndModeCreateProblemTask#L294-L320","kind":"class","name":"DashboardRetrieveIncidentAndModeCreateProblemTask","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":294,"end_line":320,"context_start_line":274,"context_end_line":336,"code":" ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_AND_CREATE_PROBLEM = [DashboardRetrieveIncidentAndMinCreateProblemTask]\nDASH_COMPUTE_AND_CREATE_PROBLEM = [\n DashboardRetrieveIncidentAndMeanCreateProblemTask,\n DashboardRetrieveIncidentAndMedianCreateProblemTask,\n DashboardRetrieveIncidentAndModeCreateProblemTask,\n]","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.__init__#L297-L320","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":297,"end_line":320,"context_start_line":277,"context_end_line":336,"code":" Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"median\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nclass DashboardRetrieveIncidentAndModeCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=\"mode\",\n dashboard_class=SingleChartMeanMedianModeRetrievalTask,\n )\n\n\nlocal_vars = locals().copy()\n\n__TASKS__ = [\n var\n for var in local_vars.values()\n if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask\n]\n\nDASH_AND_CREATE_PROBLEM = [DashboardRetrieveIncidentAndMinCreateProblemTask]\nDASH_COMPUTE_AND_CREATE_PROBLEM = [\n DashboardRetrieveIncidentAndMeanCreateProblemTask,\n DashboardRetrieveIncidentAndMedianCreateProblemTask,\n DashboardRetrieveIncidentAndModeCreateProblemTask,\n]","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.set_compositional_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.set_compositional_task#L47-L99","kind":"function","name":"set_compositional_task","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":47,"end_line":99,"context_start_line":27,"context_end_line":119,"code":" Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"\n \"\"\"\n super().__init__(\n instance=instance,\n seed=seed,\n fixed_config=fixed_config,\n level=level,\n question=question,\n dashboard_class=dashboard_class,\n )\n self.attribute_name = \"assigned_to\"\n self.filter_than = \"lesser\"\n self.prefix = \"DCP\"\n\n def set_compositional_task(self) -> None:\n agent_full_names, agent_value_sysids = self.get_agent_values(\n self.attribute_name, self.filter_than\n )\n self.agent_value_sysids = agent_value_sysids\n create_problem_subtasks = []\n self.short_description = \"Compulsory training for employee in probation\"\n for agent_full_name in agent_full_names:\n problem_config = {\n \"fields\": {\n \"short_description\": \"Problem statement\",\n \"urgency\": \"Urgency\",\n \"assigned_to\": \"Assigned to\",\n \"impact\": \"Impact\",\n },\n \"task_fields\": [\n \"short_description\",\n \"urgency\",\n \"assigned_to\",\n \"impact\",\n ],\n \"template_record\": {\n \"short_description\": self.short_description,\n \"impact\": \"1 - High\",\n \"urgency\": \"1 - High\",\n \"assigned_to\": agent_full_name,\n },\n }\n\n create_problem_subtask = [\n # Navigate to the incident list\n AllMenuTask(\n instance=self.instance,\n fixed_config={\n \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a problem\n CreateProblemTask(\n instance=self.instance,\n fixed_config=problem_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_problem_subtasks += create_problem_subtask\n\n self.compositional_task = create_problem_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report(\n user_roles=[\n \"itil\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ]\n )\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create a 'problem' with the following information (only fill these fields) and assign it to them using the 'Assigned to' field: \\n\"","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.setup_goal","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.setup_goal#L101-L139","kind":"function","name":"setup_goal","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":101,"end_line":139,"context_start_line":81,"context_end_line":159,"code":" \"application\": \"Problem\",\n \"module\": \"All\",\n \"url\": \"/now/nav/ui/classic/params/target/problem_list.do\",\n },\n is_validated=False,\n used_in_level_2=True,\n ),\n # Create a problem\n CreateProblemTask(\n instance=self.instance,\n fixed_config=problem_config,\n is_validated=False,\n used_in_level_2=True,\n check_record_created=False,\n ),\n ]\n create_problem_subtasks += create_problem_subtask\n\n self.compositional_task = create_problem_subtasks\n\n def setup_goal(self, page: Page) -> tuple[str, dict]:\n self.create_report(\n user_roles=[\n \"itil\",\n \"problem_admin\",\n \"problem_manager\",\n \"problem_coordinator\",\n \"problem_task_analyst\",\n ]\n )\n self.set_compositional_task()\n config = self.fixed_config if self.fixed_config else self._get_config()\n\n if self.level == 3:\n self.task_description = (\n self.task_description\n + f\"\\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\\n\"\n + f\"\\t For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\\n\"\n + f\"\\t - Task: For each agent that fits the above criteria, create a 'problem' with the following information (only fill these fields) and assign it to them using the 'Assigned to' field: \\n\"\n + f\"\\t\\t Impact: '1 - High', Urgency: '1 - High', Problem statement: 'Compulsory training for employee in probation'.\\n\"\n + f\"Note that you will create as many problems as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' problems here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to All > Problems. \\n\"\n + f\"\\n5. You have to create new 'problems' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new problem:- Impact: '1 - High', Urgency: '1 - High', Problem statement: 'Compulsory training for employee in probation' and 'assign' them to each agent.\\n\\n\"\n + f\"Note that you will create as many problems as there are agents matching the above criteria.\"\n + \"\\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' problems here, one assigned to each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n fixed_template_record = {\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1\",\n \"urgency\": \"1\",\n }\n for agent_sysid in self.agent_value_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}^short_description={self.short_description}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_problem_response) == 0:\n return (\n 0,\n False,","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.validate","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.validate#L141-L186","kind":"function","name":"validate","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":141,"end_line":186,"context_start_line":121,"context_end_line":206,"code":" + f\"Note that you will create as many problems as there are agents matching the above criteria.\\n\"\n + f\"\\t For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' problems here, one assigned to each agent. \\n\\n\"\n )\n\n goal, info = super().setup_goal(page=page, config=config)\n\n if self.level == 2:\n goal = (\n self.short_description\n + f\"\\n1. Navigate to the Reports > View/Run page. \\n\"\n + f\"\\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\\n\"\n + f\"\\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\\n\"\n + f\"\\n4. Navigate to All > Problems. \\n\"\n + f\"\\n5. You have to create new 'problems' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new problem:- Impact: '1 - High', Urgency: '1 - High', Problem statement: 'Compulsory training for employee in probation' and 'assign' them to each agent.\\n\\n\"\n + f\"Note that you will create as many problems as there are agents matching the above criteria.\"\n + \"\\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' problems here, one assigned to each agent. \\n\"\n )\n\n return goal, info\n\n def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:\n fixed_template_record = {\n \"short_description\": \"Compulsory training for employee in probation\",\n \"impact\": \"1\",\n \"urgency\": \"1\",\n }\n for agent_sysid in self.agent_value_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}^short_description={self.short_description}\",\n },\n method=\"GET\",\n )[\"result\"]\n if len(created_problem_response) == 0:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"No problem created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n elif len(created_problem_response) > 1:\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Multiple problems created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n created_problem_response = created_problem_response[0]\n for key, value in fixed_template_record.items():\n if str(created_problem_response[key]).lower() != str(value).lower():\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Problem for agent {self.agents[agent_sysid]['user_name']} assigned incorrect value to field {key}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.dash_do_create_problem.teardown","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.dash_do_create_problem.teardown#L188-L204","kind":"function","name":"teardown","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":188,"end_line":204,"context_start_line":168,"context_end_line":224,"code":" False,\n \"\",\n {\n \"message\": f\"Multiple problems created for agent {self.agents[agent_sysid]['user_name']}.\"\n },\n )\n created_problem_response = created_problem_response[0]\n for key, value in fixed_template_record.items():\n if str(created_problem_response[key]).lower() != str(value).lower():\n return (\n 0,\n False,\n \"\",\n {\n \"message\": f\"Problem for agent {self.agents[agent_sysid]['user_name']} assigned incorrect value to field {key}.\"\n },\n )\n reward, done, message, info = super().validate(page, chat_messages)\n return reward, done, message, info\n\n def teardown(self) -> None:\n for agent_sysid in self.agent_sysids:\n created_problem_response = table_api_call(\n instance=self.instance,\n table=\"problem\",\n params={\n \"sysparm_query\": f\"assigned_to={agent_sysid}\",\n },\n method=\"GET\",\n )[\"result\"]\n for problem in created_problem_response:\n db_delete_from_table(\n instance=self.instance,\n table=\"problem\",\n sys_id=problem[\"sys_id\"],\n )\n return super().teardown()\n\n\nclass DashboardRetrieveIncidentAndMinCreateProblemTask(\n DashboardRetrieveIncidentAndCreateProblemTask, DashDoFinalTask\n):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,\n level: int = 2,\n ) -> None:\n \"\"\"\n Retrieve the worst performing employee and create a problem to assign them a probation course.\n Attributes:\n -----------\n task_description: str\n The start of the task description to be completed.\n short_description: str\n A short description of the task to be completed. \"Create a problem for the worst performing employee from the list\"","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.knapsack","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.utils.knapsack#L1-L192","kind":"module","name":"src.browsergym.workarena.tasks.compositional.utils.knapsack","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":1,"end_line":192,"context_start_line":1,"context_end_line":192,"code":"import numpy as np\n\n\nclass KnapsackInstanceGenarator:\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n The instance is guaranteed to have a unique optimal solution in \"random\" or \"single_item\" mode .\n\n Args:\n - random: Random number generator\n - num_items: Number of items\n - max_capacity: Maximum capacity of the knapsack\n - mode: Mode of generation. Choice of \"random\", \"trivial\", \"single_item\", \"single_item_uniform\", \"n_items\"\n - random: Randomly generate the instance and return it; guaranteed to have a unique optimal solution\n - trivial: Generate a trivial instance with all items fitting in the knapsack; return the instance\n - single_item: Generate an instance where the optimal solution has only one item\n - n_items: Generate an instance with all items having uniform weight and value; n items fitting in the knapsack\n - single_item_uniform: Generate an instance with all items having uniform weight and value; optimal solution has only one item and it can be any\n - num_items_in_solution: Number of items in the optimal solution. Required for \"n_items\" mode.\n - default_return: Default return value for investments having uniform weight and value. Required for \"n_items\" and \"single_item_uniform\" modes.\n \"\"\"\n\n def __init__(\n self,\n random: np.random,\n num_items: int,\n max_capacity: int,\n mode: str = \"random\",\n num_items_in_solution: int = None,\n default_return: int = 100000,\n ):\n self.random = random\n self.num_items = num_items\n self.max_capacity = max_capacity\n self.mode = mode\n self.num_items_in_solution = num_items_in_solution\n self.default_return = default_return\n\n def get_instance(self):\n if self.mode in [\"random\", \"trivial\"]:\n return self.generate_and_solve_knapsack_instance()\n elif self.mode == \"single_item\":\n return self.generate_single_item_knapsack_instance()\n elif self.mode in [\"single_item_uniform\", \"n_items\"]:\n return self.generate_uniform_knapsack_instance()\n else:\n raise ValueError(f\"Invalid mode {self.mode} for knapsack instance generation\")\n\n def generate_and_solve_knapsack_instance(self):\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n Used to generate instances for the \"random\" and \"trivial\" mode.\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices: Indices of the investments selected in the optimal solution\n \"\"\"\n\n assert self.mode in [\n \"random\",\n \"trivial\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_and_solve_knapsack_instance\"\n\n multiple_solutions = True\n while multiple_solutions:\n # Generate knapsack instance...\n investments = []\n min_cost = self.max_capacity // (self.num_items * 2)\n max_cost = (\n self.max_capacity // 2\n if self.mode == \"random\"\n else self.max_capacity // self.num_items\n )\n for _ in range(self.num_items):\n cost = self.random.randint(min_cost, max_cost)\n # Ensure that investments yield positive returns\n investment_return = self.random.randint(\n self.max_capacity // 2, self.max_capacity // 2 + 40000\n )\n investments.append((cost, investment_return))\n\n total_cost = sum([investments[i][0] for i in range(self.num_items)])\n # Skip trivial instances where all items fit in the knapsack\n if self.mode == \"random\" and total_cost <= self.max_capacity:\n continue\n\n if self.mode == \"random\":\n # ...Solve it...\n max_return, num_optimal_solutions, selected_indices = self.solve_knapsack(\n investments, self.max_capacity\n )\n # ...and check if there are multiple solutions\n multiple_solutions = num_optimal_solutions > 1\n else:\n selected_indices = list(range(self.num_items))\n max_return = sum([investments[i][1] for i in selected_indices])\n multiple_solutions = False\n\n return investments, max_return, selected_indices\n\n def generate_single_item_knapsack_instance(self):\n \"\"\"Generate knapsack instance where the optimal solution contains only one item\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_investment_return: Investment return of the selected investment in the optimal solution\n - selected_indices: Index of the selected investment in the optimal solution\n \"\"\"\n assert (\n self.mode == \"single_item\"\n ), f\"Mode {self.mode} is invalid for instance generation with generate_single_item_knapsack_instance\"\n\n # Ensure that the optimal solution contains only one item\n min_cost = self.max_capacity // 2 + 1\n max_cost = self.max_capacity - 1\n\n max_investment_return = 0\n max_investment_index = 0\n\n # Generate knapsack instance...\n investments = []\n for i in range(self.num_items):\n cost = self.random.randint(min_cost, max_cost)\n investment_return = self.random.randint(max_cost, 2 * max_cost)\n\n # Ensure that the optimal solution contains only one item\n while investment_return == max_investment_return:\n investment_return = self.random.randint(max_cost, 2 * max_cost)\n\n if investment_return > max_investment_return:\n max_investment_return = investment_return\n max_investment_index = i\n\n investments.append((cost, investment_return))\n\n return investments, max_investment_return, [max_investment_index]\n\n def generate_uniform_knapsack_instance(self):\n \"\"\"Generate knapsack instance where all items have the same cost and return\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices=None: No need to return selected indices as all items have the same cost and return. The validation code should check that\n the optimal solution contains a subset of the items of the right length.\n \"\"\"\n assert self.mode in [\n \"single_item_uniform\",\n \"n_items\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_n_items_knapsack_instance\"\n items_in_solution = self.num_items_in_solution if self.mode == \"n_items\" else 1\n\n # Ensure that the optimal solution contains the specified number of items\n item_weight = self.max_capacity // (items_in_solution + 1) + 1\n # Generate knapsack instance...\n investments = [(item_weight, self.default_return) for _ in range(self.num_items)]\n\n return investments, self.default_return * items_in_solution, None\n\n def solve_knapsack(self, investments, max_capacity):\n \"\"\"Solves the knapsack problem using dynamic programming\"\"\"\n num_investments = len(investments)\n\n # Initialize DP table for maximum return and number of ways\n dp = [[(0, 0) for _ in range(max_capacity + 1)] for _ in range(num_investments + 1)]\n\n for i in range(1, num_investments + 1):\n cost, return_ = investments[i - 1]\n for w in range(max_capacity + 1):\n if cost <= w:\n # If adding the current investment yields a higher return, update the cell\n if return_ + dp[i - 1][w - cost][0] > dp[i - 1][w][0]:\n dp[i][w] = (return_ + dp[i - 1][w - cost][0], 1)\n # If it yields the same return, add the number of ways from the cell without the current investment\n elif return_ + dp[i - 1][w - cost][0] == dp[i - 1][w][0]:\n dp[i][w] = (dp[i - 1][w][0], dp[i - 1][w][1] + dp[i - 1][w - cost][1])\n # If it yields a lower return, keep the old maximum return and number of ways\n else:\n dp[i][w] = dp[i - 1][w]\n else:\n dp[i][w] = dp[i - 1][w]\n\n # Retrieve the maximum return and the number of ways to achieve it\n max_return, num_ways = dp[num_investments][max_capacity]\n\n # Retrieve the indices of the selected investments\n selected_indices = []\n w = max_capacity\n for i in range(num_investments, 0, -1):\n if dp[i][w] != dp[i - 1][w]:\n selected_indices.append(i - 1)\n w -= investments[i - 1][0]\n\n return max_return, num_ways, selected_indices","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.knapsack.KnapsackInstanceGenarator","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.compositional.utils.knapsack.KnapsackInstanceGenarator#L4-L192","kind":"class","name":"KnapsackInstanceGenarator","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":4,"end_line":192,"context_start_line":1,"context_end_line":192,"code":"import numpy as np\n\n\nclass KnapsackInstanceGenarator:\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n The instance is guaranteed to have a unique optimal solution in \"random\" or \"single_item\" mode .\n\n Args:\n - random: Random number generator\n - num_items: Number of items\n - max_capacity: Maximum capacity of the knapsack\n - mode: Mode of generation. Choice of \"random\", \"trivial\", \"single_item\", \"single_item_uniform\", \"n_items\"\n - random: Randomly generate the instance and return it; guaranteed to have a unique optimal solution\n - trivial: Generate a trivial instance with all items fitting in the knapsack; return the instance\n - single_item: Generate an instance where the optimal solution has only one item\n - n_items: Generate an instance with all items having uniform weight and value; n items fitting in the knapsack\n - single_item_uniform: Generate an instance with all items having uniform weight and value; optimal solution has only one item and it can be any\n - num_items_in_solution: Number of items in the optimal solution. Required for \"n_items\" mode.\n - default_return: Default return value for investments having uniform weight and value. Required for \"n_items\" and \"single_item_uniform\" modes.\n \"\"\"\n\n def __init__(\n self,\n random: np.random,\n num_items: int,\n max_capacity: int,\n mode: str = \"random\",\n num_items_in_solution: int = None,\n default_return: int = 100000,\n ):\n self.random = random\n self.num_items = num_items\n self.max_capacity = max_capacity\n self.mode = mode\n self.num_items_in_solution = num_items_in_solution\n self.default_return = default_return\n\n def get_instance(self):\n if self.mode in [\"random\", \"trivial\"]:\n return self.generate_and_solve_knapsack_instance()\n elif self.mode == \"single_item\":\n return self.generate_single_item_knapsack_instance()\n elif self.mode in [\"single_item_uniform\", \"n_items\"]:\n return self.generate_uniform_knapsack_instance()\n else:\n raise ValueError(f\"Invalid mode {self.mode} for knapsack instance generation\")\n\n def generate_and_solve_knapsack_instance(self):\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n Used to generate instances for the \"random\" and \"trivial\" mode.\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices: Indices of the investments selected in the optimal solution\n \"\"\"\n\n assert self.mode in [\n \"random\",\n \"trivial\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_and_solve_knapsack_instance\"\n\n multiple_solutions = True\n while multiple_solutions:\n # Generate knapsack instance...\n investments = []\n min_cost = self.max_capacity // (self.num_items * 2)\n max_cost = (\n self.max_capacity // 2\n if self.mode == \"random\"\n else self.max_capacity // self.num_items\n )\n for _ in range(self.num_items):\n cost = self.random.randint(min_cost, max_cost)\n # Ensure that investments yield positive returns\n investment_return = self.random.randint(\n self.max_capacity // 2, self.max_capacity // 2 + 40000\n )\n investments.append((cost, investment_return))\n\n total_cost = sum([investments[i][0] for i in range(self.num_items)])\n # Skip trivial instances where all items fit in the knapsack\n if self.mode == \"random\" and total_cost <= self.max_capacity:\n continue\n\n if self.mode == \"random\":\n # ...Solve it...\n max_return, num_optimal_solutions, selected_indices = self.solve_knapsack(\n investments, self.max_capacity\n )\n # ...and check if there are multiple solutions\n multiple_solutions = num_optimal_solutions > 1\n else:\n selected_indices = list(range(self.num_items))\n max_return = sum([investments[i][1] for i in selected_indices])\n multiple_solutions = False\n\n return investments, max_return, selected_indices\n\n def generate_single_item_knapsack_instance(self):\n \"\"\"Generate knapsack instance where the optimal solution contains only one item\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_investment_return: Investment return of the selected investment in the optimal solution\n - selected_indices: Index of the selected investment in the optimal solution\n \"\"\"\n assert (\n self.mode == \"single_item\"\n ), f\"Mode {self.mode} is invalid for instance generation with generate_single_item_knapsack_instance\"\n\n # Ensure that the optimal solution contains only one item\n min_cost = self.max_capacity // 2 + 1\n max_cost = self.max_capacity - 1\n\n max_investment_return = 0\n max_investment_index = 0\n\n # Generate knapsack instance...\n investments = []\n for i in range(self.num_items):\n cost = self.random.randint(min_cost, max_cost)\n investment_return = self.random.randint(max_cost, 2 * max_cost)\n\n # Ensure that the optimal solution contains only one item\n while investment_return == max_investment_return:\n investment_return = self.random.randint(max_cost, 2 * max_cost)\n\n if investment_return > max_investment_return:\n max_investment_return = investment_return\n max_investment_index = i\n\n investments.append((cost, investment_return))\n\n return investments, max_investment_return, [max_investment_index]\n\n def generate_uniform_knapsack_instance(self):\n \"\"\"Generate knapsack instance where all items have the same cost and return\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices=None: No need to return selected indices as all items have the same cost and return. The validation code should check that\n the optimal solution contains a subset of the items of the right length.\n \"\"\"\n assert self.mode in [\n \"single_item_uniform\",\n \"n_items\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_n_items_knapsack_instance\"\n items_in_solution = self.num_items_in_solution if self.mode == \"n_items\" else 1\n\n # Ensure that the optimal solution contains the specified number of items\n item_weight = self.max_capacity // (items_in_solution + 1) + 1\n # Generate knapsack instance...\n investments = [(item_weight, self.default_return) for _ in range(self.num_items)]\n\n return investments, self.default_return * items_in_solution, None\n\n def solve_knapsack(self, investments, max_capacity):\n \"\"\"Solves the knapsack problem using dynamic programming\"\"\"\n num_investments = len(investments)\n\n # Initialize DP table for maximum return and number of ways\n dp = [[(0, 0) for _ in range(max_capacity + 1)] for _ in range(num_investments + 1)]\n\n for i in range(1, num_investments + 1):\n cost, return_ = investments[i - 1]\n for w in range(max_capacity + 1):\n if cost <= w:\n # If adding the current investment yields a higher return, update the cell\n if return_ + dp[i - 1][w - cost][0] > dp[i - 1][w][0]:\n dp[i][w] = (return_ + dp[i - 1][w - cost][0], 1)\n # If it yields the same return, add the number of ways from the cell without the current investment\n elif return_ + dp[i - 1][w - cost][0] == dp[i - 1][w][0]:\n dp[i][w] = (dp[i - 1][w][0], dp[i - 1][w][1] + dp[i - 1][w - cost][1])\n # If it yields a lower return, keep the old maximum return and number of ways\n else:\n dp[i][w] = dp[i - 1][w]\n else:\n dp[i][w] = dp[i - 1][w]\n\n # Retrieve the maximum return and the number of ways to achieve it\n max_return, num_ways = dp[num_investments][max_capacity]\n\n # Retrieve the indices of the selected investments\n selected_indices = []\n w = max_capacity\n for i in range(num_investments, 0, -1):\n if dp[i][w] != dp[i - 1][w]:\n selected_indices.append(i - 1)\n w -= investments[i - 1][0]\n\n return max_return, num_ways, selected_indices","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.knapsack.__init__","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.knapsack.__init__#L23-L37","kind":"function","name":"__init__","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":23,"end_line":37,"context_start_line":3,"context_end_line":57,"code":"\nclass KnapsackInstanceGenarator:\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n The instance is guaranteed to have a unique optimal solution in \"random\" or \"single_item\" mode .\n\n Args:\n - random: Random number generator\n - num_items: Number of items\n - max_capacity: Maximum capacity of the knapsack\n - mode: Mode of generation. Choice of \"random\", \"trivial\", \"single_item\", \"single_item_uniform\", \"n_items\"\n - random: Randomly generate the instance and return it; guaranteed to have a unique optimal solution\n - trivial: Generate a trivial instance with all items fitting in the knapsack; return the instance\n - single_item: Generate an instance where the optimal solution has only one item\n - n_items: Generate an instance with all items having uniform weight and value; n items fitting in the knapsack\n - single_item_uniform: Generate an instance with all items having uniform weight and value; optimal solution has only one item and it can be any\n - num_items_in_solution: Number of items in the optimal solution. Required for \"n_items\" mode.\n - default_return: Default return value for investments having uniform weight and value. Required for \"n_items\" and \"single_item_uniform\" modes.\n \"\"\"\n\n def __init__(\n self,\n random: np.random,\n num_items: int,\n max_capacity: int,\n mode: str = \"random\",\n num_items_in_solution: int = None,\n default_return: int = 100000,\n ):\n self.random = random\n self.num_items = num_items\n self.max_capacity = max_capacity\n self.mode = mode\n self.num_items_in_solution = num_items_in_solution\n self.default_return = default_return\n\n def get_instance(self):\n if self.mode in [\"random\", \"trivial\"]:\n return self.generate_and_solve_knapsack_instance()\n elif self.mode == \"single_item\":\n return self.generate_single_item_knapsack_instance()\n elif self.mode in [\"single_item_uniform\", \"n_items\"]:\n return self.generate_uniform_knapsack_instance()\n else:\n raise ValueError(f\"Invalid mode {self.mode} for knapsack instance generation\")\n\n def generate_and_solve_knapsack_instance(self):\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n Used to generate instances for the \"random\" and \"trivial\" mode.\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices: Indices of the investments selected in the optimal solution\n \"\"\"","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.knapsack.get_instance","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.knapsack.get_instance#L39-L47","kind":"function","name":"get_instance","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":39,"end_line":47,"context_start_line":19,"context_end_line":67,"code":" - num_items_in_solution: Number of items in the optimal solution. Required for \"n_items\" mode.\n - default_return: Default return value for investments having uniform weight and value. Required for \"n_items\" and \"single_item_uniform\" modes.\n \"\"\"\n\n def __init__(\n self,\n random: np.random,\n num_items: int,\n max_capacity: int,\n mode: str = \"random\",\n num_items_in_solution: int = None,\n default_return: int = 100000,\n ):\n self.random = random\n self.num_items = num_items\n self.max_capacity = max_capacity\n self.mode = mode\n self.num_items_in_solution = num_items_in_solution\n self.default_return = default_return\n\n def get_instance(self):\n if self.mode in [\"random\", \"trivial\"]:\n return self.generate_and_solve_knapsack_instance()\n elif self.mode == \"single_item\":\n return self.generate_single_item_knapsack_instance()\n elif self.mode in [\"single_item_uniform\", \"n_items\"]:\n return self.generate_uniform_knapsack_instance()\n else:\n raise ValueError(f\"Invalid mode {self.mode} for knapsack instance generation\")\n\n def generate_and_solve_knapsack_instance(self):\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n Used to generate instances for the \"random\" and \"trivial\" mode.\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices: Indices of the investments selected in the optimal solution\n \"\"\"\n\n assert self.mode in [\n \"random\",\n \"trivial\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_and_solve_knapsack_instance\"\n\n multiple_solutions = True\n while multiple_solutions:\n # Generate knapsack instance...\n investments = []","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.knapsack.generate_and_solve_knapsack_instance","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.knapsack.generate_and_solve_knapsack_instance#L49-L99","kind":"function","name":"generate_and_solve_knapsack_instance","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":49,"end_line":99,"context_start_line":29,"context_end_line":119,"code":" num_items_in_solution: int = None,\n default_return: int = 100000,\n ):\n self.random = random\n self.num_items = num_items\n self.max_capacity = max_capacity\n self.mode = mode\n self.num_items_in_solution = num_items_in_solution\n self.default_return = default_return\n\n def get_instance(self):\n if self.mode in [\"random\", \"trivial\"]:\n return self.generate_and_solve_knapsack_instance()\n elif self.mode == \"single_item\":\n return self.generate_single_item_knapsack_instance()\n elif self.mode in [\"single_item_uniform\", \"n_items\"]:\n return self.generate_uniform_knapsack_instance()\n else:\n raise ValueError(f\"Invalid mode {self.mode} for knapsack instance generation\")\n\n def generate_and_solve_knapsack_instance(self):\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n Used to generate instances for the \"random\" and \"trivial\" mode.\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices: Indices of the investments selected in the optimal solution\n \"\"\"\n\n assert self.mode in [\n \"random\",\n \"trivial\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_and_solve_knapsack_instance\"\n\n multiple_solutions = True\n while multiple_solutions:\n # Generate knapsack instance...\n investments = []\n min_cost = self.max_capacity // (self.num_items * 2)\n max_cost = (\n self.max_capacity // 2\n if self.mode == \"random\"\n else self.max_capacity // self.num_items\n )\n for _ in range(self.num_items):\n cost = self.random.randint(min_cost, max_cost)\n # Ensure that investments yield positive returns\n investment_return = self.random.randint(\n self.max_capacity // 2, self.max_capacity // 2 + 40000\n )\n investments.append((cost, investment_return))\n\n total_cost = sum([investments[i][0] for i in range(self.num_items)])\n # Skip trivial instances where all items fit in the knapsack\n if self.mode == \"random\" and total_cost <= self.max_capacity:\n continue\n\n if self.mode == \"random\":\n # ...Solve it...\n max_return, num_optimal_solutions, selected_indices = self.solve_knapsack(\n investments, self.max_capacity\n )\n # ...and check if there are multiple solutions\n multiple_solutions = num_optimal_solutions > 1\n else:\n selected_indices = list(range(self.num_items))\n max_return = sum([investments[i][1] for i in selected_indices])\n multiple_solutions = False\n\n return investments, max_return, selected_indices\n\n def generate_single_item_knapsack_instance(self):\n \"\"\"Generate knapsack instance where the optimal solution contains only one item\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_investment_return: Investment return of the selected investment in the optimal solution\n - selected_indices: Index of the selected investment in the optimal solution\n \"\"\"\n assert (\n self.mode == \"single_item\"\n ), f\"Mode {self.mode} is invalid for instance generation with generate_single_item_knapsack_instance\"\n\n # Ensure that the optimal solution contains only one item\n min_cost = self.max_capacity // 2 + 1\n max_cost = self.max_capacity - 1\n\n max_investment_return = 0\n max_investment_index = 0\n\n # Generate knapsack instance...","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.knapsack.generate_single_item_knapsack_instance","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.knapsack.generate_single_item_knapsack_instance#L101-L135","kind":"function","name":"generate_single_item_knapsack_instance","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":101,"end_line":135,"context_start_line":81,"context_end_line":155,"code":"\n total_cost = sum([investments[i][0] for i in range(self.num_items)])\n # Skip trivial instances where all items fit in the knapsack\n if self.mode == \"random\" and total_cost <= self.max_capacity:\n continue\n\n if self.mode == \"random\":\n # ...Solve it...\n max_return, num_optimal_solutions, selected_indices = self.solve_knapsack(\n investments, self.max_capacity\n )\n # ...and check if there are multiple solutions\n multiple_solutions = num_optimal_solutions > 1\n else:\n selected_indices = list(range(self.num_items))\n max_return = sum([investments[i][1] for i in selected_indices])\n multiple_solutions = False\n\n return investments, max_return, selected_indices\n\n def generate_single_item_knapsack_instance(self):\n \"\"\"Generate knapsack instance where the optimal solution contains only one item\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_investment_return: Investment return of the selected investment in the optimal solution\n - selected_indices: Index of the selected investment in the optimal solution\n \"\"\"\n assert (\n self.mode == \"single_item\"\n ), f\"Mode {self.mode} is invalid for instance generation with generate_single_item_knapsack_instance\"\n\n # Ensure that the optimal solution contains only one item\n min_cost = self.max_capacity // 2 + 1\n max_cost = self.max_capacity - 1\n\n max_investment_return = 0\n max_investment_index = 0\n\n # Generate knapsack instance...\n investments = []\n for i in range(self.num_items):\n cost = self.random.randint(min_cost, max_cost)\n investment_return = self.random.randint(max_cost, 2 * max_cost)\n\n # Ensure that the optimal solution contains only one item\n while investment_return == max_investment_return:\n investment_return = self.random.randint(max_cost, 2 * max_cost)\n\n if investment_return > max_investment_return:\n max_investment_return = investment_return\n max_investment_index = i\n\n investments.append((cost, investment_return))\n\n return investments, max_investment_return, [max_investment_index]\n\n def generate_uniform_knapsack_instance(self):\n \"\"\"Generate knapsack instance where all items have the same cost and return\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices=None: No need to return selected indices as all items have the same cost and return. The validation code should check that\n the optimal solution contains a subset of the items of the right length.\n \"\"\"\n assert self.mode in [\n \"single_item_uniform\",\n \"n_items\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_n_items_knapsack_instance\"\n items_in_solution = self.num_items_in_solution if self.mode == \"n_items\" else 1\n\n # Ensure that the optimal solution contains the specified number of items\n item_weight = self.max_capacity // (items_in_solution + 1) + 1\n # Generate knapsack instance...\n investments = [(item_weight, self.default_return) for _ in range(self.num_items)]\n","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.knapsack.generate_uniform_knapsack_instance","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.knapsack.generate_uniform_knapsack_instance#L137-L156","kind":"function","name":"generate_uniform_knapsack_instance","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":137,"end_line":156,"context_start_line":117,"context_end_line":176,"code":" max_investment_index = 0\n\n # Generate knapsack instance...\n investments = []\n for i in range(self.num_items):\n cost = self.random.randint(min_cost, max_cost)\n investment_return = self.random.randint(max_cost, 2 * max_cost)\n\n # Ensure that the optimal solution contains only one item\n while investment_return == max_investment_return:\n investment_return = self.random.randint(max_cost, 2 * max_cost)\n\n if investment_return > max_investment_return:\n max_investment_return = investment_return\n max_investment_index = i\n\n investments.append((cost, investment_return))\n\n return investments, max_investment_return, [max_investment_index]\n\n def generate_uniform_knapsack_instance(self):\n \"\"\"Generate knapsack instance where all items have the same cost and return\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices=None: No need to return selected indices as all items have the same cost and return. The validation code should check that\n the optimal solution contains a subset of the items of the right length.\n \"\"\"\n assert self.mode in [\n \"single_item_uniform\",\n \"n_items\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_n_items_knapsack_instance\"\n items_in_solution = self.num_items_in_solution if self.mode == \"n_items\" else 1\n\n # Ensure that the optimal solution contains the specified number of items\n item_weight = self.max_capacity // (items_in_solution + 1) + 1\n # Generate knapsack instance...\n investments = [(item_weight, self.default_return) for _ in range(self.num_items)]\n\n return investments, self.default_return * items_in_solution, None\n\n def solve_knapsack(self, investments, max_capacity):\n \"\"\"Solves the knapsack problem using dynamic programming\"\"\"\n num_investments = len(investments)\n\n # Initialize DP table for maximum return and number of ways\n dp = [[(0, 0) for _ in range(max_capacity + 1)] for _ in range(num_investments + 1)]\n\n for i in range(1, num_investments + 1):\n cost, return_ = investments[i - 1]\n for w in range(max_capacity + 1):\n if cost <= w:\n # If adding the current investment yields a higher return, update the cell\n if return_ + dp[i - 1][w - cost][0] > dp[i - 1][w][0]:\n dp[i][w] = (return_ + dp[i - 1][w - cost][0], 1)\n # If it yields the same return, add the number of ways from the cell without the current investment\n elif return_ + dp[i - 1][w - cost][0] == dp[i - 1][w][0]:\n dp[i][w] = (dp[i - 1][w][0], dp[i - 1][w][1] + dp[i - 1][w - cost][1])\n # If it yields a lower return, keep the old maximum return and number of ways\n else:","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.knapsack.solve_knapsack","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.knapsack.solve_knapsack#L158-L192","kind":"function","name":"solve_knapsack","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":158,"end_line":192,"context_start_line":138,"context_end_line":192,"code":" \"\"\"Generate knapsack instance where all items have the same cost and return\n Returns:\n - investments: List of tuples (cost, investment_return) for each investment\n - max_return: Maximum return achievable with optimal solution\n - selected_indices=None: No need to return selected indices as all items have the same cost and return. The validation code should check that\n the optimal solution contains a subset of the items of the right length.\n \"\"\"\n assert self.mode in [\n \"single_item_uniform\",\n \"n_items\",\n ], f\"Mode {self.mode} is invalid for instance generation with generate_n_items_knapsack_instance\"\n items_in_solution = self.num_items_in_solution if self.mode == \"n_items\" else 1\n\n # Ensure that the optimal solution contains the specified number of items\n item_weight = self.max_capacity // (items_in_solution + 1) + 1\n # Generate knapsack instance...\n investments = [(item_weight, self.default_return) for _ in range(self.num_items)]\n\n return investments, self.default_return * items_in_solution, None\n\n def solve_knapsack(self, investments, max_capacity):\n \"\"\"Solves the knapsack problem using dynamic programming\"\"\"\n num_investments = len(investments)\n\n # Initialize DP table for maximum return and number of ways\n dp = [[(0, 0) for _ in range(max_capacity + 1)] for _ in range(num_investments + 1)]\n\n for i in range(1, num_investments + 1):\n cost, return_ = investments[i - 1]\n for w in range(max_capacity + 1):\n if cost <= w:\n # If adding the current investment yields a higher return, update the cell\n if return_ + dp[i - 1][w - cost][0] > dp[i - 1][w][0]:\n dp[i][w] = (return_ + dp[i - 1][w - cost][0], 1)\n # If it yields the same return, add the number of ways from the cell without the current investment\n elif return_ + dp[i - 1][w - cost][0] == dp[i - 1][w][0]:\n dp[i][w] = (dp[i - 1][w][0], dp[i - 1][w][1] + dp[i - 1][w - cost][1])\n # If it yields a lower return, keep the old maximum return and number of ways\n else:\n dp[i][w] = dp[i - 1][w]\n else:\n dp[i][w] = dp[i - 1][w]\n\n # Retrieve the maximum return and the number of ways to achieve it\n max_return, num_ways = dp[num_investments][max_capacity]\n\n # Retrieve the indices of the selected investments\n selected_indices = []\n w = max_capacity\n for i in range(num_investments, 0, -1):\n if dp[i][w] != dp[i - 1][w]:\n selected_indices.append(i - 1)\n w -= investments[i - 1][0]\n\n return max_return, num_ways, selected_indices","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.infeasible_configs","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.utils.infeasible_configs#L1-L151","kind":"module","name":"src.browsergym.workarena.tasks.compositional.utils.infeasible_configs","path":"src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","language":"python","start_line":1,"end_line":151,"context_start_line":1,"context_end_line":151,"code":"import numpy as np\n\nfrom faker import Faker\n\nfake = Faker()\n\n\ndef get_infeasible_form_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible form config from a feasible config by replacing the name of one of the task_fields with a random word\n\n Args:\n --------\n config (dict):\n The feasible form config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible form config\n infeasible_keywords (list[str]):\n The name of the new field printed and its system name\n \"\"\"\n replaced_field = (\n random.choice(config[\"infeasible_task_fields\"])\n if \"infeasible_task_fields\" in config\n else random.choice(config[\"task_fields\"])\n )\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n new_field_system_name = new_field_printed.lower().replace(\" \", \"_\")\n\n config[\"task_fields\"].remove(replaced_field)\n config[\"task_fields\"].append(new_field_system_name)\n config[\"fields\"][new_field_system_name] = new_field_printed\n config[\"template_record\"][new_field_system_name] = fake.word()\n\n infeasible_reasons = [new_field_printed, new_field_system_name] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_service_catalog_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible service catalog config from a feasible config by replacing the name of one of the additional configuration items with a random word\n\n Args:\n --------\n config (dict):\n The feasible service catalog config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible service catalog config\n infeasible_keywords (list[str]):\n The name of the new field printed and its system name\n \"\"\"\n item_configuration = list(config[\"configuration\"].keys())\n # if there is a configuration item, replace it with a new one; otherwise, simply add a new one\n if item_configuration:\n replaced_field = random.choice(item_configuration)\n config[\"configuration\"].pop(replaced_field)\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n field_type = random.choice([\"radio\", \"textarea\", \"checkbox\", \"select\"])\n field_options = [fake.word() for _ in range(random.randint(2, 5))]\n\n config[\"configuration\"][new_field_printed] = [field_type, \", \".join(field_options)]\n\n infeasible_reasons = [new_field_printed, *field_options] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_sort_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible sort config from a feasible config by replacing the name of one sort_fields with a random word\n\n Args:\n --------\n config (dict):\n The feasible sort config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible sort config\n infeasible_keywords (list[str]):\n The name of the new sort option printed and its system name\n \"\"\"\n goal = config[\"goal\"]\n config_fields = [line[3:].split(\" (\")[0] for line in goal.split(\"\\n\")[1:]]\n replaced_field_index = random.randint(0, len(config[\"sort_fields\"]))\n\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n new_field_system_name = new_field_printed.lower().replace(\" \", \"_\")\n\n config[\"goal\"] = goal.replace(config_fields[replaced_field_index], new_field_printed)\n config[\"sort_fields\"][replaced_field_index] = new_field_system_name\n\n infeasible_reasons = [new_field_printed, new_field_system_name] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_filter_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible filter config from a feasible config by replacing the name of one of the filter_columns with a random word\n\n Args:\n --------\n config (dict):\n The feasible filter config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible filter config\n infeasible_keywords (list[str]):\n The name of the new filter option printed and its system name\n \"\"\"\n replaced_field_index = random.randint(0, len(config[\"filter_columns\"]))\n\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n new_field_system_name = new_field_printed.lower().replace(\" \", \"_\")\n config[\"filter_columns\"][replaced_field_index] = new_field_system_name\n config[\"filter_values\"][replaced_field_index] = fake.word().capitalize()\n config[\"list_info\"][\"columns\"][new_field_system_name] = {\"label\": new_field_printed}\n\n infeasible_reasons = [new_field_printed, new_field_system_name] if provide_reason else [\"\"]\n\n return config, infeasible_reasons","source_hash":"881c8ede4723e531ab1325fe43ad19a05436b59348e1669260d8ef6c2558fb2d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.infeasible_configs.get_infeasible_form_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.infeasible_configs.get_infeasible_form_config#L8-L44","kind":"function","name":"get_infeasible_form_config","path":"src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","language":"python","start_line":8,"end_line":44,"context_start_line":1,"context_end_line":64,"code":"import numpy as np\n\nfrom faker import Faker\n\nfake = Faker()\n\n\ndef get_infeasible_form_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible form config from a feasible config by replacing the name of one of the task_fields with a random word\n\n Args:\n --------\n config (dict):\n The feasible form config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible form config\n infeasible_keywords (list[str]):\n The name of the new field printed and its system name\n \"\"\"\n replaced_field = (\n random.choice(config[\"infeasible_task_fields\"])\n if \"infeasible_task_fields\" in config\n else random.choice(config[\"task_fields\"])\n )\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n new_field_system_name = new_field_printed.lower().replace(\" \", \"_\")\n\n config[\"task_fields\"].remove(replaced_field)\n config[\"task_fields\"].append(new_field_system_name)\n config[\"fields\"][new_field_system_name] = new_field_printed\n config[\"template_record\"][new_field_system_name] = fake.word()\n\n infeasible_reasons = [new_field_printed, new_field_system_name] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_service_catalog_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible service catalog config from a feasible config by replacing the name of one of the additional configuration items with a random word\n\n Args:\n --------\n config (dict):\n The feasible service catalog config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible service catalog config","source_hash":"881c8ede4723e531ab1325fe43ad19a05436b59348e1669260d8ef6c2558fb2d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.infeasible_configs.get_infeasible_service_catalog_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.infeasible_configs.get_infeasible_service_catalog_config#L47-L81","kind":"function","name":"get_infeasible_service_catalog_config","path":"src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","language":"python","start_line":47,"end_line":81,"context_start_line":27,"context_end_line":101,"code":" The name of the new field printed and its system name\n \"\"\"\n replaced_field = (\n random.choice(config[\"infeasible_task_fields\"])\n if \"infeasible_task_fields\" in config\n else random.choice(config[\"task_fields\"])\n )\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n new_field_system_name = new_field_printed.lower().replace(\" \", \"_\")\n\n config[\"task_fields\"].remove(replaced_field)\n config[\"task_fields\"].append(new_field_system_name)\n config[\"fields\"][new_field_system_name] = new_field_printed\n config[\"template_record\"][new_field_system_name] = fake.word()\n\n infeasible_reasons = [new_field_printed, new_field_system_name] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_service_catalog_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible service catalog config from a feasible config by replacing the name of one of the additional configuration items with a random word\n\n Args:\n --------\n config (dict):\n The feasible service catalog config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible service catalog config\n infeasible_keywords (list[str]):\n The name of the new field printed and its system name\n \"\"\"\n item_configuration = list(config[\"configuration\"].keys())\n # if there is a configuration item, replace it with a new one; otherwise, simply add a new one\n if item_configuration:\n replaced_field = random.choice(item_configuration)\n config[\"configuration\"].pop(replaced_field)\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n field_type = random.choice([\"radio\", \"textarea\", \"checkbox\", \"select\"])\n field_options = [fake.word() for _ in range(random.randint(2, 5))]\n\n config[\"configuration\"][new_field_printed] = [field_type, \", \".join(field_options)]\n\n infeasible_reasons = [new_field_printed, *field_options] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_sort_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible sort config from a feasible config by replacing the name of one sort_fields with a random word\n\n Args:\n --------\n config (dict):\n The feasible sort config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible sort config","source_hash":"881c8ede4723e531ab1325fe43ad19a05436b59348e1669260d8ef6c2558fb2d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.infeasible_configs.get_infeasible_sort_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.infeasible_configs.get_infeasible_sort_config#L84-L117","kind":"function","name":"get_infeasible_sort_config","path":"src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","language":"python","start_line":84,"end_line":117,"context_start_line":64,"context_end_line":137,"code":" The infeasible service catalog config\n infeasible_keywords (list[str]):\n The name of the new field printed and its system name\n \"\"\"\n item_configuration = list(config[\"configuration\"].keys())\n # if there is a configuration item, replace it with a new one; otherwise, simply add a new one\n if item_configuration:\n replaced_field = random.choice(item_configuration)\n config[\"configuration\"].pop(replaced_field)\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n field_type = random.choice([\"radio\", \"textarea\", \"checkbox\", \"select\"])\n field_options = [fake.word() for _ in range(random.randint(2, 5))]\n\n config[\"configuration\"][new_field_printed] = [field_type, \", \".join(field_options)]\n\n infeasible_reasons = [new_field_printed, *field_options] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_sort_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible sort config from a feasible config by replacing the name of one sort_fields with a random word\n\n Args:\n --------\n config (dict):\n The feasible sort config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible sort config\n infeasible_keywords (list[str]):\n The name of the new sort option printed and its system name\n \"\"\"\n goal = config[\"goal\"]\n config_fields = [line[3:].split(\" (\")[0] for line in goal.split(\"\\n\")[1:]]\n replaced_field_index = random.randint(0, len(config[\"sort_fields\"]))\n\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n new_field_system_name = new_field_printed.lower().replace(\" \", \"_\")\n\n config[\"goal\"] = goal.replace(config_fields[replaced_field_index], new_field_printed)\n config[\"sort_fields\"][replaced_field_index] = new_field_system_name\n\n infeasible_reasons = [new_field_printed, new_field_system_name] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_filter_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible filter config from a feasible config by replacing the name of one of the filter_columns with a random word\n\n Args:\n --------\n config (dict):\n The feasible filter config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible filter config","source_hash":"881c8ede4723e531ab1325fe43ad19a05436b59348e1669260d8ef6c2558fb2d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.infeasible_configs.get_infeasible_filter_config","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.compositional.utils.infeasible_configs.get_infeasible_filter_config#L120-L151","kind":"function","name":"get_infeasible_filter_config","path":"src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","language":"python","start_line":120,"end_line":151,"context_start_line":100,"context_end_line":151,"code":" infeasible_config (dict):\n The infeasible sort config\n infeasible_keywords (list[str]):\n The name of the new sort option printed and its system name\n \"\"\"\n goal = config[\"goal\"]\n config_fields = [line[3:].split(\" (\")[0] for line in goal.split(\"\\n\")[1:]]\n replaced_field_index = random.randint(0, len(config[\"sort_fields\"]))\n\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n new_field_system_name = new_field_printed.lower().replace(\" \", \"_\")\n\n config[\"goal\"] = goal.replace(config_fields[replaced_field_index], new_field_printed)\n config[\"sort_fields\"][replaced_field_index] = new_field_system_name\n\n infeasible_reasons = [new_field_printed, new_field_system_name] if provide_reason else [\"\"]\n\n return config, infeasible_reasons\n\n\ndef get_infeasible_filter_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible filter config from a feasible config by replacing the name of one of the filter_columns with a random word\n\n Args:\n --------\n config (dict):\n The feasible filter config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n\n Returns:\n --------\n infeasible_config (dict):\n The infeasible filter config\n infeasible_keywords (list[str]):\n The name of the new filter option printed and its system name\n \"\"\"\n replaced_field_index = random.randint(0, len(config[\"filter_columns\"]))\n\n new_field_printed = fake.word().capitalize() + \" \" + fake.word()\n new_field_system_name = new_field_printed.lower().replace(\" \", \"_\")\n config[\"filter_columns\"][replaced_field_index] = new_field_system_name\n config[\"filter_values\"][replaced_field_index] = fake.word().capitalize()\n config[\"list_info\"][\"columns\"][new_field_system_name] = {\"label\": new_field_printed}\n\n infeasible_reasons = [new_field_printed, new_field_system_name] if provide_reason else [\"\"]\n\n return config, infeasible_reasons","source_hash":"881c8ede4723e531ab1325fe43ad19a05436b59348e1669260d8ef6c2558fb2d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.compositional.utils.curriculum","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.compositional.utils.curriculum#L1-L215","kind":"module","name":"src.browsergym.workarena.tasks.compositional.utils.curriculum","path":"src/browsergym/workarena/tasks/compositional/utils/curriculum.py","language":"python","start_line":1,"end_line":215,"context_start_line":1,"context_end_line":215,"code":"# from .edit_knowledge_base import __TASKS__ as EDIT_KNOWLEDGE_BASE_TASKS, __L2_TASKS__ as EDIT_KNOWLEDGE_BASE_L2_TASKS, __L3_TASKS__ as EDIT_KNOWLEDGE_BASE_L3TASKS\nfrom ..dash_do_catalog import (\n DASH_AND_ORDER,\n DASH_COMPUTE_MEAN_AND_ORDER,\n DASH_COMPUTE_MEDIAN_AND_ORDER,\n DASH_COMPUTE_MODE_AND_ORDER,\n)\nfrom ..dash_do_create_incident import DASH_AND_CREATE_INCIDENT, DASH_COMPUTE_AND_CREATE_INCIDENT\nfrom ..dash_do_create_problem import DASH_AND_CREATE_PROBLEM, DASH_COMPUTE_AND_CREATE_PROBLEM\nfrom ..dash_do_filter import (\n DASH_COMPUTE_MIN_FILTER_LIST,\n DASH_COMPUTE_MAX_FILTER_LIST,\n DASH_COMPUTE_MEAN_FILTER_LIST,\n DASH_COMPUTE_MEDIAN_FILTER_LIST,\n DASH_COMPUTE_MODE_FILTER_LIST,\n)\nfrom ..dash_do_request_item import (\n DASH_AND_REQUEST,\n DASH_COMPUTE_MEAN_AND_REQUEST,\n DASH_COMPUTE_MEDIAN_AND_REQUEST,\n DASH_COMPUTE_MODE_AND_REQUEST,\n)\nfrom ..expense_management import __TASKS__ as EXPENSE_MANAGEMENT_TASKS\nfrom ..find_and_order_item import __TASKS__ as FIND_AND_ORDER_ITEM_TASKS\nfrom ..manage_change_request_schedule import (\n SMALL_BASE_SCHEDULING_TASKS,\n LARGE_BASE_SCHEDULING_TASKS,\n SMALL_TIGHT_SCHEDULING_TASKS,\n LARGE_TIGHT_SCHEDULING_TASKS,\n)\nfrom ..mark_duplicate_problems import __TASKS__ as MARK_DUPLICATE_PROBLEMS_TASKS\nfrom ..maximize_investment_return import __TASKS__ as MAXIMIZE_INVESTMENT_RETURN_TASKS\nfrom ..navigate_and_do import (\n NAVIGATE_AND_CREATE_TASKS,\n NAVIGATE_AND_FILTER_TASKS,\n NAVIGATE_AND_ORDER_TASKS,\n NAVIGATE_AND_SORT_TASKS,\n)\nfrom ..navigate_and_do_infeasible import (\n INFEASIBLE_NAVIGATE_AND_CREATE_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_CREATE,\n INFEASIBLE_NAVIGATE_AND_ORDER_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_ORDER,\n INFEASIBLE_NAVIGATE_AND_FILTER_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_FILTER,\n INFEASIBLE_NAVIGATE_AND_SORT_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_SORT,\n)\nfrom ..offboard_user import __TASKS__ as OFFBOARD_USER_TASKS\nfrom ..onboard_user import __TASKS__ as ONBOARD_USER_TASKS\nfrom ..warranty_check import __TASKS__ as WARRANTY_CHECK_TASKS\nfrom ..work_assignment import __TASKS__ as WORK_ASSIGNMENT_TASKS\nfrom ..workload_balancing import __TASKS__ as WORKLOAD_BALANCING_TASKS\n\nAGENT_CURRICULUM = {\n \"planning_and_problem_solving\": {\n \"buckets\": [\n MARK_DUPLICATE_PROBLEMS_TASKS,\n WORKLOAD_BALANCING_TASKS,\n WORK_ASSIGNMENT_TASKS,\n SMALL_BASE_SCHEDULING_TASKS,\n LARGE_BASE_SCHEDULING_TASKS,\n SMALL_TIGHT_SCHEDULING_TASKS,\n LARGE_TIGHT_SCHEDULING_TASKS,\n ],\n \"num_seeds\": 2,\n \"weights\": [9, 3, 6, 1, 1, 1, 1],\n },\n \"information_retrieval\": {\n \"buckets\": [\n DASH_AND_ORDER,\n DASH_AND_CREATE_INCIDENT,\n DASH_AND_CREATE_PROBLEM,\n DASH_COMPUTE_MIN_FILTER_LIST,\n DASH_COMPUTE_MAX_FILTER_LIST,\n DASH_AND_REQUEST,\n WARRANTY_CHECK_TASKS,\n FIND_AND_ORDER_ITEM_TASKS,\n ],\n \"num_seeds\": 7,\n \"weights\": [1, 1, 1, 1, 1, 1, 1, 1],\n },\n \"data_driven_decision_making_and_reasoning\": {\n \"buckets\": [\n EXPENSE_MANAGEMENT_TASKS,\n MAXIMIZE_INVESTMENT_RETURN_TASKS,\n DASH_COMPUTE_MEAN_AND_ORDER,\n DASH_COMPUTE_MEDIAN_AND_ORDER,\n DASH_COMPUTE_MODE_AND_ORDER,\n DASH_COMPUTE_AND_CREATE_INCIDENT,\n DASH_COMPUTE_AND_CREATE_PROBLEM,\n DASH_COMPUTE_MEAN_FILTER_LIST,\n DASH_COMPUTE_MEDIAN_FILTER_LIST,\n DASH_COMPUTE_MODE_FILTER_LIST,\n DASH_COMPUTE_MEAN_AND_REQUEST,\n DASH_COMPUTE_MEDIAN_AND_REQUEST,\n DASH_COMPUTE_MODE_AND_REQUEST,\n ],\n \"num_seeds\": 1,\n \"weights\": [12, 28, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1],\n },\n \"sophisticated_memory\": {\n \"buckets\": [\n NAVIGATE_AND_CREATE_TASKS,\n NAVIGATE_AND_ORDER_TASKS,\n NAVIGATE_AND_FILTER_TASKS,\n NAVIGATE_AND_SORT_TASKS,\n OFFBOARD_USER_TASKS,\n ONBOARD_USER_TASKS,\n ],\n \"num_seeds\": 8,\n \"weights\": [1, 1, 1, 1, 1, 1],\n },\n \"contextual_understanding_infeasible_tasks\": {\n \"buckets\": [\n INFEASIBLE_NAVIGATE_AND_CREATE_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_CREATE,\n INFEASIBLE_NAVIGATE_AND_ORDER_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_ORDER,\n INFEASIBLE_NAVIGATE_AND_FILTER_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_FILTER,\n INFEASIBLE_NAVIGATE_AND_SORT_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_SORT,\n ],\n \"num_seeds\": 4,\n \"weights\": [1, 1, 1, 1, 1, 1, 1, 1],\n },\n}\n\nHUMAN_CURRICULUM = {\n \"planning_and_problem_solving\": {\n \"buckets\": [\n MARK_DUPLICATE_PROBLEMS_TASKS,\n WORKLOAD_BALANCING_TASKS,\n WORK_ASSIGNMENT_TASKS,\n SMALL_BASE_SCHEDULING_TASKS,\n SMALL_TIGHT_SCHEDULING_TASKS,\n ],\n \"num_seeds\": 1,\n \"weights\": [\n 3,\n 1,\n 2,\n 1,\n 1,\n ],\n },\n \"information_retrieval\": {\n \"buckets\": [\n DASH_AND_ORDER,\n DASH_AND_CREATE_INCIDENT,\n DASH_AND_CREATE_PROBLEM,\n DASH_COMPUTE_MIN_FILTER_LIST,\n DASH_COMPUTE_MAX_FILTER_LIST,\n DASH_AND_REQUEST,\n WARRANTY_CHECK_TASKS,\n FIND_AND_ORDER_ITEM_TASKS,\n ],\n \"num_seeds\": 1,\n \"weights\": [1, 1, 1, 1, 1, 1, 1, 1],\n },\n \"data_driven_decision_making_and_reasoning\": {\n \"buckets\": [\n EXPENSE_MANAGEMENT_TASKS,\n MAXIMIZE_INVESTMENT_RETURN_TASKS, # Not splitting as small multiplier\n [\n *DASH_COMPUTE_MEAN_AND_ORDER,\n *DASH_COMPUTE_MEDIAN_AND_ORDER,\n *DASH_COMPUTE_MODE_AND_ORDER,\n ],\n [\n *DASH_COMPUTE_AND_CREATE_INCIDENT,\n *DASH_COMPUTE_AND_CREATE_PROBLEM,\n *DASH_COMPUTE_MEAN_AND_REQUEST,\n ],\n DASH_COMPUTE_MEAN_FILTER_LIST,\n [\n *DASH_COMPUTE_MEDIAN_FILTER_LIST,\n *DASH_COMPUTE_MODE_FILTER_LIST,\n ],\n [\n *DASH_COMPUTE_MEDIAN_AND_REQUEST,\n *DASH_COMPUTE_MODE_AND_REQUEST,\n ],\n ],\n \"num_seeds\": 1,\n \"weights\": [2, 6, 1, 1, 1, 1, 1],\n },\n \"sophisticated_memory\": {\n \"buckets\": [\n NAVIGATE_AND_CREATE_TASKS,\n NAVIGATE_AND_ORDER_TASKS,\n NAVIGATE_AND_FILTER_TASKS,\n NAVIGATE_AND_SORT_TASKS,\n OFFBOARD_USER_TASKS,\n ONBOARD_USER_TASKS,\n ],\n \"num_seeds\": 2,\n \"weights\": [1, 1, 1, 1, 1, 1],\n },\n \"contextual_understanding_infeasible_tasks\": {\n \"buckets\": [\n INFEASIBLE_NAVIGATE_AND_CREATE_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_CREATE,\n INFEASIBLE_NAVIGATE_AND_ORDER_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_ORDER,\n INFEASIBLE_NAVIGATE_AND_FILTER_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_FILTER,\n INFEASIBLE_NAVIGATE_AND_SORT_WITH_REASON,\n INFEASIBLE_NAVIGATE_AND_SORT,\n ],\n \"num_seeds\": 1,\n \"weights\": [1, 1, 1, 1, 1, 1, 1, 1],\n },\n}","source_hash":"6659cf2e29de7ef9f818f36ff73483189a601b4278ae9287f4b0402dfb660730","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.service_catalog","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.scripts.service_catalog#L1-L124","kind":"module","name":"src.browsergym.workarena.tasks.scripts.service_catalog","path":"src/browsergym/workarena/tasks/scripts/service_catalog.py","language":"python","start_line":1,"end_line":124,"context_start_line":1,"context_end_line":124,"code":"import json\nimport multiprocessing\nimport random\nimport re\n\nfrom itertools import product, combinations\nfrom browsergym.workarena.tasks.service_catalog import META_CONFIGS\nfrom browsergym.workarena.config import (\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n)\nfrom browsergym.workarena.tasks.service_catalog import __TASKS__\n\n# The number of configurations to generate per item, as described in the WorkArena paper\nNUM_CONFIGS_PER_ITEM = {\n \"Developer Laptop (Mac)\": 1000,\n \"iPad mini\": 80,\n \"iPad pro\": 90,\n \"Sales Laptop\": 1000,\n \"Standard Laptop\": 1000,\n \"Apple Watch\": 10,\n \"Apple MacBook Pro 15\": 10,\n \"Development Laptop (PC)\": 40,\n \"Loaner Laptop\": 350,\n}\n\nplaceholder_tasks = [task() for task in __TASKS__]\nITEM_TO_TASK = {task.fixed_request_item: task.__class__.__name__ for task in placeholder_tasks}\n\nCONFIG_PATHS = [\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n]\nTASK_TO_CONFIG_PATH = dict(zip(__TASKS__, CONFIG_PATHS))\n\n\ndef generate_configs_for_all_items():\n \"\"\"Create task configs for all items; one file per task\"\"\"\n for item_choice, configs in META_CONFIGS.items():\n all_configs_for_a_single_item = generate_all_item_configs(item_choice, configs)\n num_configs_for_item = NUM_CONFIGS_PER_ITEM[item_choice]\n if len(all_configs_for_a_single_item) > num_configs_for_item:\n all_configs_for_a_single_item = random.sample(\n all_configs_for_a_single_item, num_configs_for_item\n )\n name = ITEM_TO_TASK[item_choice]\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n with open(\n f\"browsergym/workarena/src/browsergym/workarena/data_files/task_configs/{task_name}.json\",\n \"w\",\n ) as f:\n all_configs_for_a_single_item = sorted(\n all_configs_for_a_single_item,\n key=lambda x: x[\"item\"] + str(x[\"quantity\"]),\n )\n json.dump(all_configs_for_a_single_item, f, indent=4, sort_keys=True)\n\n\ndef generate_all_item_configs(item_choice, configs):\n \"\"\"\n generates all possible configurations for a given item choice and its configuration options.\n \"\"\"\n all_configs = []\n\n # Prepare the configuration options by maintaining their type and possible values\n config_options = {}\n for config_key, config_values in configs[\"options\"].items():\n if config_values[0] in [\"checkbox\", \"radio\"]:\n # Store each option with its type and each possible value\n config_options[config_key] = [(config_values[0], value) for value in config_values[1]]\n elif config_values[0] == \"textarea\":\n text_options = config_values[1]\n if config_key == \"Additional software requirements\":\n config_options[config_key] = [\n (\"textarea\", \", \".join(option))\n for n in range(\n 1, len(text_options) + 1\n ) # Changed to 1 to len to avoid empty selection\n for option in combinations(text_options, n)\n ]\n else:\n config_options[config_key] = [(\"textarea\", option) for option in text_options]\n\n # Iterate over all possible configurations\n for values in product(*config_options.values()):\n # Pair each configuration key with its corresponding (type, value) tuple\n config_dict = dict(zip(config_options.keys(), values))\n for quantity in range(1, 11):\n # Construct the full configuration dictionary for each combination\n task_config = {\n \"item\": item_choice,\n \"description\": configs[\"desc\"],\n \"quantity\": quantity, # Static quantity; can be adjusted if needed\n \"configuration\": config_dict,\n }\n all_configs.append(task_config)\n\n return all_configs\n\n\ndef count_all_item_occurrences(configs):\n counts = {}\n for config in configs:\n item_name = config[\"item\"]\n if item_name in counts:\n counts[item_name] += 1\n else:\n counts[item_name] = 1\n return counts","source_hash":"fe396541611f89489d460897fa115b76b4d12a68ae7ef40ee11279e7c87c1ee4","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.service_catalog.generate_configs_for_all_items","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.service_catalog.generate_configs_for_all_items#L51-L71","kind":"function","name":"generate_configs_for_all_items","path":"src/browsergym/workarena/tasks/scripts/service_catalog.py","language":"python","start_line":51,"end_line":71,"context_start_line":31,"context_end_line":91,"code":" \"Loaner Laptop\": 350,\n}\n\nplaceholder_tasks = [task() for task in __TASKS__]\nITEM_TO_TASK = {task.fixed_request_item: task.__class__.__name__ for task in placeholder_tasks}\n\nCONFIG_PATHS = [\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n]\nTASK_TO_CONFIG_PATH = dict(zip(__TASKS__, CONFIG_PATHS))\n\n\ndef generate_configs_for_all_items():\n \"\"\"Create task configs for all items; one file per task\"\"\"\n for item_choice, configs in META_CONFIGS.items():\n all_configs_for_a_single_item = generate_all_item_configs(item_choice, configs)\n num_configs_for_item = NUM_CONFIGS_PER_ITEM[item_choice]\n if len(all_configs_for_a_single_item) > num_configs_for_item:\n all_configs_for_a_single_item = random.sample(\n all_configs_for_a_single_item, num_configs_for_item\n )\n name = ITEM_TO_TASK[item_choice]\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n with open(\n f\"browsergym/workarena/src/browsergym/workarena/data_files/task_configs/{task_name}.json\",\n \"w\",\n ) as f:\n all_configs_for_a_single_item = sorted(\n all_configs_for_a_single_item,\n key=lambda x: x[\"item\"] + str(x[\"quantity\"]),\n )\n json.dump(all_configs_for_a_single_item, f, indent=4, sort_keys=True)\n\n\ndef generate_all_item_configs(item_choice, configs):\n \"\"\"\n generates all possible configurations for a given item choice and its configuration options.\n \"\"\"\n all_configs = []\n\n # Prepare the configuration options by maintaining their type and possible values\n config_options = {}\n for config_key, config_values in configs[\"options\"].items():\n if config_values[0] in [\"checkbox\", \"radio\"]:\n # Store each option with its type and each possible value\n config_options[config_key] = [(config_values[0], value) for value in config_values[1]]\n elif config_values[0] == \"textarea\":\n text_options = config_values[1]\n if config_key == \"Additional software requirements\":\n config_options[config_key] = [\n (\"textarea\", \", \".join(option))\n for n in range(","source_hash":"fe396541611f89489d460897fa115b76b4d12a68ae7ef40ee11279e7c87c1ee4","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.service_catalog.generate_all_item_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.service_catalog.generate_all_item_configs#L74-L113","kind":"function","name":"generate_all_item_configs","path":"src/browsergym/workarena/tasks/scripts/service_catalog.py","language":"python","start_line":74,"end_line":113,"context_start_line":54,"context_end_line":124,"code":" all_configs_for_a_single_item = generate_all_item_configs(item_choice, configs)\n num_configs_for_item = NUM_CONFIGS_PER_ITEM[item_choice]\n if len(all_configs_for_a_single_item) > num_configs_for_item:\n all_configs_for_a_single_item = random.sample(\n all_configs_for_a_single_item, num_configs_for_item\n )\n name = ITEM_TO_TASK[item_choice]\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n with open(\n f\"browsergym/workarena/src/browsergym/workarena/data_files/task_configs/{task_name}.json\",\n \"w\",\n ) as f:\n all_configs_for_a_single_item = sorted(\n all_configs_for_a_single_item,\n key=lambda x: x[\"item\"] + str(x[\"quantity\"]),\n )\n json.dump(all_configs_for_a_single_item, f, indent=4, sort_keys=True)\n\n\ndef generate_all_item_configs(item_choice, configs):\n \"\"\"\n generates all possible configurations for a given item choice and its configuration options.\n \"\"\"\n all_configs = []\n\n # Prepare the configuration options by maintaining their type and possible values\n config_options = {}\n for config_key, config_values in configs[\"options\"].items():\n if config_values[0] in [\"checkbox\", \"radio\"]:\n # Store each option with its type and each possible value\n config_options[config_key] = [(config_values[0], value) for value in config_values[1]]\n elif config_values[0] == \"textarea\":\n text_options = config_values[1]\n if config_key == \"Additional software requirements\":\n config_options[config_key] = [\n (\"textarea\", \", \".join(option))\n for n in range(\n 1, len(text_options) + 1\n ) # Changed to 1 to len to avoid empty selection\n for option in combinations(text_options, n)\n ]\n else:\n config_options[config_key] = [(\"textarea\", option) for option in text_options]\n\n # Iterate over all possible configurations\n for values in product(*config_options.values()):\n # Pair each configuration key with its corresponding (type, value) tuple\n config_dict = dict(zip(config_options.keys(), values))\n for quantity in range(1, 11):\n # Construct the full configuration dictionary for each combination\n task_config = {\n \"item\": item_choice,\n \"description\": configs[\"desc\"],\n \"quantity\": quantity, # Static quantity; can be adjusted if needed\n \"configuration\": config_dict,\n }\n all_configs.append(task_config)\n\n return all_configs\n\n\ndef count_all_item_occurrences(configs):\n counts = {}\n for config in configs:\n item_name = config[\"item\"]\n if item_name in counts:\n counts[item_name] += 1\n else:\n counts[item_name] = 1\n return counts","source_hash":"fe396541611f89489d460897fa115b76b4d12a68ae7ef40ee11279e7c87c1ee4","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.service_catalog.count_all_item_occurrences","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.service_catalog.count_all_item_occurrences#L116-L124","kind":"function","name":"count_all_item_occurrences","path":"src/browsergym/workarena/tasks/scripts/service_catalog.py","language":"python","start_line":116,"end_line":124,"context_start_line":96,"context_end_line":124,"code":" else:\n config_options[config_key] = [(\"textarea\", option) for option in text_options]\n\n # Iterate over all possible configurations\n for values in product(*config_options.values()):\n # Pair each configuration key with its corresponding (type, value) tuple\n config_dict = dict(zip(config_options.keys(), values))\n for quantity in range(1, 11):\n # Construct the full configuration dictionary for each combination\n task_config = {\n \"item\": item_choice,\n \"description\": configs[\"desc\"],\n \"quantity\": quantity, # Static quantity; can be adjusted if needed\n \"configuration\": config_dict,\n }\n all_configs.append(task_config)\n\n return all_configs\n\n\ndef count_all_item_occurrences(configs):\n counts = {}\n for config in configs:\n item_name = config[\"item\"]\n if item_name in counts:\n counts[item_name] += 1\n else:\n counts[item_name] = 1\n return counts","source_hash":"fe396541611f89489d460897fa115b76b4d12a68ae7ef40ee11279e7c87c1ee4","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.generate_dashboard_configs","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.scripts.generate_dashboard_configs#L1-L273","kind":"module","name":"src.browsergym.workarena.tasks.scripts.generate_dashboard_configs","path":"src/browsergym/workarena/tasks/scripts/generate_dashboard_configs.py","language":"python","start_line":1,"end_line":273,"context_start_line":1,"context_end_line":273,"code":"\"\"\"\nGenerate configurations for the report and dashboard tasks\n\nNotes: sometimes it crashes (e.g., timeout, etc.). Just relaunch and it will be fine.\n\n\"\"\"\n\nimport json\nimport multiprocessing\nimport random\nimport tenacity\n\nfrom functools import partial\nfrom playwright.sync_api import sync_playwright\n\nfrom browsergym.workarena.api.utils import table_api_call, table_column_info\nfrom browsergym.workarena.config import (\n REPORT_DATE_FILTER,\n REPORT_PATCH_FLAG,\n REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,\n REPORT_RETRIEVAL_VALUE_CONFIG_PATH,\n DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH,\n DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH,\n)\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.tasks.dashboard import DashboardRetrievalTask\n\n\nN_CPU = 20\nMAX_CONFIGS = 1000\nREPORT = False # Set to True for reports, False for dashboards\n\n\nclass DummyDashboard(DashboardRetrievalTask):\n def all_configs(self):\n return [\n {\n \"url\": \"\",\n \"chart_title\": \"\",\n \"chart_series\": \"\",\n \"question\": \"max\",\n }\n ]\n\n\ndef get_report_urls(instance):\n # Generate a bunch of reports on the fly based on valid table fields\n ON_THE_FLY_REPORTS = []\n for table in [\n \"alm_asset\",\n \"alm_hardware\",\n \"asmt_assessment_instance_question\",\n \"asmt_m2m_stakeholder\",\n \"ast_contract\",\n \"change_request\",\n \"cmdb_ci_computer\",\n \"incident\",\n \"sc_cat_item\",\n \"sys_user\",\n ]:\n cols = [\n x\n for x, y in table_column_info(instance=instance, table=table).items()\n if y.get(\"cangroup\", False)\n and y.get(\"type\", None) == \"choice\"\n and \"upon\" not in x.lower()\n ]\n for col in cols:\n ON_THE_FLY_REPORTS.append({\"table\": table, \"field\": col, \"type\": \"pie\"})\n ON_THE_FLY_REPORTS.append({\"table\": table, \"field\": col, \"type\": \"bar\"})\n\n # Reports that are already in the instance\n system_report_tables = \"alm_asset,alm_hardware,asmt_assessment_instance_question,asmt_m2m_stakeholder,ast_contract,change_request,cmdb_ci_computer\"\n SYSTEM_REPORTS = table_api_call(\n instance=instance,\n table=\"sys_report\",\n params={\n \"sysparm_query\": f\"sys_class_name=sys_report^active=true^typeINtrend,donut,vertical_bar,line,horizontal_bar,pie,bar,spline,area^descriptionLIKE{REPORT_PATCH_FLAG}^tableIN{system_report_tables}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n\n REPORTS = ON_THE_FLY_REPORTS + SYSTEM_REPORTS\n\n return [\n (\n f\"/now/nav/ui/classic/params/target/sys_report_template.do%3Fsysparm_field%3D{report['field']}%26sysparm_type%3D{report['type']}%26sysparm_table%3D{report['table']}%26sysparm_from_list%3Dtrue%26sysparm_chart_size%3Dlarge%26sysparm_manual_labor%3Dtrue%26sysparm_query=sys_created_on 1 else \"\"\n data = chart_data[series_idx][\"data\"]\n\n # Check if the data is interesting\n labels = [point[\"label\"] for point in data]\n if len(labels) <= 1:\n continue\n\n if any(l.isdigit() for l in labels):\n continue\n\n # Generate all value questions\n for format in [\"count\", \"percent\"]:\n for label in labels:\n questions.append(\n {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": series_name,\n \"question\": f\"value; {format}; {label}\",\n }\n )\n\n # Generate all other questions\n questions.append(\n {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": series_name,\n \"question\": \"min\",\n }\n )\n questions.append(\n {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": series_name,\n \"question\": \"max\",\n }\n )\n except Exception as e:\n print(\"Exception in worker\", url, chart_title, e)\n continue # Skip this chart\n\n if len(questions) == 0:\n return []\n\n # Test out all questions and keep only those that work\n valid_questions = []\n for question in questions:\n chat_messages = []\n task.config = question\n\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n valid = task.validate(page=page, chat_messages=chat_messages)[0]\n except Exception as e:\n # raise e\n print(\"Exception in worker config validations\", url, question, e)\n valid = 0\n\n if valid == 1:\n valid_questions.append(question)\n else:\n print(f\"Failed to validate question {question}\")\n\n print(\"Worker found\", len(valid_questions), \"valid questions\")\n return valid_questions\n\n\nif __name__ == \"__main__\":\n instance = SNowInstance()\n reports = get_report_urls(instance)\n gen_func = partial(get_all_configs_by_url, is_report=REPORT)\n\n if REPORT:\n urls = get_report_urls(instance)\n output_by_question = {\n \"value\": REPORT_RETRIEVAL_VALUE_CONFIG_PATH,\n \"min,max\": REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,\n }\n else:\n urls = get_dashboard_urls(instance)\n output_by_question = {\n \"value\": DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH,\n \"min,max\": DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH,\n }\n\n print(f\"Generating configs for {len(urls)} URLs\")\n configs = []\n with multiprocessing.Pool(processes=N_CPU) as pool:\n results = pool.map(gen_func, urls)\n pool.close()\n pool.join()\n\n # Flatten results list into config\n for result in results:\n configs += result\n\n # Post-process the configs and save them\n for question_type in output_by_question:\n types = [x.strip() for x in question_type.split(\",\")]\n\n type_configs = [\n config for config in configs if config[\"question\"].split(\";\")[0].strip() in types\n ]\n type_configs = set(\n json.dumps(c) for c in type_configs\n ) # Serialize to string to make unique\n type_configs = [json.loads(c) for c in type_configs]\n random.shuffle(type_configs)\n type_configs = type_configs[:MAX_CONFIGS]\n\n print(\"Saving\", len(type_configs), \"configs for\", question_type)\n with open(output_by_question[question_type], \"w\") as f:\n json.dump(type_configs, f)","source_hash":"af67032d1d67d699dfe66ffc5c84cdc7ddf3b98b7925a0556a2bade0ea989647","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.generate_dashboard_configs.DummyDashboard","uri":"program://WorkArena/class/src.browsergym.workarena.tasks.scripts.generate_dashboard_configs.DummyDashboard#L34-L43","kind":"class","name":"DummyDashboard","path":"src/browsergym/workarena/tasks/scripts/generate_dashboard_configs.py","language":"python","start_line":34,"end_line":43,"context_start_line":14,"context_end_line":63,"code":"from playwright.sync_api import sync_playwright\n\nfrom browsergym.workarena.api.utils import table_api_call, table_column_info\nfrom browsergym.workarena.config import (\n REPORT_DATE_FILTER,\n REPORT_PATCH_FLAG,\n REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,\n REPORT_RETRIEVAL_VALUE_CONFIG_PATH,\n DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH,\n DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH,\n)\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.tasks.dashboard import DashboardRetrievalTask\n\n\nN_CPU = 20\nMAX_CONFIGS = 1000\nREPORT = False # Set to True for reports, False for dashboards\n\n\nclass DummyDashboard(DashboardRetrievalTask):\n def all_configs(self):\n return [\n {\n \"url\": \"\",\n \"chart_title\": \"\",\n \"chart_series\": \"\",\n \"question\": \"max\",\n }\n ]\n\n\ndef get_report_urls(instance):\n # Generate a bunch of reports on the fly based on valid table fields\n ON_THE_FLY_REPORTS = []\n for table in [\n \"alm_asset\",\n \"alm_hardware\",\n \"asmt_assessment_instance_question\",\n \"asmt_m2m_stakeholder\",\n \"ast_contract\",\n \"change_request\",\n \"cmdb_ci_computer\",\n \"incident\",\n \"sc_cat_item\",\n \"sys_user\",\n ]:\n cols = [\n x\n for x, y in table_column_info(instance=instance, table=table).items()","source_hash":"af67032d1d67d699dfe66ffc5c84cdc7ddf3b98b7925a0556a2bade0ea989647","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.generate_dashboard_configs.get_report_urls","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.generate_dashboard_configs.get_report_urls#L46-L92","kind":"function","name":"get_report_urls","path":"src/browsergym/workarena/tasks/scripts/generate_dashboard_configs.py","language":"python","start_line":46,"end_line":92,"context_start_line":26,"context_end_line":112,"code":"from browsergym.workarena.tasks.dashboard import DashboardRetrievalTask\n\n\nN_CPU = 20\nMAX_CONFIGS = 1000\nREPORT = False # Set to True for reports, False for dashboards\n\n\nclass DummyDashboard(DashboardRetrievalTask):\n def all_configs(self):\n return [\n {\n \"url\": \"\",\n \"chart_title\": \"\",\n \"chart_series\": \"\",\n \"question\": \"max\",\n }\n ]\n\n\ndef get_report_urls(instance):\n # Generate a bunch of reports on the fly based on valid table fields\n ON_THE_FLY_REPORTS = []\n for table in [\n \"alm_asset\",\n \"alm_hardware\",\n \"asmt_assessment_instance_question\",\n \"asmt_m2m_stakeholder\",\n \"ast_contract\",\n \"change_request\",\n \"cmdb_ci_computer\",\n \"incident\",\n \"sc_cat_item\",\n \"sys_user\",\n ]:\n cols = [\n x\n for x, y in table_column_info(instance=instance, table=table).items()\n if y.get(\"cangroup\", False)\n and y.get(\"type\", None) == \"choice\"\n and \"upon\" not in x.lower()\n ]\n for col in cols:\n ON_THE_FLY_REPORTS.append({\"table\": table, \"field\": col, \"type\": \"pie\"})\n ON_THE_FLY_REPORTS.append({\"table\": table, \"field\": col, \"type\": \"bar\"})\n\n # Reports that are already in the instance\n system_report_tables = \"alm_asset,alm_hardware,asmt_assessment_instance_question,asmt_m2m_stakeholder,ast_contract,change_request,cmdb_ci_computer\"\n SYSTEM_REPORTS = table_api_call(\n instance=instance,\n table=\"sys_report\",\n params={\n \"sysparm_query\": f\"sys_class_name=sys_report^active=true^typeINtrend,donut,vertical_bar,line,horizontal_bar,pie,bar,spline,area^descriptionLIKE{REPORT_PATCH_FLAG}^tableIN{system_report_tables}\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"]\n\n REPORTS = ON_THE_FLY_REPORTS + SYSTEM_REPORTS\n\n return [\n (\n f\"/now/nav/ui/classic/params/target/sys_report_template.do%3Fsysparm_field%3D{report['field']}%26sysparm_type%3D{report['type']}%26sysparm_table%3D{report['table']}%26sysparm_from_list%3Dtrue%26sysparm_chart_size%3Dlarge%26sysparm_manual_labor%3Dtrue%26sysparm_query=sys_created_on 1 else \"\"\n data = chart_data[series_idx][\"data\"]\n\n # Check if the data is interesting\n labels = [point[\"label\"] for point in data]\n if len(labels) <= 1:\n continue\n\n if any(l.isdigit() for l in labels):\n continue\n\n # Generate all value questions\n for format in [\"count\", \"percent\"]:\n for label in labels:\n questions.append(\n {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": series_name,\n \"question\": f\"value; {format}; {label}\",\n }\n )\n\n # Generate all other questions\n questions.append(\n {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": series_name,\n \"question\": \"min\",\n }\n )\n questions.append(\n {\n \"url\": url,\n \"chart_title\": chart_title,\n \"chart_series\": series_name,\n \"question\": \"max\",\n }\n )\n except Exception as e:\n print(\"Exception in worker\", url, chart_title, e)\n continue # Skip this chart\n\n if len(questions) == 0:\n return []\n\n # Test out all questions and keep only those that work\n valid_questions = []\n for question in questions:\n chat_messages = []\n task.config = question\n\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n valid = task.validate(page=page, chat_messages=chat_messages)[0]\n except Exception as e:\n # raise e\n print(\"Exception in worker config validations\", url, question, e)\n valid = 0\n\n if valid == 1:\n valid_questions.append(question)\n else:\n print(f\"Failed to validate question {question}\")\n\n print(\"Worker found\", len(valid_questions), \"valid questions\")\n return valid_questions\n\n\nif __name__ == \"__main__\":\n instance = SNowInstance()\n reports = get_report_urls(instance)\n gen_func = partial(get_all_configs_by_url, is_report=REPORT)\n\n if REPORT:\n urls = get_report_urls(instance)\n output_by_question = {\n \"value\": REPORT_RETRIEVAL_VALUE_CONFIG_PATH,\n \"min,max\": REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,\n }\n else:\n urls = get_dashboard_urls(instance)\n output_by_question = {\n \"value\": DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH,\n \"min,max\": DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH,\n }\n","source_hash":"af67032d1d67d699dfe66ffc5c84cdc7ddf3b98b7925a0556a2bade0ea989647","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.generate_dashboard_configs.all_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.generate_dashboard_configs.all_configs#L35-L43","kind":"function","name":"all_configs","path":"src/browsergym/workarena/tasks/scripts/generate_dashboard_configs.py","language":"python","start_line":35,"end_line":43,"context_start_line":15,"context_end_line":63,"code":"\nfrom browsergym.workarena.api.utils import table_api_call, table_column_info\nfrom browsergym.workarena.config import (\n REPORT_DATE_FILTER,\n REPORT_PATCH_FLAG,\n REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,\n REPORT_RETRIEVAL_VALUE_CONFIG_PATH,\n DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH,\n DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH,\n)\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.tasks.dashboard import DashboardRetrievalTask\n\n\nN_CPU = 20\nMAX_CONFIGS = 1000\nREPORT = False # Set to True for reports, False for dashboards\n\n\nclass DummyDashboard(DashboardRetrievalTask):\n def all_configs(self):\n return [\n {\n \"url\": \"\",\n \"chart_title\": \"\",\n \"chart_series\": \"\",\n \"question\": \"max\",\n }\n ]\n\n\ndef get_report_urls(instance):\n # Generate a bunch of reports on the fly based on valid table fields\n ON_THE_FLY_REPORTS = []\n for table in [\n \"alm_asset\",\n \"alm_hardware\",\n \"asmt_assessment_instance_question\",\n \"asmt_m2m_stakeholder\",\n \"ast_contract\",\n \"change_request\",\n \"cmdb_ci_computer\",\n \"incident\",\n \"sc_cat_item\",\n \"sys_user\",\n ]:\n cols = [\n x\n for x, y in table_column_info(instance=instance, table=table).items()","source_hash":"af67032d1d67d699dfe66ffc5c84cdc7ddf3b98b7925a0556a2bade0ea989647","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.validate","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.scripts.validate#L1-L207","kind":"module","name":"src.browsergym.workarena.tasks.scripts.validate","path":"src/browsergym/workarena/tasks/scripts/validate.py","language":"python","start_line":1,"end_line":207,"context_start_line":1,"context_end_line":207,"code":"import json\nimport logging\nimport multiprocessing\n\nfrom browsergym.workarena.config import (\n # navigation tasks\n ALL_MENU_PATH,\n IMPERSONATION_CONFIG_PATH,\n # form tasks\n CREATE_CHANGE_REQUEST_CONFIG_PATH,\n CREATE_HARDWARE_CONFIG_PATH,\n CREATE_INCIDENT_CONFIG_PATH,\n CREATE_PROBLEM_CONFIG_PATH,\n CREATE_USER_CONFIG_PATH,\n # list tasks\n FILTER_ASSET_LIST_CONFIG_PATH,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n FILTER_HARDWARE_LIST_CONFIG_PATH,\n FILTER_INCIDENT_LIST_CONFIG_PATH,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n FILTER_USER_LIST_CONFIG_PATH,\n SORT_ASSET_LIST_CONFIG_PATH,\n SORT_CHANGE_REQUEST_LIST_CONFIG_PATH,\n SORT_HARDWARE_LIST_CONFIG_PATH,\n SORT_INCIDENT_LIST_CONFIG_PATH,\n SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n SORT_USER_LIST_CONFIG_PATH,\n # knowledge tasks\n KB_CONFIG_PATH,\n # Service Catalog tasks\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n)\nfrom browsergym.workarena.tasks.form import (\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,\n CreateUserTask,\n)\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterChangeRequestListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterServiceCatalogItemListTask,\n FilterUserListTask,\n SortAssetListTask,\n SortChangeRequestListTask,\n SortHardwareListTask,\n SortIncidentListTask,\n SortServiceCatalogItemListTask,\n SortUserListTask,\n)\nfrom browsergym.workarena.tasks.navigation import AllMenuTask, ImpersonationTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt\nfrom tqdm import tqdm\n\ntask_to_config_path_mapping = {\n AllMenuTask: ALL_MENU_PATH,\n ImpersonationTask: IMPERSONATION_CONFIG_PATH,\n OrderDeveloperLaptopTask: ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n OrderIpadMiniTask: ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n OrderIpadProTask: ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n OrderSalesLaptopTask: ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n OrderStandardLaptopTask: ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n OrderAppleWatchTask: ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n OrderAppleMacBookPro15Task: ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n OrderDevelopmentLaptopPCTask: ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n OrderLoanerLaptopTask: ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n CreateChangeRequestTask: CREATE_CHANGE_REQUEST_CONFIG_PATH,\n CreateHardwareAssetTask: CREATE_HARDWARE_CONFIG_PATH,\n CreateIncidentTask: CREATE_INCIDENT_CONFIG_PATH,\n CreateProblemTask: CREATE_PROBLEM_CONFIG_PATH,\n CreateUserTask: CREATE_USER_CONFIG_PATH,\n KnowledgeBaseSearchTask: KB_CONFIG_PATH,\n FilterAssetListTask: FILTER_ASSET_LIST_CONFIG_PATH,\n FilterChangeRequestListTask: FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n FilterHardwareListTask: FILTER_HARDWARE_LIST_CONFIG_PATH,\n FilterIncidentListTask: FILTER_INCIDENT_LIST_CONFIG_PATH,\n FilterServiceCatalogItemListTask: FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n FilterUserListTask: FILTER_USER_LIST_CONFIG_PATH,\n SortAssetListTask: SORT_ASSET_LIST_CONFIG_PATH,\n SortChangeRequestListTask: SORT_CHANGE_REQUEST_LIST_CONFIG_PATH,\n SortHardwareListTask: SORT_HARDWARE_LIST_CONFIG_PATH,\n SortIncidentListTask: SORT_INCIDENT_LIST_CONFIG_PATH,\n SortServiceCatalogItemListTask: SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n SortUserListTask: SORT_USER_LIST_CONFIG_PATH,\n}\n\n\n@retry(stop=stop_after_attempt(3), reraise=True)\ndef validate_task(task_config, task_class, page=None):\n \"\"\"Validates a task with a given configuration\"\"\"\n num_attempts = 4\n tries = 0\n while tries < num_attempts:\n if page is None:\n # To run validation\n with sync_playwright() as p:\n browser = p.chromium.launch(slow_mo=1000)\n context = browser.new_context()\n page = context.new_page()\n cheat_passed, task_done, reward = validate_on_page(task_class, task_config, page)\n else:\n # For testing pusposes\n cheat_passed, task_done, reward = validate_on_page(task_class, task_config, page)\n tries += 1\n task_successful = task_done is True and reward == 1.0\n if task_successful:\n break\n else:\n logging.warning(\n f\"Task {task_class.__name__} was not successful ({tries} / {num_attempts})\"\n )\n\n return task_done, reward, task_config, cheat_passed\n\n\ndef validate_on_page(task_class, task_config, page):\n \"\"\"Validate a configuration on a given page\"\"\"\n cheat_passed = False\n task_done = False\n reward = 0.0\n task = task_class(seed=1, fixed_config=task_config)\n task.setup(page=page)\n chat_messages = []\n task.cheat(page=page, chat_messages=chat_messages)\n cheat_passed = True\n page.wait_for_timeout(2000)\n reward, task_done, _, _ = task.validate(page, chat_messages)\n task.teardown()\n\n return cheat_passed, task_done, reward\n\n\ndef validate_configs(\n task_class,\n config_path,\n num_tasks: int = None,\n save_failed_tasks: bool = True,\n page=None,\n) -> list[dict]:\n \"\"\"Validate that the configs are working. Saves failing configs to json so they can be tested.\"\"\"\n with open(config_path, \"r\") as f:\n all_configs = json.load(f)\n\n if num_tasks is not None:\n all_configs = all_configs[:num_tasks]\n\n failed_tasks = {\"cheat\": [], \"no_reward\": [], \"exception\": [], \"not_done\": []}\n with tqdm(\n total=len(all_configs),\n desc=f\"Validating {task_class.__name__} configs\",\n ncols=150,\n ) as pbar:\n for task_config in all_configs:\n try:\n task_done, reward, task_config, cheat_passed = validate_task(\n task_config, task_class, page\n )\n success = task_done and reward == 1.0\n if not cheat_passed:\n failed_tasks[\"cheat\"].append(task_config)\n elif not task_done:\n failed_tasks[\"not_done\"].append(task_config)\n elif reward == 0:\n failed_tasks[\"no_reward\"].append(task_config)\n\n print(success)\n except Exception as e:\n failed_tasks[\"exception\"].append(task_config)\n print(f\"Exception {e}\")\n pbar.update(1)\n if save_failed_tasks:\n # Save failed tasks to a JSON file\n with open(f\"failed_{task_class.__name__}.json\", \"w\") as f:\n json.dump(failed_tasks, f)\n\n return failed_tasks\n\n\nif __name__ == \"__main__\":\n with multiprocessing.Pool() as pool:\n tasks_and_paths = list(task_to_config_path_mapping.items())\n pool.starmap(validate_configs, tasks_and_paths)","source_hash":"438497344b6348df0f9bafc5cfc75d3afe616d26b1725ce28bf066ddd487bde1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.validate.validate_task","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.validate.validate_task#L114-L138","kind":"function","name":"validate_task","path":"src/browsergym/workarena/tasks/scripts/validate.py","language":"python","start_line":114,"end_line":138,"context_start_line":94,"context_end_line":158,"code":" CreateIncidentTask: CREATE_INCIDENT_CONFIG_PATH,\n CreateProblemTask: CREATE_PROBLEM_CONFIG_PATH,\n CreateUserTask: CREATE_USER_CONFIG_PATH,\n KnowledgeBaseSearchTask: KB_CONFIG_PATH,\n FilterAssetListTask: FILTER_ASSET_LIST_CONFIG_PATH,\n FilterChangeRequestListTask: FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n FilterHardwareListTask: FILTER_HARDWARE_LIST_CONFIG_PATH,\n FilterIncidentListTask: FILTER_INCIDENT_LIST_CONFIG_PATH,\n FilterServiceCatalogItemListTask: FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n FilterUserListTask: FILTER_USER_LIST_CONFIG_PATH,\n SortAssetListTask: SORT_ASSET_LIST_CONFIG_PATH,\n SortChangeRequestListTask: SORT_CHANGE_REQUEST_LIST_CONFIG_PATH,\n SortHardwareListTask: SORT_HARDWARE_LIST_CONFIG_PATH,\n SortIncidentListTask: SORT_INCIDENT_LIST_CONFIG_PATH,\n SortServiceCatalogItemListTask: SORT_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n SortUserListTask: SORT_USER_LIST_CONFIG_PATH,\n}\n\n\n@retry(stop=stop_after_attempt(3), reraise=True)\ndef validate_task(task_config, task_class, page=None):\n \"\"\"Validates a task with a given configuration\"\"\"\n num_attempts = 4\n tries = 0\n while tries < num_attempts:\n if page is None:\n # To run validation\n with sync_playwright() as p:\n browser = p.chromium.launch(slow_mo=1000)\n context = browser.new_context()\n page = context.new_page()\n cheat_passed, task_done, reward = validate_on_page(task_class, task_config, page)\n else:\n # For testing pusposes\n cheat_passed, task_done, reward = validate_on_page(task_class, task_config, page)\n tries += 1\n task_successful = task_done is True and reward == 1.0\n if task_successful:\n break\n else:\n logging.warning(\n f\"Task {task_class.__name__} was not successful ({tries} / {num_attempts})\"\n )\n\n return task_done, reward, task_config, cheat_passed\n\n\ndef validate_on_page(task_class, task_config, page):\n \"\"\"Validate a configuration on a given page\"\"\"\n cheat_passed = False\n task_done = False\n reward = 0.0\n task = task_class(seed=1, fixed_config=task_config)\n task.setup(page=page)\n chat_messages = []\n task.cheat(page=page, chat_messages=chat_messages)\n cheat_passed = True\n page.wait_for_timeout(2000)\n reward, task_done, _, _ = task.validate(page, chat_messages)\n task.teardown()\n\n return cheat_passed, task_done, reward\n\n\ndef validate_configs(","source_hash":"438497344b6348df0f9bafc5cfc75d3afe616d26b1725ce28bf066ddd487bde1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.validate.validate_on_page","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.validate.validate_on_page#L141-L155","kind":"function","name":"validate_on_page","path":"src/browsergym/workarena/tasks/scripts/validate.py","language":"python","start_line":141,"end_line":155,"context_start_line":121,"context_end_line":175,"code":" with sync_playwright() as p:\n browser = p.chromium.launch(slow_mo=1000)\n context = browser.new_context()\n page = context.new_page()\n cheat_passed, task_done, reward = validate_on_page(task_class, task_config, page)\n else:\n # For testing pusposes\n cheat_passed, task_done, reward = validate_on_page(task_class, task_config, page)\n tries += 1\n task_successful = task_done is True and reward == 1.0\n if task_successful:\n break\n else:\n logging.warning(\n f\"Task {task_class.__name__} was not successful ({tries} / {num_attempts})\"\n )\n\n return task_done, reward, task_config, cheat_passed\n\n\ndef validate_on_page(task_class, task_config, page):\n \"\"\"Validate a configuration on a given page\"\"\"\n cheat_passed = False\n task_done = False\n reward = 0.0\n task = task_class(seed=1, fixed_config=task_config)\n task.setup(page=page)\n chat_messages = []\n task.cheat(page=page, chat_messages=chat_messages)\n cheat_passed = True\n page.wait_for_timeout(2000)\n reward, task_done, _, _ = task.validate(page, chat_messages)\n task.teardown()\n\n return cheat_passed, task_done, reward\n\n\ndef validate_configs(\n task_class,\n config_path,\n num_tasks: int = None,\n save_failed_tasks: bool = True,\n page=None,\n) -> list[dict]:\n \"\"\"Validate that the configs are working. Saves failing configs to json so they can be tested.\"\"\"\n with open(config_path, \"r\") as f:\n all_configs = json.load(f)\n\n if num_tasks is not None:\n all_configs = all_configs[:num_tasks]\n\n failed_tasks = {\"cheat\": [], \"no_reward\": [], \"exception\": [], \"not_done\": []}\n with tqdm(\n total=len(all_configs),\n desc=f\"Validating {task_class.__name__} configs\",","source_hash":"438497344b6348df0f9bafc5cfc75d3afe616d26b1725ce28bf066ddd487bde1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.validate.validate_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.validate.validate_configs#L158-L201","kind":"function","name":"validate_configs","path":"src/browsergym/workarena/tasks/scripts/validate.py","language":"python","start_line":158,"end_line":201,"context_start_line":138,"context_end_line":207,"code":" return task_done, reward, task_config, cheat_passed\n\n\ndef validate_on_page(task_class, task_config, page):\n \"\"\"Validate a configuration on a given page\"\"\"\n cheat_passed = False\n task_done = False\n reward = 0.0\n task = task_class(seed=1, fixed_config=task_config)\n task.setup(page=page)\n chat_messages = []\n task.cheat(page=page, chat_messages=chat_messages)\n cheat_passed = True\n page.wait_for_timeout(2000)\n reward, task_done, _, _ = task.validate(page, chat_messages)\n task.teardown()\n\n return cheat_passed, task_done, reward\n\n\ndef validate_configs(\n task_class,\n config_path,\n num_tasks: int = None,\n save_failed_tasks: bool = True,\n page=None,\n) -> list[dict]:\n \"\"\"Validate that the configs are working. Saves failing configs to json so they can be tested.\"\"\"\n with open(config_path, \"r\") as f:\n all_configs = json.load(f)\n\n if num_tasks is not None:\n all_configs = all_configs[:num_tasks]\n\n failed_tasks = {\"cheat\": [], \"no_reward\": [], \"exception\": [], \"not_done\": []}\n with tqdm(\n total=len(all_configs),\n desc=f\"Validating {task_class.__name__} configs\",\n ncols=150,\n ) as pbar:\n for task_config in all_configs:\n try:\n task_done, reward, task_config, cheat_passed = validate_task(\n task_config, task_class, page\n )\n success = task_done and reward == 1.0\n if not cheat_passed:\n failed_tasks[\"cheat\"].append(task_config)\n elif not task_done:\n failed_tasks[\"not_done\"].append(task_config)\n elif reward == 0:\n failed_tasks[\"no_reward\"].append(task_config)\n\n print(success)\n except Exception as e:\n failed_tasks[\"exception\"].append(task_config)\n print(f\"Exception {e}\")\n pbar.update(1)\n if save_failed_tasks:\n # Save failed tasks to a JSON file\n with open(f\"failed_{task_class.__name__}.json\", \"w\") as f:\n json.dump(failed_tasks, f)\n\n return failed_tasks\n\n\nif __name__ == \"__main__\":\n with multiprocessing.Pool() as pool:\n tasks_and_paths = list(task_to_config_path_mapping.items())\n pool.starmap(validate_configs, tasks_and_paths)","source_hash":"438497344b6348df0f9bafc5cfc75d3afe616d26b1725ce28bf066ddd487bde1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.extract_all_menu_items","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.scripts.extract_all_menu_items#L1-L219","kind":"module","name":"src.browsergym.workarena.tasks.scripts.extract_all_menu_items","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":1,"end_line":219,"context_start_line":1,"context_end_line":219,"code":"import json\nimport os\n\nfrom playwright.sync_api import sync_playwright\n\n\n# Load environment variables\nSNOW_INSTANCE_URL = os.getenv(\"SNOW_INSTANCE_URL\")\nSNOW_INSTANCE_UNAME = os.getenv(\"SNOW_INSTANCE_UNAME\")\nSNOW_INSTANCE_PWD = os.getenv(\"SNOW_INSTANCE_PWD\")\n\n# ==================================================================================================================\n# This file is a script that extracts all the menu tasks from the ServiceNow instance. It uses #\n# Playwright to navigate to the ServiceNow instance, log in, and extract all the menu items. It then saves #\n# menu items to a JSON file. The extracted menu items can be used to create tasks for the WorkArena benchmark. #\n# ==================================================================================================================\n\n\nif __name__ == \"__main__\":\n\n base_paths = []\n seen = dict()\n\n def close_all_paths(page, parent_selector=\"body\", current_path=[]):\n \"\"\"Recursively expand all menu items\"\"\"\n # Select all collapsible lists, regardless of whether they are expanded or not\n collapsible_lists = page.query_selector_all(\n f\"{parent_selector} .snf-collapsible-list > .snf-collapsible-list-header\"\n )\n for list_header in collapsible_lists:\n aria_label = list_header.get_attribute(\"aria-label\")\n aria_expanded = list_header.get_attribute(\"aria-expanded\")\n\n new_path = current_path + [aria_label] if aria_label else current_path\n\n if aria_expanded == \"true\":\n # If the list is not expanded, click to expand it\n list_header.click()\n page.wait_for_timeout(500)\n # Depending on the page, you might need to wait here for the list to actually expand\n\n # Get the unique identifier for the list to target nested lists within it\n data_id = list_header.get_attribute(\"data-id\")\n nested_parent_selector = f\".snf-collapsible-list-items[data-id='{data_id}-rows']\"\n\n # Recursively handle nested lists, now that the current list has been expanded\n close_all_paths(page, nested_parent_selector, new_path)\n\n def expand_and_gather_paths(page, parent_selector=\"body\", current_path=[]):\n \"\"\"Recursively expand all menu items\"\"\"\n # Select all collapsible lists, regardless of whether they are expanded or not\n collapsible_lists = page.query_selector_all(\n f\"{parent_selector} .snf-collapsible-list > .snf-collapsible-list-header\"\n )\n for list_header in collapsible_lists:\n aria_label = list_header.get_attribute(\"aria-label\")\n aria_expanded = list_header.get_attribute(\"aria-expanded\")\n\n new_path = current_path + [aria_label] if aria_label else current_path\n\n if aria_expanded == \"false\":\n # If the list is not expanded, click to expand it\n list_header.click()\n page.wait_for_timeout(3000)\n # Depending on the page, you might need to wait here for the list to actually expand\n\n # Get the unique identifier for the list to target nested lists within it\n data_id = list_header.get_attribute(\"data-id\")\n nested_parent_selector = f\".snf-collapsible-list-items[data-id='{data_id}-rows']\"\n\n # Recursively handle nested lists, now that the current list has been expanded\n expand_and_gather_paths(page, nested_parent_selector, new_path)\n\n if not collapsible_lists:\n current_path_item = {\n \"path\": current_path.copy(),\n \"selector\": parent_selector,\n }\n base_paths.append(current_path_item)\n\n def expand_menu():\n menu_button = page.locator('div[aria-label=\"All\"]')\n if menu_button.get_attribute(\"aria-expanded\").lower() != \"true\":\n menu_button.click()\n\n def pin_menu():\n pin_menu_button_locator = page.locator('button[aria-label=\"Pin All menu\"]')\n if pin_menu_button_locator.count():\n pin_menu_button_locator.click()\n\n def unpin_menu():\n unpin_menu_button_locator = page.locator('button[aria-label=\"Unpin All menu\"]')\n if unpin_menu_button_locator.count():\n unpin_menu_button_locator.click()\n\n def scroll_to_menu_bottom():\n locator = None\n # Wait for the menu to load and locate an item\n while locator is None:\n locator = page.query_selector(\n f\" .snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='false']\"\n )\n if not locator:\n locator = page.query_selector(\n f\".snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='true']\"\n )\n\n # hover on a menu item and slowly scroll to the bottom to load all the elements\n # scrolling fast will not load all the elements\n locator.hover()\n for i in range(60):\n page.mouse.wheel(0, 1000)\n page.wait_for_timeout(700)\n\n def get_application_names():\n applicaton_locators = page.query_selector_all(\n \".snf-collapsible-list > .snf-collapsible-list-header\"\n )\n application_names = [app.get_attribute(\"aria-label\") for app in applicaton_locators]\n\n return application_names\n\n with sync_playwright() as p:\n browser = p.chromium.launch(headless=False)\n context = browser.new_context()\n page = context.new_page()\n\n # Navigate to the login page\n page.goto(SNOW_INSTANCE_URL)\n\n # Fill in the login form\n page.fill(\"#user_name\", SNOW_INSTANCE_UNAME)\n page.fill(\"#user_password\", SNOW_INSTANCE_PWD)\n page.click(\"#sysverb_login\")\n\n try:\n expand_menu()\n pin_menu()\n scroll_to_menu_bottom()\n # close all paths to get the base paths; this allows us to get the name of applications, as they are at the top level\n # Otherwise, because the selectors are nested, some modules get confused with applications\n close_all_paths(page)\n page.wait_for_timeout(1000)\n application_names = get_application_names()\n expand_and_gather_paths(page)\n\n all_menu_items = []\n urls = dict()\n no_href_count = 0\n new_tabs = []\n\n for path_item in base_paths:\n selector = path_item[\"selector\"]\n # Select all menu items under the current parent selector\n\n # The selectors in base_paths point to the parents of the menu items\n # Now, we need to select the menu items themselves. Doing all this in one\n # step -in the recursive function when reaching leaf nodes- would be more\n # efficient, but it led to heap memory issues. This is a workaround.\n menu_items = page.query_selector_all(f\"{selector} .menu-item-row\")\n for item in menu_items:\n a_tag = item.query_selector(\"a\")\n if a_tag:\n aria_label = a_tag.get_attribute(\"aria-label\")\n application = path_item[\"path\"][0]\n module_path = path_item[\"path\"][1:] + [aria_label]\n\n module = \" > \".join(module_path) # .replace(\" (opens in a new tab)\", \"\")\n # Exclude some modules that modify the state of the application\n if (\n module in [\"My Notification Preferences\"]\n or \"\\u279a\"\n in module # arrow character that appears in 4 modules to indicate redirection and breaks the JSON\n or \"(opens in a new tab)\" in module\n or \"Session Debug\" in module_path\n or \"Session Debug\" in application\n or \"Debugging\" in application\n or \"Debugging\" in module\n # These 3 have a '>' in their name, which breaks the cheat function\n or \"Index Suggestions > In Progress\" in module\n or \"Index Suggestions > Done\" in module\n or \"Index Suggestions > To Review\" in module\n or application not in application_names\n ):\n continue\n try:\n item.click()\n except:\n print(module, \"could not be clicked\")\n continue\n context.pages[-1].wait_for_timeout(1500)\n url = context.pages[-1].evaluate(\"() => window.location.href\")[\n 45:\n ] # get only the end of the url\n if url not in urls:\n menu_task = {\n \"application\": application,\n \"module\": module,\n \"url\": url,\n }\n all_menu_items.append(menu_task)\n urls[url] = True\n\n num_pages = len(context.pages)\n tab_opened = num_pages > 1\n if tab_opened:\n while len(context.pages) > 1:\n context.pages[-1].close()\n with open(\"Menu-Tasks.json\", \"w\") as f:\n all_menu_items = sorted(\n all_menu_items, key=lambda x: (x[\"application\"], x[\"module\"])\n )\n json.dump(all_menu_items, f)\n\n except Exception as e:\n print(\"An error occurred while extracting the menu items\")\n finally:\n unpin_menu()\n browser.close()","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.extract_all_menu_items.close_all_paths","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.extract_all_menu_items.close_all_paths#L24-L47","kind":"function","name":"close_all_paths","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":24,"end_line":47,"context_start_line":4,"context_end_line":67,"code":"from playwright.sync_api import sync_playwright\n\n\n# Load environment variables\nSNOW_INSTANCE_URL = os.getenv(\"SNOW_INSTANCE_URL\")\nSNOW_INSTANCE_UNAME = os.getenv(\"SNOW_INSTANCE_UNAME\")\nSNOW_INSTANCE_PWD = os.getenv(\"SNOW_INSTANCE_PWD\")\n\n# ==================================================================================================================\n# This file is a script that extracts all the menu tasks from the ServiceNow instance. It uses #\n# Playwright to navigate to the ServiceNow instance, log in, and extract all the menu items. It then saves #\n# menu items to a JSON file. The extracted menu items can be used to create tasks for the WorkArena benchmark. #\n# ==================================================================================================================\n\n\nif __name__ == \"__main__\":\n\n base_paths = []\n seen = dict()\n\n def close_all_paths(page, parent_selector=\"body\", current_path=[]):\n \"\"\"Recursively expand all menu items\"\"\"\n # Select all collapsible lists, regardless of whether they are expanded or not\n collapsible_lists = page.query_selector_all(\n f\"{parent_selector} .snf-collapsible-list > .snf-collapsible-list-header\"\n )\n for list_header in collapsible_lists:\n aria_label = list_header.get_attribute(\"aria-label\")\n aria_expanded = list_header.get_attribute(\"aria-expanded\")\n\n new_path = current_path + [aria_label] if aria_label else current_path\n\n if aria_expanded == \"true\":\n # If the list is not expanded, click to expand it\n list_header.click()\n page.wait_for_timeout(500)\n # Depending on the page, you might need to wait here for the list to actually expand\n\n # Get the unique identifier for the list to target nested lists within it\n data_id = list_header.get_attribute(\"data-id\")\n nested_parent_selector = f\".snf-collapsible-list-items[data-id='{data_id}-rows']\"\n\n # Recursively handle nested lists, now that the current list has been expanded\n close_all_paths(page, nested_parent_selector, new_path)\n\n def expand_and_gather_paths(page, parent_selector=\"body\", current_path=[]):\n \"\"\"Recursively expand all menu items\"\"\"\n # Select all collapsible lists, regardless of whether they are expanded or not\n collapsible_lists = page.query_selector_all(\n f\"{parent_selector} .snf-collapsible-list > .snf-collapsible-list-header\"\n )\n for list_header in collapsible_lists:\n aria_label = list_header.get_attribute(\"aria-label\")\n aria_expanded = list_header.get_attribute(\"aria-expanded\")\n\n new_path = current_path + [aria_label] if aria_label else current_path\n\n if aria_expanded == \"false\":\n # If the list is not expanded, click to expand it\n list_header.click()\n page.wait_for_timeout(3000)\n # Depending on the page, you might need to wait here for the list to actually expand\n\n # Get the unique identifier for the list to target nested lists within it","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.extract_all_menu_items.expand_and_gather_paths","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.extract_all_menu_items.expand_and_gather_paths#L49-L79","kind":"function","name":"expand_and_gather_paths","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":49,"end_line":79,"context_start_line":29,"context_end_line":99,"code":" )\n for list_header in collapsible_lists:\n aria_label = list_header.get_attribute(\"aria-label\")\n aria_expanded = list_header.get_attribute(\"aria-expanded\")\n\n new_path = current_path + [aria_label] if aria_label else current_path\n\n if aria_expanded == \"true\":\n # If the list is not expanded, click to expand it\n list_header.click()\n page.wait_for_timeout(500)\n # Depending on the page, you might need to wait here for the list to actually expand\n\n # Get the unique identifier for the list to target nested lists within it\n data_id = list_header.get_attribute(\"data-id\")\n nested_parent_selector = f\".snf-collapsible-list-items[data-id='{data_id}-rows']\"\n\n # Recursively handle nested lists, now that the current list has been expanded\n close_all_paths(page, nested_parent_selector, new_path)\n\n def expand_and_gather_paths(page, parent_selector=\"body\", current_path=[]):\n \"\"\"Recursively expand all menu items\"\"\"\n # Select all collapsible lists, regardless of whether they are expanded or not\n collapsible_lists = page.query_selector_all(\n f\"{parent_selector} .snf-collapsible-list > .snf-collapsible-list-header\"\n )\n for list_header in collapsible_lists:\n aria_label = list_header.get_attribute(\"aria-label\")\n aria_expanded = list_header.get_attribute(\"aria-expanded\")\n\n new_path = current_path + [aria_label] if aria_label else current_path\n\n if aria_expanded == \"false\":\n # If the list is not expanded, click to expand it\n list_header.click()\n page.wait_for_timeout(3000)\n # Depending on the page, you might need to wait here for the list to actually expand\n\n # Get the unique identifier for the list to target nested lists within it\n data_id = list_header.get_attribute(\"data-id\")\n nested_parent_selector = f\".snf-collapsible-list-items[data-id='{data_id}-rows']\"\n\n # Recursively handle nested lists, now that the current list has been expanded\n expand_and_gather_paths(page, nested_parent_selector, new_path)\n\n if not collapsible_lists:\n current_path_item = {\n \"path\": current_path.copy(),\n \"selector\": parent_selector,\n }\n base_paths.append(current_path_item)\n\n def expand_menu():\n menu_button = page.locator('div[aria-label=\"All\"]')\n if menu_button.get_attribute(\"aria-expanded\").lower() != \"true\":\n menu_button.click()\n\n def pin_menu():\n pin_menu_button_locator = page.locator('button[aria-label=\"Pin All menu\"]')\n if pin_menu_button_locator.count():\n pin_menu_button_locator.click()\n\n def unpin_menu():\n unpin_menu_button_locator = page.locator('button[aria-label=\"Unpin All menu\"]')\n if unpin_menu_button_locator.count():\n unpin_menu_button_locator.click()\n\n def scroll_to_menu_bottom():\n locator = None\n # Wait for the menu to load and locate an item\n while locator is None:","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.extract_all_menu_items.expand_menu","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.extract_all_menu_items.expand_menu#L81-L84","kind":"function","name":"expand_menu","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":81,"end_line":84,"context_start_line":61,"context_end_line":104,"code":" if aria_expanded == \"false\":\n # If the list is not expanded, click to expand it\n list_header.click()\n page.wait_for_timeout(3000)\n # Depending on the page, you might need to wait here for the list to actually expand\n\n # Get the unique identifier for the list to target nested lists within it\n data_id = list_header.get_attribute(\"data-id\")\n nested_parent_selector = f\".snf-collapsible-list-items[data-id='{data_id}-rows']\"\n\n # Recursively handle nested lists, now that the current list has been expanded\n expand_and_gather_paths(page, nested_parent_selector, new_path)\n\n if not collapsible_lists:\n current_path_item = {\n \"path\": current_path.copy(),\n \"selector\": parent_selector,\n }\n base_paths.append(current_path_item)\n\n def expand_menu():\n menu_button = page.locator('div[aria-label=\"All\"]')\n if menu_button.get_attribute(\"aria-expanded\").lower() != \"true\":\n menu_button.click()\n\n def pin_menu():\n pin_menu_button_locator = page.locator('button[aria-label=\"Pin All menu\"]')\n if pin_menu_button_locator.count():\n pin_menu_button_locator.click()\n\n def unpin_menu():\n unpin_menu_button_locator = page.locator('button[aria-label=\"Unpin All menu\"]')\n if unpin_menu_button_locator.count():\n unpin_menu_button_locator.click()\n\n def scroll_to_menu_bottom():\n locator = None\n # Wait for the menu to load and locate an item\n while locator is None:\n locator = page.query_selector(\n f\" .snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='false']\"\n )\n if not locator:\n locator = page.query_selector(","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.extract_all_menu_items.pin_menu","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.extract_all_menu_items.pin_menu#L86-L89","kind":"function","name":"pin_menu","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":86,"end_line":89,"context_start_line":66,"context_end_line":109,"code":"\n # Get the unique identifier for the list to target nested lists within it\n data_id = list_header.get_attribute(\"data-id\")\n nested_parent_selector = f\".snf-collapsible-list-items[data-id='{data_id}-rows']\"\n\n # Recursively handle nested lists, now that the current list has been expanded\n expand_and_gather_paths(page, nested_parent_selector, new_path)\n\n if not collapsible_lists:\n current_path_item = {\n \"path\": current_path.copy(),\n \"selector\": parent_selector,\n }\n base_paths.append(current_path_item)\n\n def expand_menu():\n menu_button = page.locator('div[aria-label=\"All\"]')\n if menu_button.get_attribute(\"aria-expanded\").lower() != \"true\":\n menu_button.click()\n\n def pin_menu():\n pin_menu_button_locator = page.locator('button[aria-label=\"Pin All menu\"]')\n if pin_menu_button_locator.count():\n pin_menu_button_locator.click()\n\n def unpin_menu():\n unpin_menu_button_locator = page.locator('button[aria-label=\"Unpin All menu\"]')\n if unpin_menu_button_locator.count():\n unpin_menu_button_locator.click()\n\n def scroll_to_menu_bottom():\n locator = None\n # Wait for the menu to load and locate an item\n while locator is None:\n locator = page.query_selector(\n f\" .snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='false']\"\n )\n if not locator:\n locator = page.query_selector(\n f\".snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='true']\"\n )\n\n # hover on a menu item and slowly scroll to the bottom to load all the elements\n # scrolling fast will not load all the elements","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.extract_all_menu_items.unpin_menu","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.extract_all_menu_items.unpin_menu#L91-L94","kind":"function","name":"unpin_menu","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":91,"end_line":94,"context_start_line":71,"context_end_line":114,"code":" # Recursively handle nested lists, now that the current list has been expanded\n expand_and_gather_paths(page, nested_parent_selector, new_path)\n\n if not collapsible_lists:\n current_path_item = {\n \"path\": current_path.copy(),\n \"selector\": parent_selector,\n }\n base_paths.append(current_path_item)\n\n def expand_menu():\n menu_button = page.locator('div[aria-label=\"All\"]')\n if menu_button.get_attribute(\"aria-expanded\").lower() != \"true\":\n menu_button.click()\n\n def pin_menu():\n pin_menu_button_locator = page.locator('button[aria-label=\"Pin All menu\"]')\n if pin_menu_button_locator.count():\n pin_menu_button_locator.click()\n\n def unpin_menu():\n unpin_menu_button_locator = page.locator('button[aria-label=\"Unpin All menu\"]')\n if unpin_menu_button_locator.count():\n unpin_menu_button_locator.click()\n\n def scroll_to_menu_bottom():\n locator = None\n # Wait for the menu to load and locate an item\n while locator is None:\n locator = page.query_selector(\n f\" .snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='false']\"\n )\n if not locator:\n locator = page.query_selector(\n f\".snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='true']\"\n )\n\n # hover on a menu item and slowly scroll to the bottom to load all the elements\n # scrolling fast will not load all the elements\n locator.hover()\n for i in range(60):\n page.mouse.wheel(0, 1000)\n page.wait_for_timeout(700)\n","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.extract_all_menu_items.scroll_to_menu_bottom","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.extract_all_menu_items.scroll_to_menu_bottom#L96-L113","kind":"function","name":"scroll_to_menu_bottom","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":96,"end_line":113,"context_start_line":76,"context_end_line":133,"code":" \"path\": current_path.copy(),\n \"selector\": parent_selector,\n }\n base_paths.append(current_path_item)\n\n def expand_menu():\n menu_button = page.locator('div[aria-label=\"All\"]')\n if menu_button.get_attribute(\"aria-expanded\").lower() != \"true\":\n menu_button.click()\n\n def pin_menu():\n pin_menu_button_locator = page.locator('button[aria-label=\"Pin All menu\"]')\n if pin_menu_button_locator.count():\n pin_menu_button_locator.click()\n\n def unpin_menu():\n unpin_menu_button_locator = page.locator('button[aria-label=\"Unpin All menu\"]')\n if unpin_menu_button_locator.count():\n unpin_menu_button_locator.click()\n\n def scroll_to_menu_bottom():\n locator = None\n # Wait for the menu to load and locate an item\n while locator is None:\n locator = page.query_selector(\n f\" .snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='false']\"\n )\n if not locator:\n locator = page.query_selector(\n f\".snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='true']\"\n )\n\n # hover on a menu item and slowly scroll to the bottom to load all the elements\n # scrolling fast will not load all the elements\n locator.hover()\n for i in range(60):\n page.mouse.wheel(0, 1000)\n page.wait_for_timeout(700)\n\n def get_application_names():\n applicaton_locators = page.query_selector_all(\n \".snf-collapsible-list > .snf-collapsible-list-header\"\n )\n application_names = [app.get_attribute(\"aria-label\") for app in applicaton_locators]\n\n return application_names\n\n with sync_playwright() as p:\n browser = p.chromium.launch(headless=False)\n context = browser.new_context()\n page = context.new_page()\n\n # Navigate to the login page\n page.goto(SNOW_INSTANCE_URL)\n\n # Fill in the login form\n page.fill(\"#user_name\", SNOW_INSTANCE_UNAME)\n page.fill(\"#user_password\", SNOW_INSTANCE_PWD)","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.extract_all_menu_items.get_application_names","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.extract_all_menu_items.get_application_names#L115-L121","kind":"function","name":"get_application_names","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":115,"end_line":121,"context_start_line":95,"context_end_line":141,"code":"\n def scroll_to_menu_bottom():\n locator = None\n # Wait for the menu to load and locate an item\n while locator is None:\n locator = page.query_selector(\n f\" .snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='false']\"\n )\n if not locator:\n locator = page.query_selector(\n f\".snf-collapsible-list > .snf-collapsible-list-header[aria-expanded='true']\"\n )\n\n # hover on a menu item and slowly scroll to the bottom to load all the elements\n # scrolling fast will not load all the elements\n locator.hover()\n for i in range(60):\n page.mouse.wheel(0, 1000)\n page.wait_for_timeout(700)\n\n def get_application_names():\n applicaton_locators = page.query_selector_all(\n \".snf-collapsible-list > .snf-collapsible-list-header\"\n )\n application_names = [app.get_attribute(\"aria-label\") for app in applicaton_locators]\n\n return application_names\n\n with sync_playwright() as p:\n browser = p.chromium.launch(headless=False)\n context = browser.new_context()\n page = context.new_page()\n\n # Navigate to the login page\n page.goto(SNOW_INSTANCE_URL)\n\n # Fill in the login form\n page.fill(\"#user_name\", SNOW_INSTANCE_UNAME)\n page.fill(\"#user_password\", SNOW_INSTANCE_PWD)\n page.click(\"#sysverb_login\")\n\n try:\n expand_menu()\n pin_menu()\n scroll_to_menu_bottom()\n # close all paths to get the base paths; this allows us to get the name of applications, as they are at the top level\n # Otherwise, because the selectors are nested, some modules get confused with applications","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.list","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.scripts.list#L1-L117","kind":"module","name":"src.browsergym.workarena.tasks.scripts.list","path":"src/browsergym/workarena/tasks/scripts/list.py","language":"python","start_line":1,"end_line":117,"context_start_line":1,"context_end_line":117,"code":"import json\nimport multiprocessing\nimport random\nimport re\n\nfrom browsergym.workarena.tasks.list import __TASKS__\nfrom playwright.sync_api import sync_playwright\nfrom tqdm import tqdm\n\n# Split between filter and sort tasks\nFILTER_TASKS = [\n task for task in __TASKS__ if re.compile(r\"^Filter\\w+ListTask$\").match(task.__name__)\n]\nSORT_TASKS = [task for task in __TASKS__ if re.compile(r\"^Sort\\w+ListTask$\").match(task.__name__)]\n\n\ndef generate_sort_task_configs(task_class, num_configs_per_field_count=50):\n name = task_class.__name__\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n all_configs = []\n for n_fields_to_sort in range(1, 4):\n with sync_playwright() as p:\n task = task_class()\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n all_new_configs = task._generate_all_configs(\n seed=None, page=page, n_fields_to_sort=n_fields_to_sort\n )\n new_configs = random.sample(all_new_configs, num_configs_per_field_count)\n all_configs.extend(new_configs)\n\n print(f\"{task_name} {n_fields_to_sort} fields - {len(new_configs)} configs\")\n\n with open(\n f\"{task_name}.json\",\n \"w\",\n ) as f:\n all_configs = sorted(all_configs, key=lambda x: sorted(list(x[\"sort_fields\"])))\n json.dump(all_configs, f, indent=4, sort_keys=True)\n\n\ndef generate_task_configs(task_class, num_configs=1000, task_type=\"sort\"):\n def try_setup_and_cheat(task_class, seed, current_task_configs):\n \"\"\"Try to setup and cheat a task, and return its configuration if it's new\"\"\"\n try:\n with sync_playwright() as p:\n task = task_class(seed=seed)\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n goal, _ = task._generate_random_config(page=page)\n chat_messages = []\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task_successful = done is True and reward == 1.0\n except Exception as e: # Catch the exception\n print(f\"Error cheating on task {task_name} with seed {seed}: {str(e)}\")\n task_successful = False\n if task_type == \"sort\":\n config = {\n \"sort_fields\": task.sort_fields,\n \"sort_dirs\": task.sort_dirs,\n \"goal\": goal,\n }\n elif task_type == \"filter\":\n list_info = {k: v for k, v in task.list_info.items() if k in [\"columns\"]}\n config = {\n \"list_info\": list_info,\n \"filter_columns\": task.filter_columns,\n \"filter_values\": task.filter_values,\n \"filter_kind\": task.filter_kind,\n }\n task.teardown()\n browser.close()\n if task_successful and config not in current_task_configs:\n return config\n except Exception as e:\n print(f\"Error setting up task {task_name} with seed {seed}: {str(e)}\")\n return None\n\n name = task_class.__name__\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n\n current_task_configs = []\n seed = 1000\n with tqdm(total=num_configs, desc=f\"Generating {task_name} configs\", ncols=150) as pbar:\n while len(current_task_configs) < num_configs:\n seed += 1\n config = try_setup_and_cheat(task_class, seed, current_task_configs)\n if config:\n current_task_configs.append(config)\n pbar.update(1)\n print(f\"Success for {task_name} config\")\n with open(\n f\"{task_name}.json\",\n \"w\",\n ) as f:\n if task_type == \"sort\":\n current_task_configs = sorted(\n current_task_configs, key=lambda x: sorted(list(x[\"sort_fields\"]))\n )\n else:\n current_task_configs = sorted(\n current_task_configs, key=lambda x: sorted(list(x[\"filter_columns\"]))\n )\n json.dump(current_task_configs, f, indent=4, sort_keys=True)\n\n\nif __name__ == \"__main__\":\n for task in SORT_TASKS:\n generate_sort_task_configs(task)","source_hash":"0b2f69bd41ea291c121f9c964fbe3a656f53306642f6aac1cef3ca6431966133","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.list.generate_sort_task_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.list.generate_sort_task_configs#L17-L42","kind":"function","name":"generate_sort_task_configs","path":"src/browsergym/workarena/tasks/scripts/list.py","language":"python","start_line":17,"end_line":42,"context_start_line":1,"context_end_line":62,"code":"import json\nimport multiprocessing\nimport random\nimport re\n\nfrom browsergym.workarena.tasks.list import __TASKS__\nfrom playwright.sync_api import sync_playwright\nfrom tqdm import tqdm\n\n# Split between filter and sort tasks\nFILTER_TASKS = [\n task for task in __TASKS__ if re.compile(r\"^Filter\\w+ListTask$\").match(task.__name__)\n]\nSORT_TASKS = [task for task in __TASKS__ if re.compile(r\"^Sort\\w+ListTask$\").match(task.__name__)]\n\n\ndef generate_sort_task_configs(task_class, num_configs_per_field_count=50):\n name = task_class.__name__\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n all_configs = []\n for n_fields_to_sort in range(1, 4):\n with sync_playwright() as p:\n task = task_class()\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n all_new_configs = task._generate_all_configs(\n seed=None, page=page, n_fields_to_sort=n_fields_to_sort\n )\n new_configs = random.sample(all_new_configs, num_configs_per_field_count)\n all_configs.extend(new_configs)\n\n print(f\"{task_name} {n_fields_to_sort} fields - {len(new_configs)} configs\")\n\n with open(\n f\"{task_name}.json\",\n \"w\",\n ) as f:\n all_configs = sorted(all_configs, key=lambda x: sorted(list(x[\"sort_fields\"])))\n json.dump(all_configs, f, indent=4, sort_keys=True)\n\n\ndef generate_task_configs(task_class, num_configs=1000, task_type=\"sort\"):\n def try_setup_and_cheat(task_class, seed, current_task_configs):\n \"\"\"Try to setup and cheat a task, and return its configuration if it's new\"\"\"\n try:\n with sync_playwright() as p:\n task = task_class(seed=seed)\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n goal, _ = task._generate_random_config(page=page)\n chat_messages = []\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task_successful = done is True and reward == 1.0\n except Exception as e: # Catch the exception\n print(f\"Error cheating on task {task_name} with seed {seed}: {str(e)}\")","source_hash":"0b2f69bd41ea291c121f9c964fbe3a656f53306642f6aac1cef3ca6431966133","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.list.generate_task_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.list.generate_task_configs#L45-L112","kind":"function","name":"generate_task_configs","path":"src/browsergym/workarena/tasks/scripts/list.py","language":"python","start_line":45,"end_line":112,"context_start_line":25,"context_end_line":117,"code":" browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n all_new_configs = task._generate_all_configs(\n seed=None, page=page, n_fields_to_sort=n_fields_to_sort\n )\n new_configs = random.sample(all_new_configs, num_configs_per_field_count)\n all_configs.extend(new_configs)\n\n print(f\"{task_name} {n_fields_to_sort} fields - {len(new_configs)} configs\")\n\n with open(\n f\"{task_name}.json\",\n \"w\",\n ) as f:\n all_configs = sorted(all_configs, key=lambda x: sorted(list(x[\"sort_fields\"])))\n json.dump(all_configs, f, indent=4, sort_keys=True)\n\n\ndef generate_task_configs(task_class, num_configs=1000, task_type=\"sort\"):\n def try_setup_and_cheat(task_class, seed, current_task_configs):\n \"\"\"Try to setup and cheat a task, and return its configuration if it's new\"\"\"\n try:\n with sync_playwright() as p:\n task = task_class(seed=seed)\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n goal, _ = task._generate_random_config(page=page)\n chat_messages = []\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task_successful = done is True and reward == 1.0\n except Exception as e: # Catch the exception\n print(f\"Error cheating on task {task_name} with seed {seed}: {str(e)}\")\n task_successful = False\n if task_type == \"sort\":\n config = {\n \"sort_fields\": task.sort_fields,\n \"sort_dirs\": task.sort_dirs,\n \"goal\": goal,\n }\n elif task_type == \"filter\":\n list_info = {k: v for k, v in task.list_info.items() if k in [\"columns\"]}\n config = {\n \"list_info\": list_info,\n \"filter_columns\": task.filter_columns,\n \"filter_values\": task.filter_values,\n \"filter_kind\": task.filter_kind,\n }\n task.teardown()\n browser.close()\n if task_successful and config not in current_task_configs:\n return config\n except Exception as e:\n print(f\"Error setting up task {task_name} with seed {seed}: {str(e)}\")\n return None\n\n name = task_class.__name__\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n\n current_task_configs = []\n seed = 1000\n with tqdm(total=num_configs, desc=f\"Generating {task_name} configs\", ncols=150) as pbar:\n while len(current_task_configs) < num_configs:\n seed += 1\n config = try_setup_and_cheat(task_class, seed, current_task_configs)\n if config:\n current_task_configs.append(config)\n pbar.update(1)\n print(f\"Success for {task_name} config\")\n with open(\n f\"{task_name}.json\",\n \"w\",\n ) as f:\n if task_type == \"sort\":\n current_task_configs = sorted(\n current_task_configs, key=lambda x: sorted(list(x[\"sort_fields\"]))\n )\n else:\n current_task_configs = sorted(\n current_task_configs, key=lambda x: sorted(list(x[\"filter_columns\"]))\n )\n json.dump(current_task_configs, f, indent=4, sort_keys=True)\n\n\nif __name__ == \"__main__\":\n for task in SORT_TASKS:\n generate_sort_task_configs(task)","source_hash":"0b2f69bd41ea291c121f9c964fbe3a656f53306642f6aac1cef3ca6431966133","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.list.try_setup_and_cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.list.try_setup_and_cheat#L46-L84","kind":"function","name":"try_setup_and_cheat","path":"src/browsergym/workarena/tasks/scripts/list.py","language":"python","start_line":46,"end_line":84,"context_start_line":26,"context_end_line":104,"code":" context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n all_new_configs = task._generate_all_configs(\n seed=None, page=page, n_fields_to_sort=n_fields_to_sort\n )\n new_configs = random.sample(all_new_configs, num_configs_per_field_count)\n all_configs.extend(new_configs)\n\n print(f\"{task_name} {n_fields_to_sort} fields - {len(new_configs)} configs\")\n\n with open(\n f\"{task_name}.json\",\n \"w\",\n ) as f:\n all_configs = sorted(all_configs, key=lambda x: sorted(list(x[\"sort_fields\"])))\n json.dump(all_configs, f, indent=4, sort_keys=True)\n\n\ndef generate_task_configs(task_class, num_configs=1000, task_type=\"sort\"):\n def try_setup_and_cheat(task_class, seed, current_task_configs):\n \"\"\"Try to setup and cheat a task, and return its configuration if it's new\"\"\"\n try:\n with sync_playwright() as p:\n task = task_class(seed=seed)\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n goal, _ = task._generate_random_config(page=page)\n chat_messages = []\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task_successful = done is True and reward == 1.0\n except Exception as e: # Catch the exception\n print(f\"Error cheating on task {task_name} with seed {seed}: {str(e)}\")\n task_successful = False\n if task_type == \"sort\":\n config = {\n \"sort_fields\": task.sort_fields,\n \"sort_dirs\": task.sort_dirs,\n \"goal\": goal,\n }\n elif task_type == \"filter\":\n list_info = {k: v for k, v in task.list_info.items() if k in [\"columns\"]}\n config = {\n \"list_info\": list_info,\n \"filter_columns\": task.filter_columns,\n \"filter_values\": task.filter_values,\n \"filter_kind\": task.filter_kind,\n }\n task.teardown()\n browser.close()\n if task_successful and config not in current_task_configs:\n return config\n except Exception as e:\n print(f\"Error setting up task {task_name} with seed {seed}: {str(e)}\")\n return None\n\n name = task_class.__name__\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n\n current_task_configs = []\n seed = 1000\n with tqdm(total=num_configs, desc=f\"Generating {task_name} configs\", ncols=150) as pbar:\n while len(current_task_configs) < num_configs:\n seed += 1\n config = try_setup_and_cheat(task_class, seed, current_task_configs)\n if config:\n current_task_configs.append(config)\n pbar.update(1)\n print(f\"Success for {task_name} config\")\n with open(\n f\"{task_name}.json\",\n \"w\",\n ) as f:\n if task_type == \"sort\":","source_hash":"0b2f69bd41ea291c121f9c964fbe3a656f53306642f6aac1cef3ca6431966133","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.navigation","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.scripts.navigation#L1-L30","kind":"module","name":"src.browsergym.workarena.tasks.scripts.navigation","path":"src/browsergym/workarena/tasks/scripts/navigation.py","language":"python","start_line":1,"end_line":30,"context_start_line":1,"context_end_line":30,"code":"import json\n\nfrom browsergym.workarena.api.utils import table_api_call, SNowInstance\n\nNUM_CONFIGS = 650 # number of impersonation tasks in the paper\n\n\ndef get_all_impersonation_users():\n instance = SNowInstance()\n candidate_users = [\n u[\"first_name\"] + \" \" + u[\"last_name\"]\n for u in table_api_call(\n instance=instance,\n table=\"sys_user\",\n params={\"sysparm_query\": \"user_name!=admin\"},\n )[\"result\"]\n if u[\"first_name\"].strip() and u[\"last_name\"].strip()\n ]\n\n return candidate_users\n\n\nif __name__ == \"__main__\":\n all_users = get_all_impersonation_users()\n with open(\n \"browsergym/workarena/src/browsergym/workarena/data_files/task_configs/impersonation_users.json\",\n \"w\",\n ) as f:\n all_users = sorted(list(all_users))\n json.dump(all_users, f)","source_hash":"d862081a85ba01dd98a705fdf7f313b8ba228d293e120b237d136245a61a8ad1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.navigation.get_all_impersonation_users","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.navigation.get_all_impersonation_users#L8-L20","kind":"function","name":"get_all_impersonation_users","path":"src/browsergym/workarena/tasks/scripts/navigation.py","language":"python","start_line":8,"end_line":20,"context_start_line":1,"context_end_line":30,"code":"import json\n\nfrom browsergym.workarena.api.utils import table_api_call, SNowInstance\n\nNUM_CONFIGS = 650 # number of impersonation tasks in the paper\n\n\ndef get_all_impersonation_users():\n instance = SNowInstance()\n candidate_users = [\n u[\"first_name\"] + \" \" + u[\"last_name\"]\n for u in table_api_call(\n instance=instance,\n table=\"sys_user\",\n params={\"sysparm_query\": \"user_name!=admin\"},\n )[\"result\"]\n if u[\"first_name\"].strip() and u[\"last_name\"].strip()\n ]\n\n return candidate_users\n\n\nif __name__ == \"__main__\":\n all_users = get_all_impersonation_users()\n with open(\n \"browsergym/workarena/src/browsergym/workarena/data_files/task_configs/impersonation_users.json\",\n \"w\",\n ) as f:\n all_users = sorted(list(all_users))\n json.dump(all_users, f)","source_hash":"d862081a85ba01dd98a705fdf7f313b8ba228d293e120b237d136245a61a8ad1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.knowledge","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.scripts.knowledge#L1-L37","kind":"module","name":"src.browsergym.workarena.tasks.scripts.knowledge","path":"src/browsergym/workarena/tasks/scripts/knowledge.py","language":"python","start_line":1,"end_line":37,"context_start_line":1,"context_end_line":37,"code":"import json\nimport random\n\nfrom browsergym.workarena.api.utils import SNowInstance\nfrom browsergym.workarena.config import KB_FILEPATH, KB_CONFIG_PATH\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt\nfrom tqdm import tqdm\n\n\ndef generate_all_kb_configs(instance=None, num_configs=1000) -> list[dict]:\n \"\"\"Generate all possible KB configs\"\"\"\n instance = instance if instance is not None else SNowInstance()\n with open(KB_FILEPATH, \"r\") as f:\n kb_entries = json.load(f)\n all_configs = []\n for kb_entry in kb_entries:\n for question in kb_entry[\"questions\"]:\n config = {\n \"item\": kb_entry[\"item\"],\n \"value\": kb_entry[\"value\"],\n \"alternative_answers\": kb_entry[\"alternative_answers\"],\n \"question\": question,\n }\n all_configs.append(config)\n # sample the configs\n if len(all_configs) > num_configs:\n all_configs = random.sample(all_configs, num_configs)\n all_configs = sorted(all_configs, key=lambda x: x[\"item\"] + x[\"question\"])\n\n return all_configs\n\n\nif __name__ == \"__main__\":\n\n validate_kb_configs()","source_hash":"42bbf7018f62eaf8d7862b431484c68cd8ccbce2fa1fb14b282251f2103a41da","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.knowledge.generate_all_kb_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.knowledge.generate_all_kb_configs#L12-L32","kind":"function","name":"generate_all_kb_configs","path":"src/browsergym/workarena/tasks/scripts/knowledge.py","language":"python","start_line":12,"end_line":32,"context_start_line":1,"context_end_line":37,"code":"import json\nimport random\n\nfrom browsergym.workarena.api.utils import SNowInstance\nfrom browsergym.workarena.config import KB_FILEPATH, KB_CONFIG_PATH\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt\nfrom tqdm import tqdm\n\n\ndef generate_all_kb_configs(instance=None, num_configs=1000) -> list[dict]:\n \"\"\"Generate all possible KB configs\"\"\"\n instance = instance if instance is not None else SNowInstance()\n with open(KB_FILEPATH, \"r\") as f:\n kb_entries = json.load(f)\n all_configs = []\n for kb_entry in kb_entries:\n for question in kb_entry[\"questions\"]:\n config = {\n \"item\": kb_entry[\"item\"],\n \"value\": kb_entry[\"value\"],\n \"alternative_answers\": kb_entry[\"alternative_answers\"],\n \"question\": question,\n }\n all_configs.append(config)\n # sample the configs\n if len(all_configs) > num_configs:\n all_configs = random.sample(all_configs, num_configs)\n all_configs = sorted(all_configs, key=lambda x: x[\"item\"] + x[\"question\"])\n\n return all_configs\n\n\nif __name__ == \"__main__\":\n\n validate_kb_configs()","source_hash":"42bbf7018f62eaf8d7862b431484c68cd8ccbce2fa1fb14b282251f2103a41da","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.generate_forms","uri":"program://WorkArena/module/src.browsergym.workarena.tasks.scripts.generate_forms#L1-L87","kind":"module","name":"src.browsergym.workarena.tasks.scripts.generate_forms","path":"src/browsergym/workarena/tasks/scripts/generate_forms.py","language":"python","start_line":1,"end_line":87,"context_start_line":1,"context_end_line":87,"code":"import json\nimport logging\nimport multiprocessing\nimport re\n\nfrom browsergym.workarena.tasks.form import __TASKS__\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom tqdm import tqdm\n\n\ndef camel_to_snake(name):\n \"\"\"Convert camel case to snake case.\"\"\"\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n return re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n\n\ndef generate_form_task_configs(task_name, task_class, num_configs=1):\n \"\"\"Generate forms by using random setup and validating the feasibility of the task; also ensure that the task is new.\"\"\"\n\n @retry(\n stop=stop_after_attempt(2),\n retry=retry_if_exception_type(TimeoutError),\n reraise=False,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n )\n def try_setup_and_cheat(task_class, seed, current_task_configs):\n \"\"\"Try to setup and cheat a task, and return its configuration if it's new\"\"\"\n try:\n with sync_playwright() as p:\n task = task_class(seed=seed)\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n task._generate_random_config(page=page)\n config = {\n \"template_record\": task.template_record,\n \"fields\": {\n f: task.fields[f][\"label\"] for f in task.fields\n }, # the validate function only needs the field names\n \"task_fields\": task.task_fields,\n }\n # If the task was never seen before, store it\n chat_messages = []\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task_successful = done is True and reward == 1.0\n\n except Exception as e: # Catch the exception\n print(f\"Error cheating on task {task_name} with seed {seed}: {str(e)}\")\n task_successful = False\n\n task.teardown()\n browser.close()\n if config not in current_task_configs and task_successful:\n return config\n except Exception as e:\n print(f\"Error setting up task {task_name} with seed {seed}: {str(e)}\")\n return None\n\n current_task_configs = []\n seed = 30\n with tqdm(total=num_configs, desc=f\"Generating {task_name} configs\", ncols=70) as pbar:\n while len(current_task_configs) < num_configs:\n seed += 1\n config = try_setup_and_cheat(task_class, seed, current_task_configs)\n if config:\n current_task_configs.append(config)\n pbar.update(1)\n\n path = f\"{camel_to_snake(task_name)}.json\"\n with open(path, \"w\") as f:\n current_task_configs = sorted(current_task_configs, key=lambda x: list(x[\"fields\"].keys()))\n json.dump(current_task_configs, f, indent=4, sort_keys=True)\n\n\nif __name__ == \"__main__\":\n form_tasks = {task.__name__: task for task in __TASKS__}\n # iterate over all form tasks and generate their configurations\n # all form tasks should be saved in separate json files\n with multiprocessing.Pool() as pool:\n pool.starmap(generate_form_task_configs, form_tasks.items())\n # single process for debugging\n # for task_name, task_class in form_tasks.items():\n # generate_form_task_configs(task_name, task_class)","source_hash":"c27a971356f9790770401d19aaca904b9cfd54d2b239b527628615becab8b0cd","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.generate_forms.camel_to_snake","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.generate_forms.camel_to_snake#L12-L15","kind":"function","name":"camel_to_snake","path":"src/browsergym/workarena/tasks/scripts/generate_forms.py","language":"python","start_line":12,"end_line":15,"context_start_line":1,"context_end_line":35,"code":"import json\nimport logging\nimport multiprocessing\nimport re\n\nfrom browsergym.workarena.tasks.form import __TASKS__\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom tqdm import tqdm\n\n\ndef camel_to_snake(name):\n \"\"\"Convert camel case to snake case.\"\"\"\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n return re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n\n\ndef generate_form_task_configs(task_name, task_class, num_configs=1):\n \"\"\"Generate forms by using random setup and validating the feasibility of the task; also ensure that the task is new.\"\"\"\n\n @retry(\n stop=stop_after_attempt(2),\n retry=retry_if_exception_type(TimeoutError),\n reraise=False,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n )\n def try_setup_and_cheat(task_class, seed, current_task_configs):\n \"\"\"Try to setup and cheat a task, and return its configuration if it's new\"\"\"\n try:\n with sync_playwright() as p:\n task = task_class(seed=seed)\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()","source_hash":"c27a971356f9790770401d19aaca904b9cfd54d2b239b527628615becab8b0cd","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.generate_forms.generate_form_task_configs","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.generate_forms.generate_form_task_configs#L18-L76","kind":"function","name":"generate_form_task_configs","path":"src/browsergym/workarena/tasks/scripts/generate_forms.py","language":"python","start_line":18,"end_line":76,"context_start_line":1,"context_end_line":87,"code":"import json\nimport logging\nimport multiprocessing\nimport re\n\nfrom browsergym.workarena.tasks.form import __TASKS__\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom tqdm import tqdm\n\n\ndef camel_to_snake(name):\n \"\"\"Convert camel case to snake case.\"\"\"\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n return re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n\n\ndef generate_form_task_configs(task_name, task_class, num_configs=1):\n \"\"\"Generate forms by using random setup and validating the feasibility of the task; also ensure that the task is new.\"\"\"\n\n @retry(\n stop=stop_after_attempt(2),\n retry=retry_if_exception_type(TimeoutError),\n reraise=False,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n )\n def try_setup_and_cheat(task_class, seed, current_task_configs):\n \"\"\"Try to setup and cheat a task, and return its configuration if it's new\"\"\"\n try:\n with sync_playwright() as p:\n task = task_class(seed=seed)\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n task._generate_random_config(page=page)\n config = {\n \"template_record\": task.template_record,\n \"fields\": {\n f: task.fields[f][\"label\"] for f in task.fields\n }, # the validate function only needs the field names\n \"task_fields\": task.task_fields,\n }\n # If the task was never seen before, store it\n chat_messages = []\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task_successful = done is True and reward == 1.0\n\n except Exception as e: # Catch the exception\n print(f\"Error cheating on task {task_name} with seed {seed}: {str(e)}\")\n task_successful = False\n\n task.teardown()\n browser.close()\n if config not in current_task_configs and task_successful:\n return config\n except Exception as e:\n print(f\"Error setting up task {task_name} with seed {seed}: {str(e)}\")\n return None\n\n current_task_configs = []\n seed = 30\n with tqdm(total=num_configs, desc=f\"Generating {task_name} configs\", ncols=70) as pbar:\n while len(current_task_configs) < num_configs:\n seed += 1\n config = try_setup_and_cheat(task_class, seed, current_task_configs)\n if config:\n current_task_configs.append(config)\n pbar.update(1)\n\n path = f\"{camel_to_snake(task_name)}.json\"\n with open(path, \"w\") as f:\n current_task_configs = sorted(current_task_configs, key=lambda x: list(x[\"fields\"].keys()))\n json.dump(current_task_configs, f, indent=4, sort_keys=True)\n\n\nif __name__ == \"__main__\":\n form_tasks = {task.__name__: task for task in __TASKS__}\n # iterate over all form tasks and generate their configurations\n # all form tasks should be saved in separate json files\n with multiprocessing.Pool() as pool:\n pool.starmap(generate_form_task_configs, form_tasks.items())\n # single process for debugging\n # for task_name, task_class in form_tasks.items():\n # generate_form_task_configs(task_name, task_class)","source_hash":"c27a971356f9790770401d19aaca904b9cfd54d2b239b527628615becab8b0cd","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.tasks.scripts.generate_forms.try_setup_and_cheat","uri":"program://WorkArena/function/src.browsergym.workarena.tasks.scripts.generate_forms.try_setup_and_cheat#L27-L61","kind":"function","name":"try_setup_and_cheat","path":"src/browsergym/workarena/tasks/scripts/generate_forms.py","language":"python","start_line":27,"end_line":61,"context_start_line":7,"context_end_line":81,"code":"from playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom tqdm import tqdm\n\n\ndef camel_to_snake(name):\n \"\"\"Convert camel case to snake case.\"\"\"\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n return re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n\n\ndef generate_form_task_configs(task_name, task_class, num_configs=1):\n \"\"\"Generate forms by using random setup and validating the feasibility of the task; also ensure that the task is new.\"\"\"\n\n @retry(\n stop=stop_after_attempt(2),\n retry=retry_if_exception_type(TimeoutError),\n reraise=False,\n before_sleep=lambda _: logging.info(\"Retrying due to a TimeoutError...\"),\n )\n def try_setup_and_cheat(task_class, seed, current_task_configs):\n \"\"\"Try to setup and cheat a task, and return its configuration if it's new\"\"\"\n try:\n with sync_playwright() as p:\n task = task_class(seed=seed)\n browser = p.chromium.launch()\n context = browser.new_context() # Set the timeout here\n context.set_default_timeout(5000)\n page = context.new_page()\n task._generate_random_config(page=page)\n config = {\n \"template_record\": task.template_record,\n \"fields\": {\n f: task.fields[f][\"label\"] for f in task.fields\n }, # the validate function only needs the field names\n \"task_fields\": task.task_fields,\n }\n # If the task was never seen before, store it\n chat_messages = []\n try:\n task.cheat(page=page, chat_messages=chat_messages)\n reward, done, message, info = task.validate(page, chat_messages)\n task_successful = done is True and reward == 1.0\n\n except Exception as e: # Catch the exception\n print(f\"Error cheating on task {task_name} with seed {seed}: {str(e)}\")\n task_successful = False\n\n task.teardown()\n browser.close()\n if config not in current_task_configs and task_successful:\n return config\n except Exception as e:\n print(f\"Error setting up task {task_name} with seed {seed}: {str(e)}\")\n return None\n\n current_task_configs = []\n seed = 30\n with tqdm(total=num_configs, desc=f\"Generating {task_name} configs\", ncols=70) as pbar:\n while len(current_task_configs) < num_configs:\n seed += 1\n config = try_setup_and_cheat(task_class, seed, current_task_configs)\n if config:\n current_task_configs.append(config)\n pbar.update(1)\n\n path = f\"{camel_to_snake(task_name)}.json\"\n with open(path, \"w\") as f:\n current_task_configs = sorted(current_task_configs, key=lambda x: list(x[\"fields\"].keys()))\n json.dump(current_task_configs, f, indent=4, sort_keys=True)\n\n\nif __name__ == \"__main__\":\n form_tasks = {task.__name__: task for task in __TASKS__}\n # iterate over all form tasks and generate their configurations","source_hash":"c27a971356f9790770401d19aaca904b9cfd54d2b239b527628615becab8b0cd","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.computer_asset","uri":"program://WorkArena/module/src.browsergym.workarena.api.computer_asset#L1-L90","kind":"module","name":"src.browsergym.workarena.api.computer_asset","path":"src/browsergym/workarena/api/computer_asset.py","language":"python","start_line":1,"end_line":90,"context_start_line":1,"context_end_line":90,"code":"import json\nimport numpy as np\nimport time\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_computer_asset(\n instance: SNowInstance,\n asset_tag: str,\n warranty_expiration_date: str = None,\n user_sys_id: str = None,\n computer_model_info: dict = None,\n random: np.random = None,\n):\n \"\"\"Create a hardware asset -computer model- and assign it to a user\n Args:\n --------\n instance (SNowInstance):\n The instance to create the hardware asset in\n asset_tag (str):\n The asset tag of the hardware asset\n warranty_expiration_date (str):\n The warranty expiration date of the hardware asset. If None, a random date is chosen\n user_sys_id (str):\n The sys_id of the user to assign the hardware asset to. If None, the hardware asset is not assigned to any user\n computer_model_info (dict):\n Contains the sys_id and short_description of the computer model to create the hardware asset with.\n If None, a random computer model is chosen\n random (np.random):\n The random number generator\n Returns:\n --------\n sys_id (str):\n The sys_id of the created hardware asset\n computer_model (dict):\n The computer model information\n warranty_expiration_date (str):\n The warranty expiration date of the hardware asset\n \"\"\"\n\n if computer_model_info is None:\n # Get the sys_id of the 'Computer' category\n computer_model_sys_id = table_api_call(\n instance=instance,\n table=\"cmdb_model_category\",\n # The cmdb_model_category is the sys_id for the hardware category; computer in this case\n params={\n \"sysparm_query\": f\"name=Computer\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"][0][\"sys_id\"]\n # Randomly choose a computer model if needed\n computer_models = table_api_call(\n instance=instance,\n table=\"cmdb_model\",\n # The cmdb_model_category is the sys_id for the hardware category;\n params={\n \"sysparm_query\": f\"cmdb_model_category={computer_model_sys_id}\",\n \"sysparm_fields\": \"sys_id,short_description\",\n },\n )[\"result\"]\n computer_model = random.choice(computer_models)\n if warranty_expiration_date is None:\n # Warranty expiration date is randomly selected between 1 year ago and 1 year from now\n warranty_expiration_date = str(fake.date_between(start_date=\"-1y\", end_date=\"+1y\"))\n\n # Create hardware asset\n hardware_result = table_api_call(\n instance=instance,\n table=\"alm_hardware\",\n data=json.dumps(\n {\n \"assigned_to\": user_sys_id,\n \"asset_tag\": asset_tag,\n \"display_name\": asset_tag + \" - \" + computer_model[\"short_description\"],\n \"model\": computer_model[\"sys_id\"],\n \"model_category\": computer_model_sys_id,\n \"warranty_expiration\": warranty_expiration_date,\n }\n ),\n method=\"POST\",\n )[\"result\"]\n\n return hardware_result[\"sys_id\"], computer_model, warranty_expiration_date","source_hash":"ffe646fd6da6f4b6daa0f1ead6141a6f60c4726abf9df804c9458c9f145cbc43","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.computer_asset.create_computer_asset","uri":"program://WorkArena/function/src.browsergym.workarena.api.computer_asset.create_computer_asset#L13-L90","kind":"function","name":"create_computer_asset","path":"src/browsergym/workarena/api/computer_asset.py","language":"python","start_line":13,"end_line":90,"context_start_line":1,"context_end_line":90,"code":"import json\nimport numpy as np\nimport time\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_computer_asset(\n instance: SNowInstance,\n asset_tag: str,\n warranty_expiration_date: str = None,\n user_sys_id: str = None,\n computer_model_info: dict = None,\n random: np.random = None,\n):\n \"\"\"Create a hardware asset -computer model- and assign it to a user\n Args:\n --------\n instance (SNowInstance):\n The instance to create the hardware asset in\n asset_tag (str):\n The asset tag of the hardware asset\n warranty_expiration_date (str):\n The warranty expiration date of the hardware asset. If None, a random date is chosen\n user_sys_id (str):\n The sys_id of the user to assign the hardware asset to. If None, the hardware asset is not assigned to any user\n computer_model_info (dict):\n Contains the sys_id and short_description of the computer model to create the hardware asset with.\n If None, a random computer model is chosen\n random (np.random):\n The random number generator\n Returns:\n --------\n sys_id (str):\n The sys_id of the created hardware asset\n computer_model (dict):\n The computer model information\n warranty_expiration_date (str):\n The warranty expiration date of the hardware asset\n \"\"\"\n\n if computer_model_info is None:\n # Get the sys_id of the 'Computer' category\n computer_model_sys_id = table_api_call(\n instance=instance,\n table=\"cmdb_model_category\",\n # The cmdb_model_category is the sys_id for the hardware category; computer in this case\n params={\n \"sysparm_query\": f\"name=Computer\",\n \"sysparm_fields\": \"sys_id\",\n },\n )[\"result\"][0][\"sys_id\"]\n # Randomly choose a computer model if needed\n computer_models = table_api_call(\n instance=instance,\n table=\"cmdb_model\",\n # The cmdb_model_category is the sys_id for the hardware category;\n params={\n \"sysparm_query\": f\"cmdb_model_category={computer_model_sys_id}\",\n \"sysparm_fields\": \"sys_id,short_description\",\n },\n )[\"result\"]\n computer_model = random.choice(computer_models)\n if warranty_expiration_date is None:\n # Warranty expiration date is randomly selected between 1 year ago and 1 year from now\n warranty_expiration_date = str(fake.date_between(start_date=\"-1y\", end_date=\"+1y\"))\n\n # Create hardware asset\n hardware_result = table_api_call(\n instance=instance,\n table=\"alm_hardware\",\n data=json.dumps(\n {\n \"assigned_to\": user_sys_id,\n \"asset_tag\": asset_tag,\n \"display_name\": asset_tag + \" - \" + computer_model[\"short_description\"],\n \"model\": computer_model[\"sys_id\"],\n \"model_category\": computer_model_sys_id,\n \"warranty_expiration\": warranty_expiration_date,\n }\n ),\n method=\"POST\",\n )[\"result\"]\n\n return hardware_result[\"sys_id\"], computer_model, warranty_expiration_date","source_hash":"ffe646fd6da6f4b6daa0f1ead6141a6f60c4726abf9df804c9458c9f145cbc43","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.requested_items","uri":"program://WorkArena/module/src.browsergym.workarena.api.requested_items#L1-L63","kind":"module","name":"src.browsergym.workarena.api.requested_items","path":"src/browsergym/workarena/api/requested_items.py","language":"python","start_line":1,"end_line":63,"context_start_line":1,"context_end_line":63,"code":"import faker\n\nfake = faker.Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_requested_item(\n instance: SNowInstance,\n user_sys_id: str,\n system_name: str,\n quantity: int = 1,\n short_description: str = None,\n) -> list[str]:\n \"\"\"\n Create a requested item for a given user\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the requested item in\n user_sys_id: str\n The sys_id of the user to request the item for\n system_name: str\n The name of the system to request (e.g. \"Developer Laptop (Mac)\" )\n quantity: int\n The quantity of the item to request\n short_description: str\n The short description of the item (optional). if not provided, a random one will be generated\n\n Returns:\n --------\n sys_id, number of the requested item\n\n \"\"\"\n if short_description is None:\n short_description = fake.sentence(4)\n\n item_sys_id = table_api_call(\n instance=instance,\n table=\"sc_cat_item\",\n params={\"sysparm_query\": f\"sys_name={system_name}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0][\"sys_id\"]\n\n item_config = {\n \"requested_for\": user_sys_id,\n \"state\": \"3\",\n \"impact\": \"3\",\n \"active\": \"true\",\n \"priority\": \"4\",\n \"short_description\": short_description,\n \"urgency\": \"3\",\n \"quantity\": str(quantity),\n \"billable\": \"false\",\n \"cat_item\": item_sys_id,\n }\n\n result = table_api_call(\n instance=instance, table=\"sc_req_item\", json=item_config, method=\"POST\"\n )[\"result\"]\n\n return result[\"sys_id\"], result[\"number\"]","source_hash":"8345f4b00d6ff1b010cf3f637e9013a9272d50d34e4c3e78ec3e841f9678b30d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.requested_items.create_requested_item","uri":"program://WorkArena/function/src.browsergym.workarena.api.requested_items.create_requested_item#L9-L63","kind":"function","name":"create_requested_item","path":"src/browsergym/workarena/api/requested_items.py","language":"python","start_line":9,"end_line":63,"context_start_line":1,"context_end_line":63,"code":"import faker\n\nfake = faker.Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_requested_item(\n instance: SNowInstance,\n user_sys_id: str,\n system_name: str,\n quantity: int = 1,\n short_description: str = None,\n) -> list[str]:\n \"\"\"\n Create a requested item for a given user\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the requested item in\n user_sys_id: str\n The sys_id of the user to request the item for\n system_name: str\n The name of the system to request (e.g. \"Developer Laptop (Mac)\" )\n quantity: int\n The quantity of the item to request\n short_description: str\n The short description of the item (optional). if not provided, a random one will be generated\n\n Returns:\n --------\n sys_id, number of the requested item\n\n \"\"\"\n if short_description is None:\n short_description = fake.sentence(4)\n\n item_sys_id = table_api_call(\n instance=instance,\n table=\"sc_cat_item\",\n params={\"sysparm_query\": f\"sys_name={system_name}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0][\"sys_id\"]\n\n item_config = {\n \"requested_for\": user_sys_id,\n \"state\": \"3\",\n \"impact\": \"3\",\n \"active\": \"true\",\n \"priority\": \"4\",\n \"short_description\": short_description,\n \"urgency\": \"3\",\n \"quantity\": str(quantity),\n \"billable\": \"false\",\n \"cat_item\": item_sys_id,\n }\n\n result = table_api_call(\n instance=instance, table=\"sc_req_item\", json=item_config, method=\"POST\"\n )[\"result\"]\n\n return result[\"sys_id\"], result[\"number\"]","source_hash":"8345f4b00d6ff1b010cf3f637e9013a9272d50d34e4c3e78ec3e841f9678b30d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.problem","uri":"program://WorkArena/module/src.browsergym.workarena.api.problem#L1-L90","kind":"module","name":"src.browsergym.workarena.api.problem","path":"src/browsergym/workarena/api/problem.py","language":"python","start_line":1,"end_line":90,"context_start_line":1,"context_end_line":90,"code":"import faker\n\nfake = faker.Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_problem(\n instance: SNowInstance,\n priority: str,\n user_sys_id: str,\n problem_hashtag: str,\n short_description: str = None,\n return_number: bool = False,\n) -> list[str]:\n \"\"\"\n Create a problem with a random cause, description, and short description. The problem is assigned to a user and\n is created with a hashtag.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the problem in\n priority: str\n The priority of the problem\n user_sys_id: str\n The sys_id of the user to assign the problem to\n problem_hashtag: str\n The name of the hashtag for the problem\n short_description: str\n The short description of the problem (optional). if not provided, a random one will be generated\n return_number: bool\n whether or not to return the problem number that was created\n\n Returns:\n --------\n sys_id of the problem\n problem_number (optional)\n\n \"\"\"\n cause = fake.sentence()\n description = fake.text()\n if short_description is None:\n short_description = fake.sentence(4)\n\n # Priority is a read-only field defined by a combo of impact and urgency. The mapping is as follows:\n # https://docs.servicenow.com/bundle/washingtondc-it-service-management/page/product/problem-management/concept/prioritise-problems.html\n priority_to_impact_and_urgency = {\n 1: (1, 1),\n 2: (1, 2),\n 3: (1, 3),\n 4: (2, 3),\n 5: (3, 3),\n }\n\n impact, urgency = priority_to_impact_and_urgency[priority]\n\n problem_cfg = {\n \"made_sla\": True,\n \"upon_reject\": \"cancel\",\n \"cause_notes\": f\"

{cause}

\",\n \"fix_notes\": \" placeholder \", # placeholder value - will not work without a fix note\n \"knowledge\": False,\n \"major_problem\": False,\n \"impact\": f\"{impact}\",\n \"active\": False,\n \"sys_domain_path\": \"/\",\n \"short_description\": f\"{short_description} {problem_hashtag}\",\n \"known_error\": False,\n \"description\": f\"{description}\",\n \"sla_due\": \"2021-04-11 17:39:07\",\n \"closed_at\": \"\",\n \"resolution_code\": \"fix_applied\",\n \"urgency\": f\"{urgency}\",\n \"assigned_to\": f\"{user_sys_id}\",\n \"active\": True,\n }\n\n result = table_api_call(\n instance=instance,\n table=\"problem\",\n json=problem_cfg,\n method=\"POST\",\n )[\"result\"]\n\n if return_number:\n return result[\"sys_id\"], result[\"number\"]\n\n return result[\"sys_id\"]","source_hash":"404afdbb05023af559733eceafd6ca91beda088acfecb48fba5bdf38b5720f53","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.problem.create_problem","uri":"program://WorkArena/function/src.browsergym.workarena.api.problem.create_problem#L9-L90","kind":"function","name":"create_problem","path":"src/browsergym/workarena/api/problem.py","language":"python","start_line":9,"end_line":90,"context_start_line":1,"context_end_line":90,"code":"import faker\n\nfake = faker.Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_problem(\n instance: SNowInstance,\n priority: str,\n user_sys_id: str,\n problem_hashtag: str,\n short_description: str = None,\n return_number: bool = False,\n) -> list[str]:\n \"\"\"\n Create a problem with a random cause, description, and short description. The problem is assigned to a user and\n is created with a hashtag.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the problem in\n priority: str\n The priority of the problem\n user_sys_id: str\n The sys_id of the user to assign the problem to\n problem_hashtag: str\n The name of the hashtag for the problem\n short_description: str\n The short description of the problem (optional). if not provided, a random one will be generated\n return_number: bool\n whether or not to return the problem number that was created\n\n Returns:\n --------\n sys_id of the problem\n problem_number (optional)\n\n \"\"\"\n cause = fake.sentence()\n description = fake.text()\n if short_description is None:\n short_description = fake.sentence(4)\n\n # Priority is a read-only field defined by a combo of impact and urgency. The mapping is as follows:\n # https://docs.servicenow.com/bundle/washingtondc-it-service-management/page/product/problem-management/concept/prioritise-problems.html\n priority_to_impact_and_urgency = {\n 1: (1, 1),\n 2: (1, 2),\n 3: (1, 3),\n 4: (2, 3),\n 5: (3, 3),\n }\n\n impact, urgency = priority_to_impact_and_urgency[priority]\n\n problem_cfg = {\n \"made_sla\": True,\n \"upon_reject\": \"cancel\",\n \"cause_notes\": f\"

{cause}

\",\n \"fix_notes\": \" placeholder \", # placeholder value - will not work without a fix note\n \"knowledge\": False,\n \"major_problem\": False,\n \"impact\": f\"{impact}\",\n \"active\": False,\n \"sys_domain_path\": \"/\",\n \"short_description\": f\"{short_description} {problem_hashtag}\",\n \"known_error\": False,\n \"description\": f\"{description}\",\n \"sla_due\": \"2021-04-11 17:39:07\",\n \"closed_at\": \"\",\n \"resolution_code\": \"fix_applied\",\n \"urgency\": f\"{urgency}\",\n \"assigned_to\": f\"{user_sys_id}\",\n \"active\": True,\n }\n\n result = table_api_call(\n instance=instance,\n table=\"problem\",\n json=problem_cfg,\n method=\"POST\",\n )[\"result\"]\n\n if return_number:\n return result[\"sys_id\"], result[\"number\"]\n\n return result[\"sys_id\"]","source_hash":"404afdbb05023af559733eceafd6ca91beda088acfecb48fba5bdf38b5720f53","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.report","uri":"program://WorkArena/module/src.browsergym.workarena.api.report#L1-L183","kind":"module","name":"src.browsergym.workarena.api.report","path":"src/browsergym/workarena/api/report.py","language":"python","start_line":1,"end_line":183,"context_start_line":1,"context_end_line":183,"code":"import numpy as np\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_report(\n instance: SNowInstance,\n table: str,\n filter_hashtag: str,\n field: str,\n plot_title: str,\n filter_field: str = \"short_description\",\n random: np.random = None,\n) -> list[str]:\n \"\"\"\n Create a report for for the given table using a filter (str added to the short description).\n The report is created with a random color palette and colors and a random plot type (pie or bar).\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the category in\n table: str\n The name of the table used to make the plot\n field: str\n The field of the table used to make the plot\n filter_hashtag: str\n The name of the hashtag to filter the table with\n plot_title: str\n The title of the plot\n\n Returns:\n --------\n sys_id: str; sys_id of the report created\n plot_title: str; The title of the plot\n\n \"\"\"\n # select a random color palette for the plot\n color_palettes = table_api_call(\n instance=instance,\n table=\"pa_chart_color_schemes\",\n params={\n \"sysparm_fields\": \"sys_id\",\n },\n method=\"GET\",\n )[\"result\"]\n\n color_palette_sys_id = random.choice(color_palettes)[\"sys_id\"]\n\n # Get available colors to eventually randomly select from them\n colors = table_api_call(\n instance=instance,\n table=\"sys_report_color\",\n params={\n \"sysparm_fields\": \"sys_id\",\n },\n method=\"GET\",\n )[\"result\"]\n\n # Select a random plot type\n plot_types = [\"pie\", \"bar\"]\n plot_type = random.choice(plot_types)\n\n report_params = {\n \"show_data_label_position_middle\": False,\n \"display_row_lines\": False,\n \"is_published\": False,\n \"chart_title_y_position\": \"0\",\n \"gauge_autoscale\": True,\n \"type\": f\"{plot_type}\",\n \"formatting_configuration\": {\n \"table\": \"incident\",\n \"stringFormattingProperties\": {},\n \"durationFormattingProperties\": {},\n \"dateFormattingProperties\": {},\n \"numberFormattingProperties\": {},\n },\n \"apply_alias\": False,\n \"chart_border_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"custom_chart_title_position\": False,\n \"other_threshold\": \"-2\",\n \"y_axis_title_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"show_legend_border\": False,\n \"donut_width_percent\": \"30\",\n \"y_axis_title_size\": \"12\",\n \"legend_border_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"y_axis_label_bold\": False,\n \"chart_title_size\": \"16\",\n \"x_axis_label_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"active\": True,\n \"source_type\": \"table\",\n \"x_axis_title_bold\": True,\n \"x_axis_opposite\": False,\n \"chart_height\": \"450\",\n \"legend_border_radius\": \"0\",\n \"field\": field,\n \"show_geographical_label\": False,\n \"legend_horizontal_alignment\": \"center\",\n \"interval\": \"year\",\n \"show_zero\": False,\n \"y_axis_grid_width\": \"1\",\n \"chart_subtitle_size\": \"14\",\n \"x_axis_display_grid\": False,\n \"show_chart_total\": False,\n \"chart_subtitle_style\": \"normal\",\n \"chart_title_style\": \"normal\",\n \"x_axis_grid_width\": \"1\",\n \"x_axis_label_tilt\": \"0\",\n \"show_chart_title\": \"report\",\n \"title_vertical_alignment\": \"top\",\n \"legend_border_width\": \"1\",\n \"compute_percent\": \"aggregate\",\n \"show_marker\": False,\n \"sys_scope\": \"global\",\n \"map\": \"93b8a3a2d7101200bd4a4ebfae61033a\",\n \"use_color_heatmap\": False,\n \"use_null_in_trend\": False,\n \"y_axis_label_tilt\": \"0\",\n \"table\": table,\n \"legend_vertical_alignment\": \"bottom\",\n \"x_axis_label_bold\": False,\n \"no_bulk_migration\": False,\n \"filter\": f\"{filter_field}LIKE{filter_hashtag}\",\n \"display_column_lines\": False,\n \"x_axis_allow_decimals\": True,\n \"custom_chart_size\": False,\n \"title_horizontal_alignment\": \"center\",\n \"bar_unstack\": False,\n \"y_axis_allow_decimals\": True,\n \"chart_width\": \"600\",\n \"x_axis_title_size\": \"12\",\n \"y_axis_opposite\": False,\n \"y_axis_title_bold\": True,\n \"decimal_precision\": \"2\",\n \"y_axis_label_size\": \"11\",\n \"x_axis_grid_color\": f\"{random.choice(colors)['sys_id']}\",\n \"legend_align_columns\": True,\n \"field_list\": \"active,short_description,incident_state,business_duration,calendar_duration,description,caller_id,location,closed_by,impact,cmdb_ci,priority,assigned_to,activity_due,task_effective_number,company,escalation,sys_created_on,closed_at,child_incidents,state,assignment_group,category,number,business_stc\",\n \"is_scheduled\": False,\n \"others\": True,\n \"x_axis_title_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"aggregation_source\": \"no_override\",\n \"chart_title_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"y_axis_grid_dotted\": False,\n \"chart_size\": \"large\",\n \"legend_items_left_align\": False,\n \"show_chart_data_label\": False,\n \"y_axis_grid_color\": f\"{random.choice(colors)['sys_id']}\",\n \"allow_data_label_overlap\": False,\n \"chart_border_radius\": \"0\",\n \"title\": plot_title,\n \"exp_report_attrs\": True,\n \"aggregate\": \"COUNT\",\n \"y_axis_display_grid\": True,\n \"score_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"axis_max_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"b0d449b3d7332100fa6c0c12ce610383\"\n \"is_real_time\": False,\n \"show_empty\": False,\n \"direction\": \"minimize\",\n \"display_grid\": False,\n \"chart_border_width\": \"1\",\n \"funnel_neck_percent\": \"30\",\n \"show_legend\": True,\n \"set_color\": \"one_color\",\n \"color_palette\": f\"{color_palette_sys_id}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"x_axis_label_size\": \"11\",\n \"show_chart_border\": False,\n \"x_axis_grid_dotted\": False,\n \"chart_title_x_position\": \"0\",\n \"pivot_expanded\": True,\n }\n\n result = table_api_call(\n instance=instance,\n table=\"sys_report\",\n # The cmdb_model_category is the sys_id for the hardware category; computer in this case\n json=report_params,\n method=\"POST\",\n wait_for_record=True,\n )[\"result\"]\n\n return result[\"sys_id\"], plot_title","source_hash":"9cd49370ce26284f465e3966efcee20252b943bd6841b59d51c56f9741a5a5e1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.report.create_report","uri":"program://WorkArena/function/src.browsergym.workarena.api.report.create_report#L7-L183","kind":"function","name":"create_report","path":"src/browsergym/workarena/api/report.py","language":"python","start_line":7,"end_line":183,"context_start_line":1,"context_end_line":183,"code":"import numpy as np\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_report(\n instance: SNowInstance,\n table: str,\n filter_hashtag: str,\n field: str,\n plot_title: str,\n filter_field: str = \"short_description\",\n random: np.random = None,\n) -> list[str]:\n \"\"\"\n Create a report for for the given table using a filter (str added to the short description).\n The report is created with a random color palette and colors and a random plot type (pie or bar).\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the category in\n table: str\n The name of the table used to make the plot\n field: str\n The field of the table used to make the plot\n filter_hashtag: str\n The name of the hashtag to filter the table with\n plot_title: str\n The title of the plot\n\n Returns:\n --------\n sys_id: str; sys_id of the report created\n plot_title: str; The title of the plot\n\n \"\"\"\n # select a random color palette for the plot\n color_palettes = table_api_call(\n instance=instance,\n table=\"pa_chart_color_schemes\",\n params={\n \"sysparm_fields\": \"sys_id\",\n },\n method=\"GET\",\n )[\"result\"]\n\n color_palette_sys_id = random.choice(color_palettes)[\"sys_id\"]\n\n # Get available colors to eventually randomly select from them\n colors = table_api_call(\n instance=instance,\n table=\"sys_report_color\",\n params={\n \"sysparm_fields\": \"sys_id\",\n },\n method=\"GET\",\n )[\"result\"]\n\n # Select a random plot type\n plot_types = [\"pie\", \"bar\"]\n plot_type = random.choice(plot_types)\n\n report_params = {\n \"show_data_label_position_middle\": False,\n \"display_row_lines\": False,\n \"is_published\": False,\n \"chart_title_y_position\": \"0\",\n \"gauge_autoscale\": True,\n \"type\": f\"{plot_type}\",\n \"formatting_configuration\": {\n \"table\": \"incident\",\n \"stringFormattingProperties\": {},\n \"durationFormattingProperties\": {},\n \"dateFormattingProperties\": {},\n \"numberFormattingProperties\": {},\n },\n \"apply_alias\": False,\n \"chart_border_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"custom_chart_title_position\": False,\n \"other_threshold\": \"-2\",\n \"y_axis_title_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"show_legend_border\": False,\n \"donut_width_percent\": \"30\",\n \"y_axis_title_size\": \"12\",\n \"legend_border_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"y_axis_label_bold\": False,\n \"chart_title_size\": \"16\",\n \"x_axis_label_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"active\": True,\n \"source_type\": \"table\",\n \"x_axis_title_bold\": True,\n \"x_axis_opposite\": False,\n \"chart_height\": \"450\",\n \"legend_border_radius\": \"0\",\n \"field\": field,\n \"show_geographical_label\": False,\n \"legend_horizontal_alignment\": \"center\",\n \"interval\": \"year\",\n \"show_zero\": False,\n \"y_axis_grid_width\": \"1\",\n \"chart_subtitle_size\": \"14\",\n \"x_axis_display_grid\": False,\n \"show_chart_total\": False,\n \"chart_subtitle_style\": \"normal\",\n \"chart_title_style\": \"normal\",\n \"x_axis_grid_width\": \"1\",\n \"x_axis_label_tilt\": \"0\",\n \"show_chart_title\": \"report\",\n \"title_vertical_alignment\": \"top\",\n \"legend_border_width\": \"1\",\n \"compute_percent\": \"aggregate\",\n \"show_marker\": False,\n \"sys_scope\": \"global\",\n \"map\": \"93b8a3a2d7101200bd4a4ebfae61033a\",\n \"use_color_heatmap\": False,\n \"use_null_in_trend\": False,\n \"y_axis_label_tilt\": \"0\",\n \"table\": table,\n \"legend_vertical_alignment\": \"bottom\",\n \"x_axis_label_bold\": False,\n \"no_bulk_migration\": False,\n \"filter\": f\"{filter_field}LIKE{filter_hashtag}\",\n \"display_column_lines\": False,\n \"x_axis_allow_decimals\": True,\n \"custom_chart_size\": False,\n \"title_horizontal_alignment\": \"center\",\n \"bar_unstack\": False,\n \"y_axis_allow_decimals\": True,\n \"chart_width\": \"600\",\n \"x_axis_title_size\": \"12\",\n \"y_axis_opposite\": False,\n \"y_axis_title_bold\": True,\n \"decimal_precision\": \"2\",\n \"y_axis_label_size\": \"11\",\n \"x_axis_grid_color\": f\"{random.choice(colors)['sys_id']}\",\n \"legend_align_columns\": True,\n \"field_list\": \"active,short_description,incident_state,business_duration,calendar_duration,description,caller_id,location,closed_by,impact,cmdb_ci,priority,assigned_to,activity_due,task_effective_number,company,escalation,sys_created_on,closed_at,child_incidents,state,assignment_group,category,number,business_stc\",\n \"is_scheduled\": False,\n \"others\": True,\n \"x_axis_title_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"aggregation_source\": \"no_override\",\n \"chart_title_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"y_axis_grid_dotted\": False,\n \"chart_size\": \"large\",\n \"legend_items_left_align\": False,\n \"show_chart_data_label\": False,\n \"y_axis_grid_color\": f\"{random.choice(colors)['sys_id']}\",\n \"allow_data_label_overlap\": False,\n \"chart_border_radius\": \"0\",\n \"title\": plot_title,\n \"exp_report_attrs\": True,\n \"aggregate\": \"COUNT\",\n \"y_axis_display_grid\": True,\n \"score_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"axis_max_color\": f\"{random.choice(colors)['sys_id']}\", # default: \"b0d449b3d7332100fa6c0c12ce610383\"\n \"is_real_time\": False,\n \"show_empty\": False,\n \"direction\": \"minimize\",\n \"display_grid\": False,\n \"chart_border_width\": \"1\",\n \"funnel_neck_percent\": \"30\",\n \"show_legend\": True,\n \"set_color\": \"one_color\",\n \"color_palette\": f\"{color_palette_sys_id}\", # default: \"65b30218a9fe3dba0120df8611520d97\"\n \"x_axis_label_size\": \"11\",\n \"show_chart_border\": False,\n \"x_axis_grid_dotted\": False,\n \"chart_title_x_position\": \"0\",\n \"pivot_expanded\": True,\n }\n\n result = table_api_call(\n instance=instance,\n table=\"sys_report\",\n # The cmdb_model_category is the sys_id for the hardware category; computer in this case\n json=report_params,\n method=\"POST\",\n wait_for_record=True,\n )[\"result\"]\n\n return result[\"sys_id\"], plot_title","source_hash":"9cd49370ce26284f465e3966efcee20252b943bd6841b59d51c56f9741a5a5e1","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.cost_center","uri":"program://WorkArena/module/src.browsergym.workarena.api.cost_center#L1-L19","kind":"module","name":"src.browsergym.workarena.api.cost_center","path":"src/browsergym/workarena/api/cost_center.py","language":"python","start_line":1,"end_line":19,"context_start_line":1,"context_end_line":19,"code":"import warnings\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef get_cost_center_sysid(instance, cost_center_name):\n \"\"\"Get the sys_id of a cost center by its name\"\"\"\n sys_id = table_api_call(\n instance=instance,\n table=\"cmn_cost_center\",\n params={\"sysparm_query\": f\"name={cost_center_name}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0]\n\n return sys_id","source_hash":"f25146421287d540d4da7c0c62903b36a8b6b47630ee8dfb86031286c68d12cc","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.cost_center.get_cost_center_sysid","uri":"program://WorkArena/function/src.browsergym.workarena.api.cost_center.get_cost_center_sysid#L11-L19","kind":"function","name":"get_cost_center_sysid","path":"src/browsergym/workarena/api/cost_center.py","language":"python","start_line":11,"end_line":19,"context_start_line":1,"context_end_line":19,"code":"import warnings\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef get_cost_center_sysid(instance, cost_center_name):\n \"\"\"Get the sys_id of a cost center by its name\"\"\"\n sys_id = table_api_call(\n instance=instance,\n table=\"cmn_cost_center\",\n params={\"sysparm_query\": f\"name={cost_center_name}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0]\n\n return sys_id","source_hash":"f25146421287d540d4da7c0c62903b36a8b6b47630ee8dfb86031286c68d12cc","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.ui_themes","uri":"program://WorkArena/module/src.browsergym.workarena.api.ui_themes#L1-L35","kind":"module","name":"src.browsergym.workarena.api.ui_themes","path":"src/browsergym/workarena/api/ui_themes.py","language":"python","start_line":1,"end_line":35,"context_start_line":1,"context_end_line":35,"code":"\"\"\"\nUtility functions for UI themes\n\n\"\"\"\n\nfrom .utils import table_api_call\n\n\ndef get_workarena_theme_variants(instance):\n \"\"\"\n Get the list of available WorkArena UI themes\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to get the UI themes from\n\n Returns:\n --------\n list[dict]\n The list of available WorkArena UI themes and their information\n\n \"\"\"\n themes = table_api_call(\n instance=instance,\n table=\"m2m_theme_style\",\n params={\n \"sysparm_query\": \"style.type=variant\",\n \"sysparm_fields\": \"theme.name,theme.sys_id,style.name,style.sys_id\",\n \"sysparm_display_value\": True,\n },\n method=\"GET\",\n )[\"result\"]\n themes = [t for t in themes if t[\"theme.name\"] == \"WorkArena\"]\n return themes","source_hash":"f47f07867a875add020395f9135b289245d2098631b5666f84d15c5e7ddef74b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.ui_themes.get_workarena_theme_variants","uri":"program://WorkArena/function/src.browsergym.workarena.api.ui_themes.get_workarena_theme_variants#L9-L35","kind":"function","name":"get_workarena_theme_variants","path":"src/browsergym/workarena/api/ui_themes.py","language":"python","start_line":9,"end_line":35,"context_start_line":1,"context_end_line":35,"code":"\"\"\"\nUtility functions for UI themes\n\n\"\"\"\n\nfrom .utils import table_api_call\n\n\ndef get_workarena_theme_variants(instance):\n \"\"\"\n Get the list of available WorkArena UI themes\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to get the UI themes from\n\n Returns:\n --------\n list[dict]\n The list of available WorkArena UI themes and their information\n\n \"\"\"\n themes = table_api_call(\n instance=instance,\n table=\"m2m_theme_style\",\n params={\n \"sysparm_query\": \"style.type=variant\",\n \"sysparm_fields\": \"theme.name,theme.sys_id,style.name,style.sys_id\",\n \"sysparm_display_value\": True,\n },\n method=\"GET\",\n )[\"result\"]\n themes = [t for t in themes if t[\"theme.name\"] == \"WorkArena\"]\n return themes","source_hash":"f47f07867a875add020395f9135b289245d2098631b5666f84d15c5e7ddef74b","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.utils","uri":"program://WorkArena/module/src.browsergym.workarena.api.utils#L1-L174","kind":"module","name":"src.browsergym.workarena.api.utils","path":"src/browsergym/workarena/api/utils.py","language":"python","start_line":1,"end_line":174,"context_start_line":1,"context_end_line":174,"code":"import requests\n\nfrom ..instance import SNowInstance\n\nfrom requests.exceptions import HTTPError\nfrom time import sleep\n\n# ServiceNow API configuration\nSNOW_API_HEADERS = {\"Content-Type\": \"application/json\", \"Accept\": \"application/json\"}\n\n\ndef table_api_call(\n instance: SNowInstance,\n table: str,\n data: dict = {},\n params: dict = {},\n json: dict = {},\n method: str = \"GET\",\n wait_for_record: bool = False,\n max_retries: int = 5,\n raise_on_wait_expired: bool = True,\n) -> dict:\n \"\"\"\n Make a call to the ServiceNow Table API\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to interact with\n table: str\n The name of the table to interact with\n data: dict\n The data to send with the request\n params: dict\n The parameters to pass to the API\n json: dict\n The JSON data to send with the request\n method: str\n The HTTP method to use (GET, POST, PUT, DELETE).\n wait_for_record: bool\n If True, will wait up to 2 seconds for the record to be present before returning\n max_retries: int\n The number of retries to attempt before failing\n raise_on_wait_expired: bool\n If True, will raise an exception if the record is not found after max_retries.\n Otherwise, will return an empty result.\n\n Returns:\n --------\n dict\n The JSON response from the API\n\n \"\"\"\n\n # Query API\n response = requests.request(\n method=method,\n url=instance.snow_url + f\"/api/now/table/{table}\",\n auth=instance.snow_credentials,\n headers=SNOW_API_HEADERS,\n data=data,\n params=params,\n json=json,\n )\n if method == \"POST\":\n sys_id = response.json()[\"result\"][\"sys_id\"]\n data = {}\n params = {\"sysparm_query\": f\"sys_id={sys_id}\"}\n\n # Check for HTTP success code (fail otherwise)\n response.raise_for_status()\n\n record_exists = False\n num_retries = 0\n if method == \"POST\" or wait_for_record:\n while not record_exists:\n sleep(0.5)\n get_response = table_api_call(\n instance=instance,\n table=table,\n params=params,\n json=json,\n data=data,\n method=\"GET\",\n )\n record_exists = len(get_response[\"result\"]) > 0\n num_retries += 1\n if num_retries > max_retries:\n if raise_on_wait_expired:\n raise HTTPError(f\"Record not found after {max_retries} retries\")\n else:\n return {\"result\": []}\n if method == \"GET\":\n response = get_response\n\n if method != \"DELETE\":\n # Decode the JSON response into a dictionary if necessary\n # When using wait_for_record=True, the response is already a dict as it is a recursive call\n if type(response) == dict:\n return response\n else:\n return response.json()\n else:\n return response\n\n\ndef table_column_info(instance: SNowInstance, table: str) -> dict:\n \"\"\"\n Get the column information for a ServiceNow table\n\n Parameters:\n -----------\n table: str\n The name of the table to interact with\n\n Returns:\n --------\n dict\n The JSON response from the API\n\n \"\"\"\n # Query the Meta API to get most of the column info (e.g., valid choices)\n response = requests.get(\n url=instance.snow_url + f\"/api/now/ui/meta/{table}\",\n auth=instance.snow_credentials,\n headers=SNOW_API_HEADERS,\n )\n response.raise_for_status()\n meta_info = response.json()[\"result\"][\"columns\"]\n\n # Clean column value choices\n for info in meta_info.values():\n if info.get(\"choices\", None):\n info[\"choices\"] = {c[\"value\"]: c[\"label\"] for c in info[\"choices\"]}\n\n # Query the sys_dictionnary table to find more info (e.g., is this column dependent on another)\n sys_dict_info = table_api_call(\n instance=instance,\n table=\"sys_dictionary\",\n params={\n \"sysparm_query\": f\"name={table}\",\n \"sysparm_fields\": \"element,dependent_on_field\",\n },\n )\n sys_dict_info = {d[\"element\"]: d for d in sys_dict_info[\"result\"]}\n\n # Merge information\n for k, v in meta_info.items():\n v.update(sys_dict_info.get(k, {}))\n\n return meta_info\n\n\ndef db_delete_from_table(instance: SNowInstance, sys_id: str, table: str) -> None:\n \"\"\"\n Delete an entry from a ServiceNow table using its sys_id\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the entry to delete\n table: str\n The name of the table to delete from\n\n \"\"\"\n # Query API\n response = requests.delete(\n url=instance.snow_url + f\"/api/now/table/{table}/{sys_id}\",\n auth=instance.snow_credentials,\n headers=SNOW_API_HEADERS,\n )\n\n # Check for HTTP code 200 (fail otherwise)\n response.raise_for_status()","source_hash":"b2e954d6b0ba8e20b20d5c27e4fa8f2b4002fba9be1894bfe02af36abea910d5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.utils.table_api_call","uri":"program://WorkArena/function/src.browsergym.workarena.api.utils.table_api_call#L12-L104","kind":"function","name":"table_api_call","path":"src/browsergym/workarena/api/utils.py","language":"python","start_line":12,"end_line":104,"context_start_line":1,"context_end_line":124,"code":"import requests\n\nfrom ..instance import SNowInstance\n\nfrom requests.exceptions import HTTPError\nfrom time import sleep\n\n# ServiceNow API configuration\nSNOW_API_HEADERS = {\"Content-Type\": \"application/json\", \"Accept\": \"application/json\"}\n\n\ndef table_api_call(\n instance: SNowInstance,\n table: str,\n data: dict = {},\n params: dict = {},\n json: dict = {},\n method: str = \"GET\",\n wait_for_record: bool = False,\n max_retries: int = 5,\n raise_on_wait_expired: bool = True,\n) -> dict:\n \"\"\"\n Make a call to the ServiceNow Table API\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to interact with\n table: str\n The name of the table to interact with\n data: dict\n The data to send with the request\n params: dict\n The parameters to pass to the API\n json: dict\n The JSON data to send with the request\n method: str\n The HTTP method to use (GET, POST, PUT, DELETE).\n wait_for_record: bool\n If True, will wait up to 2 seconds for the record to be present before returning\n max_retries: int\n The number of retries to attempt before failing\n raise_on_wait_expired: bool\n If True, will raise an exception if the record is not found after max_retries.\n Otherwise, will return an empty result.\n\n Returns:\n --------\n dict\n The JSON response from the API\n\n \"\"\"\n\n # Query API\n response = requests.request(\n method=method,\n url=instance.snow_url + f\"/api/now/table/{table}\",\n auth=instance.snow_credentials,\n headers=SNOW_API_HEADERS,\n data=data,\n params=params,\n json=json,\n )\n if method == \"POST\":\n sys_id = response.json()[\"result\"][\"sys_id\"]\n data = {}\n params = {\"sysparm_query\": f\"sys_id={sys_id}\"}\n\n # Check for HTTP success code (fail otherwise)\n response.raise_for_status()\n\n record_exists = False\n num_retries = 0\n if method == \"POST\" or wait_for_record:\n while not record_exists:\n sleep(0.5)\n get_response = table_api_call(\n instance=instance,\n table=table,\n params=params,\n json=json,\n data=data,\n method=\"GET\",\n )\n record_exists = len(get_response[\"result\"]) > 0\n num_retries += 1\n if num_retries > max_retries:\n if raise_on_wait_expired:\n raise HTTPError(f\"Record not found after {max_retries} retries\")\n else:\n return {\"result\": []}\n if method == \"GET\":\n response = get_response\n\n if method != \"DELETE\":\n # Decode the JSON response into a dictionary if necessary\n # When using wait_for_record=True, the response is already a dict as it is a recursive call\n if type(response) == dict:\n return response\n else:\n return response.json()\n else:\n return response\n\n\ndef table_column_info(instance: SNowInstance, table: str) -> dict:\n \"\"\"\n Get the column information for a ServiceNow table\n\n Parameters:\n -----------\n table: str\n The name of the table to interact with\n\n Returns:\n --------\n dict\n The JSON response from the API\n\n \"\"\"\n # Query the Meta API to get most of the column info (e.g., valid choices)\n response = requests.get(\n url=instance.snow_url + f\"/api/now/ui/meta/{table}\",","source_hash":"b2e954d6b0ba8e20b20d5c27e4fa8f2b4002fba9be1894bfe02af36abea910d5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.utils.table_column_info","uri":"program://WorkArena/function/src.browsergym.workarena.api.utils.table_column_info#L107-L151","kind":"function","name":"table_column_info","path":"src/browsergym/workarena/api/utils.py","language":"python","start_line":107,"end_line":151,"context_start_line":87,"context_end_line":171,"code":" num_retries += 1\n if num_retries > max_retries:\n if raise_on_wait_expired:\n raise HTTPError(f\"Record not found after {max_retries} retries\")\n else:\n return {\"result\": []}\n if method == \"GET\":\n response = get_response\n\n if method != \"DELETE\":\n # Decode the JSON response into a dictionary if necessary\n # When using wait_for_record=True, the response is already a dict as it is a recursive call\n if type(response) == dict:\n return response\n else:\n return response.json()\n else:\n return response\n\n\ndef table_column_info(instance: SNowInstance, table: str) -> dict:\n \"\"\"\n Get the column information for a ServiceNow table\n\n Parameters:\n -----------\n table: str\n The name of the table to interact with\n\n Returns:\n --------\n dict\n The JSON response from the API\n\n \"\"\"\n # Query the Meta API to get most of the column info (e.g., valid choices)\n response = requests.get(\n url=instance.snow_url + f\"/api/now/ui/meta/{table}\",\n auth=instance.snow_credentials,\n headers=SNOW_API_HEADERS,\n )\n response.raise_for_status()\n meta_info = response.json()[\"result\"][\"columns\"]\n\n # Clean column value choices\n for info in meta_info.values():\n if info.get(\"choices\", None):\n info[\"choices\"] = {c[\"value\"]: c[\"label\"] for c in info[\"choices\"]}\n\n # Query the sys_dictionnary table to find more info (e.g., is this column dependent on another)\n sys_dict_info = table_api_call(\n instance=instance,\n table=\"sys_dictionary\",\n params={\n \"sysparm_query\": f\"name={table}\",\n \"sysparm_fields\": \"element,dependent_on_field\",\n },\n )\n sys_dict_info = {d[\"element\"]: d for d in sys_dict_info[\"result\"]}\n\n # Merge information\n for k, v in meta_info.items():\n v.update(sys_dict_info.get(k, {}))\n\n return meta_info\n\n\ndef db_delete_from_table(instance: SNowInstance, sys_id: str, table: str) -> None:\n \"\"\"\n Delete an entry from a ServiceNow table using its sys_id\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the entry to delete\n table: str\n The name of the table to delete from\n\n \"\"\"\n # Query API\n response = requests.delete(\n url=instance.snow_url + f\"/api/now/table/{table}/{sys_id}\",\n auth=instance.snow_credentials,\n headers=SNOW_API_HEADERS,\n )","source_hash":"b2e954d6b0ba8e20b20d5c27e4fa8f2b4002fba9be1894bfe02af36abea910d5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.utils.db_delete_from_table","uri":"program://WorkArena/function/src.browsergym.workarena.api.utils.db_delete_from_table#L154-L174","kind":"function","name":"db_delete_from_table","path":"src/browsergym/workarena/api/utils.py","language":"python","start_line":154,"end_line":174,"context_start_line":134,"context_end_line":174,"code":" info[\"choices\"] = {c[\"value\"]: c[\"label\"] for c in info[\"choices\"]}\n\n # Query the sys_dictionnary table to find more info (e.g., is this column dependent on another)\n sys_dict_info = table_api_call(\n instance=instance,\n table=\"sys_dictionary\",\n params={\n \"sysparm_query\": f\"name={table}\",\n \"sysparm_fields\": \"element,dependent_on_field\",\n },\n )\n sys_dict_info = {d[\"element\"]: d for d in sys_dict_info[\"result\"]}\n\n # Merge information\n for k, v in meta_info.items():\n v.update(sys_dict_info.get(k, {}))\n\n return meta_info\n\n\ndef db_delete_from_table(instance: SNowInstance, sys_id: str, table: str) -> None:\n \"\"\"\n Delete an entry from a ServiceNow table using its sys_id\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the entry to delete\n table: str\n The name of the table to delete from\n\n \"\"\"\n # Query API\n response = requests.delete(\n url=instance.snow_url + f\"/api/now/table/{table}/{sys_id}\",\n auth=instance.snow_credentials,\n headers=SNOW_API_HEADERS,\n )\n\n # Check for HTTP code 200 (fail otherwise)\n response.raise_for_status()","source_hash":"b2e954d6b0ba8e20b20d5c27e4fa8f2b4002fba9be1894bfe02af36abea910d5","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.system_properties","uri":"program://WorkArena/module/src.browsergym.workarena.api.system_properties#L1-L66","kind":"module","name":"src.browsergym.workarena.api.system_properties","path":"src/browsergym/workarena/api/system_properties.py","language":"python","start_line":1,"end_line":66,"context_start_line":1,"context_end_line":66,"code":"from .utils import table_api_call\n\n\ndef set_sys_property(instance, property_name: str, value: str):\n \"\"\"\n Set a sys_property in the instance.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to set the property in\n property_name: str\n The name of the property to set\n value: str\n The value to set for the property\n\n \"\"\"\n\n property = table_api_call(\n instance=instance,\n table=\"sys_properties\",\n params={\"sysparm_query\": f\"name={property_name}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"]\n\n if not property:\n property_sysid = \"\"\n method = \"POST\"\n else:\n property_sysid = \"/\" + property[0][\"sys_id\"]\n method = \"PUT\"\n\n property = table_api_call(\n instance=instance,\n table=f\"sys_properties{property_sysid}\",\n method=method,\n json={\"name\": property_name, \"value\": value},\n )\n\n # Verify that the property was updated\n assert property[\"result\"][\"value\"] == value, f\"Error setting {property_name}.\"\n\n\ndef get_sys_property(instance, property_name: str) -> str:\n \"\"\"\n Get a sys_property from the instance.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to get the property from\n property_name: str\n The name of the property to get\n\n Returns:\n --------\n str\n The value of the property\n\n \"\"\"\n property_value = table_api_call(\n instance=instance,\n table=\"sys_properties\",\n params={\"sysparm_query\": f\"name={property_name}\", \"sysparm_fields\": \"value\"},\n )[\"result\"][0][\"value\"]\n\n return property_value","source_hash":"f83cac1ee5137c7f36b6440639a94d76daa5fb6c9e196107e5005a613a412a1e","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.system_properties.set_sys_property","uri":"program://WorkArena/function/src.browsergym.workarena.api.system_properties.set_sys_property#L4-L40","kind":"function","name":"set_sys_property","path":"src/browsergym/workarena/api/system_properties.py","language":"python","start_line":4,"end_line":40,"context_start_line":1,"context_end_line":60,"code":"from .utils import table_api_call\n\n\ndef set_sys_property(instance, property_name: str, value: str):\n \"\"\"\n Set a sys_property in the instance.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to set the property in\n property_name: str\n The name of the property to set\n value: str\n The value to set for the property\n\n \"\"\"\n\n property = table_api_call(\n instance=instance,\n table=\"sys_properties\",\n params={\"sysparm_query\": f\"name={property_name}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"]\n\n if not property:\n property_sysid = \"\"\n method = \"POST\"\n else:\n property_sysid = \"/\" + property[0][\"sys_id\"]\n method = \"PUT\"\n\n property = table_api_call(\n instance=instance,\n table=f\"sys_properties{property_sysid}\",\n method=method,\n json={\"name\": property_name, \"value\": value},\n )\n\n # Verify that the property was updated\n assert property[\"result\"][\"value\"] == value, f\"Error setting {property_name}.\"\n\n\ndef get_sys_property(instance, property_name: str) -> str:\n \"\"\"\n Get a sys_property from the instance.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to get the property from\n property_name: str\n The name of the property to get\n\n Returns:\n --------\n str\n The value of the property\n\n \"\"\"\n property_value = table_api_call(","source_hash":"f83cac1ee5137c7f36b6440639a94d76daa5fb6c9e196107e5005a613a412a1e","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.system_properties.get_sys_property","uri":"program://WorkArena/function/src.browsergym.workarena.api.system_properties.get_sys_property#L43-L66","kind":"function","name":"get_sys_property","path":"src/browsergym/workarena/api/system_properties.py","language":"python","start_line":43,"end_line":66,"context_start_line":23,"context_end_line":66,"code":" )[\"result\"]\n\n if not property:\n property_sysid = \"\"\n method = \"POST\"\n else:\n property_sysid = \"/\" + property[0][\"sys_id\"]\n method = \"PUT\"\n\n property = table_api_call(\n instance=instance,\n table=f\"sys_properties{property_sysid}\",\n method=method,\n json={\"name\": property_name, \"value\": value},\n )\n\n # Verify that the property was updated\n assert property[\"result\"][\"value\"] == value, f\"Error setting {property_name}.\"\n\n\ndef get_sys_property(instance, property_name: str) -> str:\n \"\"\"\n Get a sys_property from the instance.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to get the property from\n property_name: str\n The name of the property to get\n\n Returns:\n --------\n str\n The value of the property\n\n \"\"\"\n property_value = table_api_call(\n instance=instance,\n table=\"sys_properties\",\n params={\"sysparm_query\": f\"name={property_name}\", \"sysparm_fields\": \"value\"},\n )[\"result\"][0][\"value\"]\n\n return property_value","source_hash":"f83cac1ee5137c7f36b6440639a94d76daa5fb6c9e196107e5005a613a412a1e","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.change_request","uri":"program://WorkArena/module/src.browsergym.workarena.api.change_request#L1-L87","kind":"module","name":"src.browsergym.workarena.api.change_request","path":"src/browsergym/workarena/api/change_request.py","language":"python","start_line":1,"end_line":87,"context_start_line":1,"context_end_line":87,"code":"import faker\nimport numpy as np\n\nfake = faker.Faker()\n\nfrom datetime import datetime, timedelta\n\nfrom .category import get_categories\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_change_request(\n instance: SNowInstance,\n user_sys_id: str,\n impact: int,\n risk: int,\n start_date: datetime = \"\",\n end_date: datetime = \"\",\n hashtag: str = \"\",\n short_description: str = None,\n random: np.random = None,\n) -> list[str]:\n \"\"\"\n Create a change request\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the change request in\n user_sys_id: str\n The sys_id of the user to assign the problem to\n impact: str\n The impact of the change request; ranges from 1 (high) to 3 (low)\n risk: str\n The risk of the change request; ranges from 2 (high) to 4 (low)\n start_date: datetime.datetime\n The start date of the change request; empty if not set\n end_date: datetime.datetime\n The end date of the change request; empty if not set\n hashtag: str\n The name of the hashtag for the change request. If \"\", no hashtag will be added\n short_description: str\n The short description of the change request. If None, a random sentence will be generated\n random: np.random\n The random number generator\n\n Returns:\n --------\n sys_id of the change request\n number of the change request\n\n \"\"\"\n if short_description is None:\n short_description = fake.sentence(4)\n categories = get_categories(instance=instance, list_name=\"change_request\")\n category = random.choice(categories)\n\n cfg = {\n \"reason\": \"broken\",\n \"upon_reject\": \"cancel\",\n \"type\": \"emergency\",\n \"state\": \"-5\",\n \"phase\": \"requested\",\n \"impact\": str(impact),\n \"active\": \"true\",\n \"short_description\": short_description + \" \" + hashtag,\n \"assigned_to\": user_sys_id,\n \"start_date\": str(start_date),\n \"end_date\": str(end_date),\n \"upon_approval\": \"proceed\",\n \"justification\": fake.sentence(),\n \"implementation_plan\": fake.sentence(),\n \"phase_state\": \"open\",\n \"risk\": str(risk),\n \"cab_required\": \"false\",\n \"category\": category,\n }\n result = table_api_call(\n instance=instance,\n table=\"change_request\",\n method=\"POST\",\n json=cfg,\n )[\"result\"]\n\n return result[\"sys_id\"], result[\"number\"]","source_hash":"f59e6e3f6df1d3c5ae25aa359dad6d80cfc1f03998a01e2f8e27a3850a260c2c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.change_request.create_change_request","uri":"program://WorkArena/function/src.browsergym.workarena.api.change_request.create_change_request#L14-L87","kind":"function","name":"create_change_request","path":"src/browsergym/workarena/api/change_request.py","language":"python","start_line":14,"end_line":87,"context_start_line":1,"context_end_line":87,"code":"import faker\nimport numpy as np\n\nfake = faker.Faker()\n\nfrom datetime import datetime, timedelta\n\nfrom .category import get_categories\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_change_request(\n instance: SNowInstance,\n user_sys_id: str,\n impact: int,\n risk: int,\n start_date: datetime = \"\",\n end_date: datetime = \"\",\n hashtag: str = \"\",\n short_description: str = None,\n random: np.random = None,\n) -> list[str]:\n \"\"\"\n Create a change request\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the change request in\n user_sys_id: str\n The sys_id of the user to assign the problem to\n impact: str\n The impact of the change request; ranges from 1 (high) to 3 (low)\n risk: str\n The risk of the change request; ranges from 2 (high) to 4 (low)\n start_date: datetime.datetime\n The start date of the change request; empty if not set\n end_date: datetime.datetime\n The end date of the change request; empty if not set\n hashtag: str\n The name of the hashtag for the change request. If \"\", no hashtag will be added\n short_description: str\n The short description of the change request. If None, a random sentence will be generated\n random: np.random\n The random number generator\n\n Returns:\n --------\n sys_id of the change request\n number of the change request\n\n \"\"\"\n if short_description is None:\n short_description = fake.sentence(4)\n categories = get_categories(instance=instance, list_name=\"change_request\")\n category = random.choice(categories)\n\n cfg = {\n \"reason\": \"broken\",\n \"upon_reject\": \"cancel\",\n \"type\": \"emergency\",\n \"state\": \"-5\",\n \"phase\": \"requested\",\n \"impact\": str(impact),\n \"active\": \"true\",\n \"short_description\": short_description + \" \" + hashtag,\n \"assigned_to\": user_sys_id,\n \"start_date\": str(start_date),\n \"end_date\": str(end_date),\n \"upon_approval\": \"proceed\",\n \"justification\": fake.sentence(),\n \"implementation_plan\": fake.sentence(),\n \"phase_state\": \"open\",\n \"risk\": str(risk),\n \"cab_required\": \"false\",\n \"category\": category,\n }\n result = table_api_call(\n instance=instance,\n table=\"change_request\",\n method=\"POST\",\n json=cfg,\n )[\"result\"]\n\n return result[\"sys_id\"], result[\"number\"]","source_hash":"f59e6e3f6df1d3c5ae25aa359dad6d80cfc1f03998a01e2f8e27a3850a260c2c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.knowledge","uri":"program://WorkArena/module/src.browsergym.workarena.api.knowledge#L1-L29","kind":"module","name":"src.browsergym.workarena.api.knowledge","path":"src/browsergym/workarena/api/knowledge.py","language":"python","start_line":1,"end_line":29,"context_start_line":1,"context_end_line":29,"code":"from ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef give_kb_read_permissions(admin_instance, user_sys_id, user_name, kb_sys_id, kb_name):\n # Need admin permissions to give KB permissions to the user\n\n # Create user criteria\n user_criteria_data = {\n \"user\": user_sys_id,\n \"name\": f\"{user_name} read KB\",\n \"short_description\": f\"Let {user_name} read {kb_name}\",\n }\n criteria_response = table_api_call(\n instance=admin_instance, table=\"user_criteria\", json=user_criteria_data, method=\"POST\"\n )[\"result\"]\n criteria_sys_id = criteria_response[\"sys_id\"]\n\n # Add user criteria entry to allow users to access the ADHOC KB\n kb_uc_can_read_mtom_data = {\n \"user_criteria\": criteria_sys_id,\n \"kb_knowledge_base\": kb_sys_id,\n }\n _ = table_api_call(\n instance=admin_instance,\n table=\"kb_uc_can_read_mtom\",\n json=kb_uc_can_read_mtom_data,\n method=\"POST\",\n )[\"result\"]","source_hash":"94fbcd0d7c02f4df5998ebdea8b57047d07ab588fc0c3a278f69f77eed40a034","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.knowledge.give_kb_read_permissions","uri":"program://WorkArena/function/src.browsergym.workarena.api.knowledge.give_kb_read_permissions#L5-L29","kind":"function","name":"give_kb_read_permissions","path":"src/browsergym/workarena/api/knowledge.py","language":"python","start_line":5,"end_line":29,"context_start_line":1,"context_end_line":29,"code":"from ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef give_kb_read_permissions(admin_instance, user_sys_id, user_name, kb_sys_id, kb_name):\n # Need admin permissions to give KB permissions to the user\n\n # Create user criteria\n user_criteria_data = {\n \"user\": user_sys_id,\n \"name\": f\"{user_name} read KB\",\n \"short_description\": f\"Let {user_name} read {kb_name}\",\n }\n criteria_response = table_api_call(\n instance=admin_instance, table=\"user_criteria\", json=user_criteria_data, method=\"POST\"\n )[\"result\"]\n criteria_sys_id = criteria_response[\"sys_id\"]\n\n # Add user criteria entry to allow users to access the ADHOC KB\n kb_uc_can_read_mtom_data = {\n \"user_criteria\": criteria_sys_id,\n \"kb_knowledge_base\": kb_sys_id,\n }\n _ = table_api_call(\n instance=admin_instance,\n table=\"kb_uc_can_read_mtom\",\n json=kb_uc_can_read_mtom_data,\n method=\"POST\",\n )[\"result\"]","source_hash":"94fbcd0d7c02f4df5998ebdea8b57047d07ab588fc0c3a278f69f77eed40a034","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.user","uri":"program://WorkArena/module/src.browsergym.workarena.api.user#L1-L156","kind":"module","name":"src.browsergym.workarena.api.user","path":"src/browsergym/workarena/api/user.py","language":"python","start_line":1,"end_line":156,"context_start_line":1,"context_end_line":156,"code":"from faker import Faker\nimport numpy as np\nimport time\n\nfake = Faker()\n\nfrom ..instance import SNowInstance\nfrom .ui_themes import get_workarena_theme_variants\nfrom .utils import table_api_call\n\n\ndef create_user(\n instance: SNowInstance,\n first_name: str = None,\n last_name: str = None,\n user_name: str = None,\n return_full_response: bool = False,\n user_roles: list[str] = [\"admin\"],\n random: np.random = np.random,\n) -> list[str]:\n \"\"\"\n Create a user with a random username and password with an admin role\n\n Parameters:\n -----------\n first_name: str\n The first name of the user, defaults to a random first name\n last_name: str\n The last name of the user, defaults to a random last name\n user_name: str\n The user name of the user, defaults to first_name.last_name\n user_roles: list[str]\n The roles to assign to the user, defaults to ['admin']\n\n Returns:\n --------\n username, password, sys_id\n\n \"\"\"\n user_idx = str(random.randint(1000, 9999))\n user_password = \"aStrongPassword!\"\n first_name = fake.first_name() if not first_name else first_name\n last_name = fake.last_name() if not last_name else last_name\n\n # Create user\n user_data = {\n \"user_name\": f\"{first_name}.{last_name}.{user_idx}\" if not user_name else user_name,\n \"first_name\": first_name,\n \"last_name\": last_name,\n \"email\": f\"{first_name}.{last_name}.{user_idx}@workarena.com\".lower(),\n \"user_password\": user_password,\n \"active\": True,\n }\n user_params = {\"sysparm_input_display_value\": True}\n user_response = table_api_call(\n instance=instance, table=\"sys_user\", json=user_data, params=user_params, method=\"POST\"\n )[\"result\"]\n user_name = user_response[\"user_name\"]\n user_sys_id = user_response[\"sys_id\"]\n\n # Get role sys_id's\n for role in user_roles:\n role_sys_id = table_api_call(\n instance=instance,\n table=\"sys_user_role\",\n params={\"sysparm_query\": f\"name={role}\", \"sysparm_fields\": \"sys_id\"},\n method=\"GET\",\n )[\"result\"][0][\"sys_id\"]\n\n # Give admin permissions\n association_data = {\"user\": user_sys_id, \"role\": role_sys_id}\n table_api_call(\n instance=instance, table=\"sys_user_has_role\", json=association_data, method=\"POST\"\n )\n\n # Randomly pick a UI theme and set it for the user\n themes = get_workarena_theme_variants(instance)\n theme = random.choice(themes)\n set_user_preference(\n instance, \"glide.ui.polaris.theme.variant\", theme[\"style.sys_id\"], user=user_sys_id\n )\n if return_full_response:\n return user_response\n return user_name, user_password, user_sys_id\n\n\ndef set_user_preference(instance: SNowInstance, key: str, value: str, user=None) -> dict:\n \"\"\"\n Set a user preference in the ServiceNow instance\n\n Parameters:\n -----------\n key: str\n The name of the preference\n value: str\n The value of the preference\n user: str\n The sys_id of the user. If None, the preference will be set globally.\n\n Returns:\n --------\n dict\n The preference that was set\n\n \"\"\"\n if user is None:\n # make it global\n user = \"\"\n system = True\n else:\n system = False\n\n # Try to get the preference's sys_id\n preference = table_api_call(\n instance=instance,\n table=\"sys_user_preference\",\n params={\"sysparm_query\": f\"name={key},user={user}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"]\n\n if not preference:\n # ... The preference key doesn't exist, create it\n pref_sysid = \"\"\n method = \"POST\"\n else:\n # ... The preference key exists, update it\n pref_sysid = \"/\" + preference[0][\"sys_id\"]\n method = \"PUT\"\n\n property = table_api_call(\n instance=instance,\n table=f\"sys_user_preference{pref_sysid}\",\n method=method,\n json={\n \"name\": key,\n \"value\": value,\n \"user\": user,\n \"system\": system,\n \"description\": \"Updated by WorkArena\",\n },\n )[\"result\"]\n\n # Verify that the property was updated\n property[\"user\"] = (\n property[\"user\"].get(\"value\") if isinstance(property[\"user\"], dict) else property[\"user\"]\n )\n assert (\n property[\"value\"] == value\n ), f\"Error setting system property {key}, incorrect value {property['value']}, while expecting {value}.\"\n assert (\n property[\"user\"] == user\n ), f\"Error setting system property {key}, incorrect user {property['user']}, while expecting {user}.\"\n assert (\n property[\"system\"] == str(system).lower()\n ), f\"Error setting {key}, incorrect system {property['system']}, while expecting {system}.\"\n\n return property","source_hash":"98bc7caf8445540bb0ebae75e319e2bf9b27fcee24c2302c55ffa20900bd6899","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.user.create_user","uri":"program://WorkArena/function/src.browsergym.workarena.api.user.create_user#L12-L84","kind":"function","name":"create_user","path":"src/browsergym/workarena/api/user.py","language":"python","start_line":12,"end_line":84,"context_start_line":1,"context_end_line":104,"code":"from faker import Faker\nimport numpy as np\nimport time\n\nfake = Faker()\n\nfrom ..instance import SNowInstance\nfrom .ui_themes import get_workarena_theme_variants\nfrom .utils import table_api_call\n\n\ndef create_user(\n instance: SNowInstance,\n first_name: str = None,\n last_name: str = None,\n user_name: str = None,\n return_full_response: bool = False,\n user_roles: list[str] = [\"admin\"],\n random: np.random = np.random,\n) -> list[str]:\n \"\"\"\n Create a user with a random username and password with an admin role\n\n Parameters:\n -----------\n first_name: str\n The first name of the user, defaults to a random first name\n last_name: str\n The last name of the user, defaults to a random last name\n user_name: str\n The user name of the user, defaults to first_name.last_name\n user_roles: list[str]\n The roles to assign to the user, defaults to ['admin']\n\n Returns:\n --------\n username, password, sys_id\n\n \"\"\"\n user_idx = str(random.randint(1000, 9999))\n user_password = \"aStrongPassword!\"\n first_name = fake.first_name() if not first_name else first_name\n last_name = fake.last_name() if not last_name else last_name\n\n # Create user\n user_data = {\n \"user_name\": f\"{first_name}.{last_name}.{user_idx}\" if not user_name else user_name,\n \"first_name\": first_name,\n \"last_name\": last_name,\n \"email\": f\"{first_name}.{last_name}.{user_idx}@workarena.com\".lower(),\n \"user_password\": user_password,\n \"active\": True,\n }\n user_params = {\"sysparm_input_display_value\": True}\n user_response = table_api_call(\n instance=instance, table=\"sys_user\", json=user_data, params=user_params, method=\"POST\"\n )[\"result\"]\n user_name = user_response[\"user_name\"]\n user_sys_id = user_response[\"sys_id\"]\n\n # Get role sys_id's\n for role in user_roles:\n role_sys_id = table_api_call(\n instance=instance,\n table=\"sys_user_role\",\n params={\"sysparm_query\": f\"name={role}\", \"sysparm_fields\": \"sys_id\"},\n method=\"GET\",\n )[\"result\"][0][\"sys_id\"]\n\n # Give admin permissions\n association_data = {\"user\": user_sys_id, \"role\": role_sys_id}\n table_api_call(\n instance=instance, table=\"sys_user_has_role\", json=association_data, method=\"POST\"\n )\n\n # Randomly pick a UI theme and set it for the user\n themes = get_workarena_theme_variants(instance)\n theme = random.choice(themes)\n set_user_preference(\n instance, \"glide.ui.polaris.theme.variant\", theme[\"style.sys_id\"], user=user_sys_id\n )\n if return_full_response:\n return user_response\n return user_name, user_password, user_sys_id\n\n\ndef set_user_preference(instance: SNowInstance, key: str, value: str, user=None) -> dict:\n \"\"\"\n Set a user preference in the ServiceNow instance\n\n Parameters:\n -----------\n key: str\n The name of the preference\n value: str\n The value of the preference\n user: str\n The sys_id of the user. If None, the preference will be set globally.\n\n Returns:\n --------\n dict\n The preference that was set\n","source_hash":"98bc7caf8445540bb0ebae75e319e2bf9b27fcee24c2302c55ffa20900bd6899","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.user.set_user_preference","uri":"program://WorkArena/function/src.browsergym.workarena.api.user.set_user_preference#L87-L156","kind":"function","name":"set_user_preference","path":"src/browsergym/workarena/api/user.py","language":"python","start_line":87,"end_line":156,"context_start_line":67,"context_end_line":156,"code":" method=\"GET\",\n )[\"result\"][0][\"sys_id\"]\n\n # Give admin permissions\n association_data = {\"user\": user_sys_id, \"role\": role_sys_id}\n table_api_call(\n instance=instance, table=\"sys_user_has_role\", json=association_data, method=\"POST\"\n )\n\n # Randomly pick a UI theme and set it for the user\n themes = get_workarena_theme_variants(instance)\n theme = random.choice(themes)\n set_user_preference(\n instance, \"glide.ui.polaris.theme.variant\", theme[\"style.sys_id\"], user=user_sys_id\n )\n if return_full_response:\n return user_response\n return user_name, user_password, user_sys_id\n\n\ndef set_user_preference(instance: SNowInstance, key: str, value: str, user=None) -> dict:\n \"\"\"\n Set a user preference in the ServiceNow instance\n\n Parameters:\n -----------\n key: str\n The name of the preference\n value: str\n The value of the preference\n user: str\n The sys_id of the user. If None, the preference will be set globally.\n\n Returns:\n --------\n dict\n The preference that was set\n\n \"\"\"\n if user is None:\n # make it global\n user = \"\"\n system = True\n else:\n system = False\n\n # Try to get the preference's sys_id\n preference = table_api_call(\n instance=instance,\n table=\"sys_user_preference\",\n params={\"sysparm_query\": f\"name={key},user={user}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"]\n\n if not preference:\n # ... The preference key doesn't exist, create it\n pref_sysid = \"\"\n method = \"POST\"\n else:\n # ... The preference key exists, update it\n pref_sysid = \"/\" + preference[0][\"sys_id\"]\n method = \"PUT\"\n\n property = table_api_call(\n instance=instance,\n table=f\"sys_user_preference{pref_sysid}\",\n method=method,\n json={\n \"name\": key,\n \"value\": value,\n \"user\": user,\n \"system\": system,\n \"description\": \"Updated by WorkArena\",\n },\n )[\"result\"]\n\n # Verify that the property was updated\n property[\"user\"] = (\n property[\"user\"].get(\"value\") if isinstance(property[\"user\"], dict) else property[\"user\"]\n )\n assert (\n property[\"value\"] == value\n ), f\"Error setting system property {key}, incorrect value {property['value']}, while expecting {value}.\"\n assert (\n property[\"user\"] == user\n ), f\"Error setting system property {key}, incorrect user {property['user']}, while expecting {user}.\"\n assert (\n property[\"system\"] == str(system).lower()\n ), f\"Error setting {key}, incorrect system {property['system']}, while expecting {system}.\"\n\n return property","source_hash":"98bc7caf8445540bb0ebae75e319e2bf9b27fcee24c2302c55ffa20900bd6899","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.requests","uri":"program://WorkArena/module/src.browsergym.workarena.api.requests#L1-L155","kind":"module","name":"src.browsergym.workarena.api.requests","path":"src/browsergym/workarena/api/requests.py","language":"python","start_line":1,"end_line":155,"context_start_line":1,"context_end_line":155,"code":"\"\"\"\nAPI to interact with requests in ServiceNow\n\n\"\"\"\n\nimport json\n\nfrom collections import defaultdict\n\nfrom .utils import SNowInstance, table_api_call, db_delete_from_table\n\n\ndef delete_request(instance: SNowInstance, sys_id: str) -> None:\n \"\"\"\n Deletes a request from an instance along with all its items and their options\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the request to delete\n\n \"\"\"\n # Delete all items\n for item in get_request_items(instance, sys_id):\n # Delete all options for each item\n for option in item[\"options\"].values():\n db_delete_from_table(\n instance,\n option[\"sys_ids\"][\"sc_item_option_mtom\"],\n \"sc_item_option_mtom\",\n )\n db_delete_from_table(instance, option[\"sys_ids\"][\"sc_item_option\"], \"sc_item_option\")\n db_delete_from_table(instance, item[\"sys_id\"], \"sc_req_item\")\n\n # Delete the request\n db_delete_from_table(instance, sys_id, \"sc_request\")\n\n\ndef get_all_requests(instance: SNowInstance, since_minutes: int = 99999999999) -> list:\n \"\"\"\n Retrives a list of all requests from an instance\n\n Parameters:\n -----------\n since_minutes: int\n The number of minutes to look back for requests (used to avoid getting too many requests)\n\n Returns:\n --------\n list\n A list of all requests from an instance (as dicts)\n\n \"\"\"\n # Filter for requests that were created in the time frame\n query = f\"sys_created_on>=javascript:gs.minutesAgoStart({since_minutes})\"\n\n # Get all requests\n requests_ = table_api_call(\n instance, table=\"sc_request\", method=\"GET\", params={\"sysparm_query\": query}\n )[\"result\"]\n\n # For each request, get the items that were ordered\n for request in requests_:\n request[\"items\"] = get_request_items(instance, request[\"sys_id\"])\n\n return requests_\n\n\ndef get_request_by_id(instance: SNowInstance, sysid: str) -> dict:\n \"\"\"\n Get a request by its sys_id\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to get the request from\n sysid: str\n The sys_id of the request to get\n\n Returns:\n --------\n dict\n A dictionary containing the details of the request\n\n \"\"\"\n # Get the request\n request = table_api_call(\n instance,\n table=f\"sc_request\",\n method=\"GET\",\n params={\"sysparm_query\": f\"sys_id={sysid}\"},\n )[\"result\"]\n\n if len(request) == 0:\n return None\n request = request[0]\n\n # Get the items that were ordered\n request[\"items\"] = get_request_items(instance, request[\"sys_id\"])\n\n return request\n\n\ndef get_request_items(instance: SNowInstance, sys_id: str) -> list[dict]:\n \"\"\"\n Get all items that were ordered as part of a request\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the request to get items for\n\n Returns:\n --------\n list\n A list of dicts containing the items\n\n \"\"\"\n # Get all items in the request\n items = table_api_call(\n instance=instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"request={sys_id}\",\n \"sysparm_fields\": \",\".join(\n [\n \"sys_id\",\n \"short_description\",\n \"quantity\",\n ]\n ),\n },\n )[\"result\"]\n\n # For each item, get the options that were selected (if there are any)\n for item in items:\n options = table_api_call(\n instance=instance,\n table=\"sc_item_option_mtom\",\n params={\n \"sysparm_query\": f\"request_item={item['sys_id']}\",\n \"sysparm_fields\": \",\".join(\n [\n \"sc_item_option.value\",\n \"sc_item_option.item_option_new.question_text\",\n ]\n ),\n },\n )[\"result\"]\n item[\"options\"] = {\n opt[\"sc_item_option.item_option_new.question_text\"]: opt[\"sc_item_option.value\"]\n for opt in options\n }\n\n return items","source_hash":"cf6bd04d3926d47474e3f77fa5c7ba8e8a6e37ef8e874814693f9886b55af7ef","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.requests.delete_request","uri":"program://WorkArena/function/src.browsergym.workarena.api.requests.delete_request#L13-L36","kind":"function","name":"delete_request","path":"src/browsergym/workarena/api/requests.py","language":"python","start_line":13,"end_line":36,"context_start_line":1,"context_end_line":56,"code":"\"\"\"\nAPI to interact with requests in ServiceNow\n\n\"\"\"\n\nimport json\n\nfrom collections import defaultdict\n\nfrom .utils import SNowInstance, table_api_call, db_delete_from_table\n\n\ndef delete_request(instance: SNowInstance, sys_id: str) -> None:\n \"\"\"\n Deletes a request from an instance along with all its items and their options\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the request to delete\n\n \"\"\"\n # Delete all items\n for item in get_request_items(instance, sys_id):\n # Delete all options for each item\n for option in item[\"options\"].values():\n db_delete_from_table(\n instance,\n option[\"sys_ids\"][\"sc_item_option_mtom\"],\n \"sc_item_option_mtom\",\n )\n db_delete_from_table(instance, option[\"sys_ids\"][\"sc_item_option\"], \"sc_item_option\")\n db_delete_from_table(instance, item[\"sys_id\"], \"sc_req_item\")\n\n # Delete the request\n db_delete_from_table(instance, sys_id, \"sc_request\")\n\n\ndef get_all_requests(instance: SNowInstance, since_minutes: int = 99999999999) -> list:\n \"\"\"\n Retrives a list of all requests from an instance\n\n Parameters:\n -----------\n since_minutes: int\n The number of minutes to look back for requests (used to avoid getting too many requests)\n\n Returns:\n --------\n list\n A list of all requests from an instance (as dicts)\n\n \"\"\"\n # Filter for requests that were created in the time frame\n query = f\"sys_created_on>=javascript:gs.minutesAgoStart({since_minutes})\"\n","source_hash":"cf6bd04d3926d47474e3f77fa5c7ba8e8a6e37ef8e874814693f9886b55af7ef","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.requests.get_all_requests","uri":"program://WorkArena/function/src.browsergym.workarena.api.requests.get_all_requests#L39-L66","kind":"function","name":"get_all_requests","path":"src/browsergym/workarena/api/requests.py","language":"python","start_line":39,"end_line":66,"context_start_line":19,"context_end_line":86,"code":" sys_id: str\n The sys_id of the request to delete\n\n \"\"\"\n # Delete all items\n for item in get_request_items(instance, sys_id):\n # Delete all options for each item\n for option in item[\"options\"].values():\n db_delete_from_table(\n instance,\n option[\"sys_ids\"][\"sc_item_option_mtom\"],\n \"sc_item_option_mtom\",\n )\n db_delete_from_table(instance, option[\"sys_ids\"][\"sc_item_option\"], \"sc_item_option\")\n db_delete_from_table(instance, item[\"sys_id\"], \"sc_req_item\")\n\n # Delete the request\n db_delete_from_table(instance, sys_id, \"sc_request\")\n\n\ndef get_all_requests(instance: SNowInstance, since_minutes: int = 99999999999) -> list:\n \"\"\"\n Retrives a list of all requests from an instance\n\n Parameters:\n -----------\n since_minutes: int\n The number of minutes to look back for requests (used to avoid getting too many requests)\n\n Returns:\n --------\n list\n A list of all requests from an instance (as dicts)\n\n \"\"\"\n # Filter for requests that were created in the time frame\n query = f\"sys_created_on>=javascript:gs.minutesAgoStart({since_minutes})\"\n\n # Get all requests\n requests_ = table_api_call(\n instance, table=\"sc_request\", method=\"GET\", params={\"sysparm_query\": query}\n )[\"result\"]\n\n # For each request, get the items that were ordered\n for request in requests_:\n request[\"items\"] = get_request_items(instance, request[\"sys_id\"])\n\n return requests_\n\n\ndef get_request_by_id(instance: SNowInstance, sysid: str) -> dict:\n \"\"\"\n Get a request by its sys_id\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to get the request from\n sysid: str\n The sys_id of the request to get\n\n Returns:\n --------\n dict\n A dictionary containing the details of the request\n\n \"\"\"\n # Get the request","source_hash":"cf6bd04d3926d47474e3f77fa5c7ba8e8a6e37ef8e874814693f9886b55af7ef","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.requests.get_request_by_id","uri":"program://WorkArena/function/src.browsergym.workarena.api.requests.get_request_by_id#L69-L101","kind":"function","name":"get_request_by_id","path":"src/browsergym/workarena/api/requests.py","language":"python","start_line":69,"end_line":101,"context_start_line":49,"context_end_line":121,"code":" --------\n list\n A list of all requests from an instance (as dicts)\n\n \"\"\"\n # Filter for requests that were created in the time frame\n query = f\"sys_created_on>=javascript:gs.minutesAgoStart({since_minutes})\"\n\n # Get all requests\n requests_ = table_api_call(\n instance, table=\"sc_request\", method=\"GET\", params={\"sysparm_query\": query}\n )[\"result\"]\n\n # For each request, get the items that were ordered\n for request in requests_:\n request[\"items\"] = get_request_items(instance, request[\"sys_id\"])\n\n return requests_\n\n\ndef get_request_by_id(instance: SNowInstance, sysid: str) -> dict:\n \"\"\"\n Get a request by its sys_id\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to get the request from\n sysid: str\n The sys_id of the request to get\n\n Returns:\n --------\n dict\n A dictionary containing the details of the request\n\n \"\"\"\n # Get the request\n request = table_api_call(\n instance,\n table=f\"sc_request\",\n method=\"GET\",\n params={\"sysparm_query\": f\"sys_id={sysid}\"},\n )[\"result\"]\n\n if len(request) == 0:\n return None\n request = request[0]\n\n # Get the items that were ordered\n request[\"items\"] = get_request_items(instance, request[\"sys_id\"])\n\n return request\n\n\ndef get_request_items(instance: SNowInstance, sys_id: str) -> list[dict]:\n \"\"\"\n Get all items that were ordered as part of a request\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the request to get items for\n\n Returns:\n --------\n list\n A list of dicts containing the items\n\n \"\"\"\n # Get all items in the request\n items = table_api_call(\n instance=instance,","source_hash":"cf6bd04d3926d47474e3f77fa5c7ba8e8a6e37ef8e874814693f9886b55af7ef","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.requests.get_request_items","uri":"program://WorkArena/function/src.browsergym.workarena.api.requests.get_request_items#L104-L155","kind":"function","name":"get_request_items","path":"src/browsergym/workarena/api/requests.py","language":"python","start_line":104,"end_line":155,"context_start_line":84,"context_end_line":155,"code":"\n \"\"\"\n # Get the request\n request = table_api_call(\n instance,\n table=f\"sc_request\",\n method=\"GET\",\n params={\"sysparm_query\": f\"sys_id={sysid}\"},\n )[\"result\"]\n\n if len(request) == 0:\n return None\n request = request[0]\n\n # Get the items that were ordered\n request[\"items\"] = get_request_items(instance, request[\"sys_id\"])\n\n return request\n\n\ndef get_request_items(instance: SNowInstance, sys_id: str) -> list[dict]:\n \"\"\"\n Get all items that were ordered as part of a request\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the request to get items for\n\n Returns:\n --------\n list\n A list of dicts containing the items\n\n \"\"\"\n # Get all items in the request\n items = table_api_call(\n instance=instance,\n table=\"sc_req_item\",\n params={\n \"sysparm_query\": f\"request={sys_id}\",\n \"sysparm_fields\": \",\".join(\n [\n \"sys_id\",\n \"short_description\",\n \"quantity\",\n ]\n ),\n },\n )[\"result\"]\n\n # For each item, get the options that were selected (if there are any)\n for item in items:\n options = table_api_call(\n instance=instance,\n table=\"sc_item_option_mtom\",\n params={\n \"sysparm_query\": f\"request_item={item['sys_id']}\",\n \"sysparm_fields\": \",\".join(\n [\n \"sc_item_option.value\",\n \"sc_item_option.item_option_new.question_text\",\n ]\n ),\n },\n )[\"result\"]\n item[\"options\"] = {\n opt[\"sc_item_option.item_option_new.question_text\"]: opt[\"sc_item_option.value\"]\n for opt in options\n }\n\n return items","source_hash":"cf6bd04d3926d47474e3f77fa5c7ba8e8a6e37ef8e874814693f9886b55af7ef","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.incident","uri":"program://WorkArena/module/src.browsergym.workarena.api.incident#L1-L45","kind":"module","name":"src.browsergym.workarena.api.incident","path":"src/browsergym/workarena/api/incident.py","language":"python","start_line":1,"end_line":45,"context_start_line":1,"context_end_line":45,"code":"from faker import Faker\nfrom ..instance import SNowInstance\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\n\ndef create_incident(\n instance: SNowInstance,\n incident_number: int,\n caller_sys_id: str,\n category: str,\n impact: int,\n urgency: int,\n priority: int,\n incident_hastag: str = None,\n assigned_to: str = None,\n):\n incident_config = {\n \"task_effective_number\": incident_number,\n \"number\": incident_number,\n \"state\": 2,\n \"knowledge\": False,\n \"impact\": impact,\n \"active\": True,\n \"priority\": priority,\n \"caller_id\": caller_sys_id,\n \"short_description\": incident_hastag if incident_hastag else \" \".join(fake.words(5)),\n \"description\": \" \".join(fake.words(10)),\n \"incident_state\": 2,\n \"urgency\": urgency,\n \"severity\": 3,\n \"category\": category,\n }\n if assigned_to:\n incident_config[\"assigned_to\"] = assigned_to\n\n incident_response = table_api_call(\n instance=instance,\n table=\"incident\",\n json=incident_config,\n method=\"POST\",\n )[\"result\"]\n return incident_response","source_hash":"6d56a9b1ed9c07d1f27e04ee8fe20c00904c30fbfb9bda24469cdda689680a7d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.incident.create_incident","uri":"program://WorkArena/function/src.browsergym.workarena.api.incident.create_incident#L9-L45","kind":"function","name":"create_incident","path":"src/browsergym/workarena/api/incident.py","language":"python","start_line":9,"end_line":45,"context_start_line":1,"context_end_line":45,"code":"from faker import Faker\nfrom ..instance import SNowInstance\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\n\ndef create_incident(\n instance: SNowInstance,\n incident_number: int,\n caller_sys_id: str,\n category: str,\n impact: int,\n urgency: int,\n priority: int,\n incident_hastag: str = None,\n assigned_to: str = None,\n):\n incident_config = {\n \"task_effective_number\": incident_number,\n \"number\": incident_number,\n \"state\": 2,\n \"knowledge\": False,\n \"impact\": impact,\n \"active\": True,\n \"priority\": priority,\n \"caller_id\": caller_sys_id,\n \"short_description\": incident_hastag if incident_hastag else \" \".join(fake.words(5)),\n \"description\": \" \".join(fake.words(10)),\n \"incident_state\": 2,\n \"urgency\": urgency,\n \"severity\": 3,\n \"category\": category,\n }\n if assigned_to:\n incident_config[\"assigned_to\"] = assigned_to\n\n incident_response = table_api_call(\n instance=instance,\n table=\"incident\",\n json=incident_config,\n method=\"POST\",\n )[\"result\"]\n return incident_response","source_hash":"6d56a9b1ed9c07d1f27e04ee8fe20c00904c30fbfb9bda24469cdda689680a7d","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.expense_line","uri":"program://WorkArena/module/src.browsergym.workarena.api.expense_line#L1-L89","kind":"module","name":"src.browsergym.workarena.api.expense_line","path":"src/browsergym/workarena/api/expense_line.py","language":"python","start_line":1,"end_line":89,"context_start_line":1,"context_end_line":89,"code":"import json\nimport time\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .cost_center import get_cost_center_sysid\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_expense_line(\n instance: SNowInstance,\n amount: float,\n number: str,\n date: str,\n short_description: str = None,\n expense_hashtag: str = \"\",\n task_sys_id: str = None,\n cost_center_sys_id: str = None,\n summary_type: str = \"run_business\",\n user_sys_id: str = None,\n):\n \"\"\"Create a hardware asset -computer model- and assign it to a user\n Args:\n --------\n instance (SNowInstance):\n The instance to create the hardware asset in\n amount (float):\n The amount of the expense line\n number (str):\n The number of the expense line\n date (str):\n The date of the expense line\n short_description (str):\n The short description of the expense line; if None, a random one will be generated\n expense_hashtag (str):\n The hashtag of the expense line (added to the short description)\n task_sys_id (str):\n The sys id of the task to file the expense line under\n cost_center_sys_id (str):\n The sys id of the cost center to file the expense line under\n summary_type (str):\n The summary type of the expense line (choice of \"run_business\", \"grow_business\", \"transform_business\")\n user_sys_id (str):\n The sys_id of the user to assign the hardware asset to. If None, the hardware asset is not assigned to any user\n Returns:\n --------\n sys_id (str):\n The sys_id of the created expense_line\n expense_line_number (str):\n The number of the created expense_line\n \"\"\"\n if cost_center_sys_id is None:\n # sys_id of the engineering cost center\n cost_center_sys_id = table_api_call(\n instance=instance,\n table=\"cmn_cost_center\",\n params={\"sysparm_query\": \"name=Engineering\"},\n )[\"result\"][0][\"sys_id\"]\n\n if short_description is None:\n short_description = fake.sentence(4)\n\n expense_cfg = {\n \"date\": date,\n \"base_expense\": \"\",\n \"short_description\": short_description + \" \" + expense_hashtag,\n \"summary_type\": summary_type,\n \"summary_type\": \"run_business\",\n \"type\": \"one-time\",\n \"number\": f\"{number}\",\n \"task\": f\"{task_sys_id}\",\n \"state\": \"processed\",\n \"amount\": f\"{amount}\",\n \"cost_center\": f\"{cost_center_sys_id}\",\n \"user\": f\"{user_sys_id}\",\n }\n\n result = table_api_call(\n instance=instance,\n table=\"fm_expense_line\",\n json=expense_cfg,\n method=\"POST\",\n )[\"result\"]\n\n return result[\"sys_id\"], result[\"number\"]","source_hash":"31f22c9e0ca79ae2178200d8b1f5e6a38f386c1573dedc0d64d4ef5c323843c9","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.expense_line.create_expense_line","uri":"program://WorkArena/function/src.browsergym.workarena.api.expense_line.create_expense_line#L14-L89","kind":"function","name":"create_expense_line","path":"src/browsergym/workarena/api/expense_line.py","language":"python","start_line":14,"end_line":89,"context_start_line":1,"context_end_line":89,"code":"import json\nimport time\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .cost_center import get_cost_center_sysid\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_expense_line(\n instance: SNowInstance,\n amount: float,\n number: str,\n date: str,\n short_description: str = None,\n expense_hashtag: str = \"\",\n task_sys_id: str = None,\n cost_center_sys_id: str = None,\n summary_type: str = \"run_business\",\n user_sys_id: str = None,\n):\n \"\"\"Create a hardware asset -computer model- and assign it to a user\n Args:\n --------\n instance (SNowInstance):\n The instance to create the hardware asset in\n amount (float):\n The amount of the expense line\n number (str):\n The number of the expense line\n date (str):\n The date of the expense line\n short_description (str):\n The short description of the expense line; if None, a random one will be generated\n expense_hashtag (str):\n The hashtag of the expense line (added to the short description)\n task_sys_id (str):\n The sys id of the task to file the expense line under\n cost_center_sys_id (str):\n The sys id of the cost center to file the expense line under\n summary_type (str):\n The summary type of the expense line (choice of \"run_business\", \"grow_business\", \"transform_business\")\n user_sys_id (str):\n The sys_id of the user to assign the hardware asset to. If None, the hardware asset is not assigned to any user\n Returns:\n --------\n sys_id (str):\n The sys_id of the created expense_line\n expense_line_number (str):\n The number of the created expense_line\n \"\"\"\n if cost_center_sys_id is None:\n # sys_id of the engineering cost center\n cost_center_sys_id = table_api_call(\n instance=instance,\n table=\"cmn_cost_center\",\n params={\"sysparm_query\": \"name=Engineering\"},\n )[\"result\"][0][\"sys_id\"]\n\n if short_description is None:\n short_description = fake.sentence(4)\n\n expense_cfg = {\n \"date\": date,\n \"base_expense\": \"\",\n \"short_description\": short_description + \" \" + expense_hashtag,\n \"summary_type\": summary_type,\n \"summary_type\": \"run_business\",\n \"type\": \"one-time\",\n \"number\": f\"{number}\",\n \"task\": f\"{task_sys_id}\",\n \"state\": \"processed\",\n \"amount\": f\"{amount}\",\n \"cost_center\": f\"{cost_center_sys_id}\",\n \"user\": f\"{user_sys_id}\",\n }\n\n result = table_api_call(\n instance=instance,\n table=\"fm_expense_line\",\n json=expense_cfg,\n method=\"POST\",\n )[\"result\"]\n\n return result[\"sys_id\"], result[\"number\"]","source_hash":"31f22c9e0ca79ae2178200d8b1f5e6a38f386c1573dedc0d64d4ef5c323843c9","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.category","uri":"program://WorkArena/module/src.browsergym.workarena.api.category#L1-L74","kind":"module","name":"src.browsergym.workarena.api.category","path":"src/browsergym/workarena/api/category.py","language":"python","start_line":1,"end_line":74,"context_start_line":1,"context_end_line":74,"code":"import warnings\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_category(\n instance: SNowInstance,\n list_name: str,\n category_name: str = None,\n) -> list[str]:\n \"\"\"\n NOTE: This function creates a new category in the given list. Because categories are in a drop-down list, adding more\n categories will make the list longer and this will affect the difficulty of the task. Use only if you are certain you know\n what you are doing.\n\n Create a category for a given list\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the category in\n list_name: str\n The name of the list to create the category for (e.g. problem, incident, etc.)\n category_name: str\n The name of the category to create, defaults to a random category name\n\n Returns:\n --------\n category_name, sys_id\n\n \"\"\"\n warnings.warn(\n \"This function creates a new category in the given list. Because categories are in a drop-down list, adding more \"\n \"categories will make the list longer and this will affect the difficulty of the task. Use only if you are certain you know \"\n \"what you are doing.\",\n UserWarning,\n )\n\n if category_name is None:\n category_name = fake.word() + \"-\" + fake.word()\n\n # Create category\n category_data = {\n \"name\": list_name,\n \"element\": \"category\",\n \"value\": category_name,\n }\n result = table_api_call(\n instance=instance,\n table=\"sys_choice\",\n json=category_data,\n method=\"POST\",\n wait_for_record=True,\n )[\"result\"]\n\n sys_id = result[\"sys_id\"]\n\n return category_name, sys_id\n\n\ndef get_categories(instance, list_name):\n \"\"\"Get the name of the categories for a given list name\"\"\"\n categories = table_api_call(\n instance=instance,\n table=\"sys_choice\",\n params={\"sysparm_query\": f\"name={list_name}^element=category\", \"sysparm_fields\": \"value\"},\n )[\"result\"]\n\n return categories","source_hash":"e288b03e745ab3465609d932eface1369bbff4f7c1fc79a19c56bf0c967219f0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.category.create_category","uri":"program://WorkArena/function/src.browsergym.workarena.api.category.create_category#L11-L63","kind":"function","name":"create_category","path":"src/browsergym/workarena/api/category.py","language":"python","start_line":11,"end_line":63,"context_start_line":1,"context_end_line":74,"code":"import warnings\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_category(\n instance: SNowInstance,\n list_name: str,\n category_name: str = None,\n) -> list[str]:\n \"\"\"\n NOTE: This function creates a new category in the given list. Because categories are in a drop-down list, adding more\n categories will make the list longer and this will affect the difficulty of the task. Use only if you are certain you know\n what you are doing.\n\n Create a category for a given list\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to create the category in\n list_name: str\n The name of the list to create the category for (e.g. problem, incident, etc.)\n category_name: str\n The name of the category to create, defaults to a random category name\n\n Returns:\n --------\n category_name, sys_id\n\n \"\"\"\n warnings.warn(\n \"This function creates a new category in the given list. Because categories are in a drop-down list, adding more \"\n \"categories will make the list longer and this will affect the difficulty of the task. Use only if you are certain you know \"\n \"what you are doing.\",\n UserWarning,\n )\n\n if category_name is None:\n category_name = fake.word() + \"-\" + fake.word()\n\n # Create category\n category_data = {\n \"name\": list_name,\n \"element\": \"category\",\n \"value\": category_name,\n }\n result = table_api_call(\n instance=instance,\n table=\"sys_choice\",\n json=category_data,\n method=\"POST\",\n wait_for_record=True,\n )[\"result\"]\n\n sys_id = result[\"sys_id\"]\n\n return category_name, sys_id\n\n\ndef get_categories(instance, list_name):\n \"\"\"Get the name of the categories for a given list name\"\"\"\n categories = table_api_call(\n instance=instance,\n table=\"sys_choice\",\n params={\"sysparm_query\": f\"name={list_name}^element=category\", \"sysparm_fields\": \"value\"},\n )[\"result\"]\n\n return categories","source_hash":"e288b03e745ab3465609d932eface1369bbff4f7c1fc79a19c56bf0c967219f0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:src.browsergym.workarena.api.category.get_categories","uri":"program://WorkArena/function/src.browsergym.workarena.api.category.get_categories#L66-L74","kind":"function","name":"get_categories","path":"src/browsergym/workarena/api/category.py","language":"python","start_line":66,"end_line":74,"context_start_line":46,"context_end_line":74,"code":"\n # Create category\n category_data = {\n \"name\": list_name,\n \"element\": \"category\",\n \"value\": category_name,\n }\n result = table_api_call(\n instance=instance,\n table=\"sys_choice\",\n json=category_data,\n method=\"POST\",\n wait_for_record=True,\n )[\"result\"]\n\n sys_id = result[\"sys_id\"]\n\n return category_name, sys_id\n\n\ndef get_categories(instance, list_name):\n \"\"\"Get the name of the categories for a given list name\"\"\"\n categories = table_api_call(\n instance=instance,\n table=\"sys_choice\",\n params={\"sysparm_query\": f\"name={list_name}^element=category\", \"sysparm_fields\": \"value\"},\n )[\"result\"]\n\n return categories","source_hash":"e288b03e745ab3465609d932eface1369bbff4f7c1fc79a19c56bf0c967219f0","truncated":false} {"repo_id":"WorkArena","entity_id":"py:scripts.extract_finetuning_traces","uri":"program://WorkArena/module/scripts.extract_finetuning_traces#L1-L131","kind":"module","name":"scripts.extract_finetuning_traces","path":"scripts/extract_finetuning_traces.py","language":"python","start_line":1,"end_line":131,"context_start_line":1,"context_end_line":131,"code":"\"\"\"\nA demonstration of how observation/action traces can be extracted\nfor WorkArena tasks without modifying the task code.\n\nAuthor: Alexandre Drouin (alexandre.drouin@servicenow.com)\n\nNotes:\n- This approach relies on monkey patching the playwright actions to log the actions and observations.\n It has not been tested for parallel execution. It might work with multiprocessing, but it will for\n sure not work with multithreading.\n\n\"\"\"\n\nimport importlib\nimport logging\nimport os\nimport pickle\nimport playwright.sync_api as playwright_sync\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS\nfrom collections import defaultdict\nfrom tenacity import retry, stop_after_attempt, wait_fixed\nfrom time import time\n\n\nN_PER_TASK = 10\n\n\ndef monkey_patch_playwright(observation_callback, trace_storage):\n \"\"\"\n A function that overrides the default playwright actions to log the actions and observations.\n\n Parameters:\n ------------\n observation_callback: callable\n A function that returns the observation of the environment.\n trace_storage: list\n A list to store the trace of the actions and observations.\n These will be appended in-place.\n\n \"\"\"\n\n def wrapper(func, interface):\n def wrapped(*args, **kwargs):\n # Get the observation\n obs = observation_callback()\n\n # Get the BID of the element on which we are acting.\n if interface.__name__ == \"Locator\":\n # Get the locator\n locator = args[0]\n # Get the BID\n bid = locator.element_handle().evaluate('(el) => el.getAttribute(\"bid\")')\n elif interface.__name__ == \"Keyboard\":\n # Get the BID of the element\n bid = \"keyboard\"\n else:\n # Get the BID of the element\n bid = args[0].evaluate('(el) => el.getAttribute(\"bid\")')\n\n logging.info(f\"Action: {func.__name__} BID: {bid} -- Args: {args[1:]} {kwargs}\")\n trace_storage.append(\n {\n \"obs\": obs,\n \"action\": func.__name__,\n \"args\": args[1:],\n \"kwargs\": kwargs,\n \"bid\": bid,\n \"time\": time(),\n }\n )\n\n # Resume action\n return func(*args, **kwargs)\n\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))\ndef extract_trace(task_cls, headless=True):\n \"\"\"\n Extracts the trace of actions and observations for a given task.\n\n Parameters:\n ------------\n task_cls: class\n The class of the task to extract the trace from.\n\n \"\"\"\n # Instantiate a new environment\n env = BrowserEnv(task_entrypoint=task_cls, headless=headless, slow_mo=1000)\n\n # Setup customized tracing\n trace = []\n monkey_patch_playwright(observation_callback=env._get_obs, trace_storage=trace)\n\n env.reset()\n env.task.cheat(env.page, env.chat.messages)\n env.close()\n\n return trace\n\n\nif __name__ == \"__main__\":\n os.makedirs(\"trace_profiling\", exist_ok=True)\n\n task_traces = defaultdict(list)\n for task in ALL_WORKARENA_TASKS:\n print(\"Task:\", task)\n for i in range(N_PER_TASK):\n print(f\"Extracting trace {i+1}/{N_PER_TASK}\")\n trace = extract_trace(task, headless=True)\n task_traces[task].append(trace)\n\n pickle.dump(task_traces, open(\"trace_profiling/task_traces.pkl\", \"wb\"))","source_hash":"076442bd033a07c06f90d578a41a35f67c11cc26f25dd7d23b3b4e694930c05c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:scripts.extract_finetuning_traces.monkey_patch_playwright","uri":"program://WorkArena/function/scripts.extract_finetuning_traces.monkey_patch_playwright#L30-L92","kind":"function","name":"monkey_patch_playwright","path":"scripts/extract_finetuning_traces.py","language":"python","start_line":30,"end_line":92,"context_start_line":10,"context_end_line":112,"code":" sure not work with multithreading.\n\n\"\"\"\n\nimport importlib\nimport logging\nimport os\nimport pickle\nimport playwright.sync_api as playwright_sync\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS\nfrom collections import defaultdict\nfrom tenacity import retry, stop_after_attempt, wait_fixed\nfrom time import time\n\n\nN_PER_TASK = 10\n\n\ndef monkey_patch_playwright(observation_callback, trace_storage):\n \"\"\"\n A function that overrides the default playwright actions to log the actions and observations.\n\n Parameters:\n ------------\n observation_callback: callable\n A function that returns the observation of the environment.\n trace_storage: list\n A list to store the trace of the actions and observations.\n These will be appended in-place.\n\n \"\"\"\n\n def wrapper(func, interface):\n def wrapped(*args, **kwargs):\n # Get the observation\n obs = observation_callback()\n\n # Get the BID of the element on which we are acting.\n if interface.__name__ == \"Locator\":\n # Get the locator\n locator = args[0]\n # Get the BID\n bid = locator.element_handle().evaluate('(el) => el.getAttribute(\"bid\")')\n elif interface.__name__ == \"Keyboard\":\n # Get the BID of the element\n bid = \"keyboard\"\n else:\n # Get the BID of the element\n bid = args[0].evaluate('(el) => el.getAttribute(\"bid\")')\n\n logging.info(f\"Action: {func.__name__} BID: {bid} -- Args: {args[1:]} {kwargs}\")\n trace_storage.append(\n {\n \"obs\": obs,\n \"action\": func.__name__,\n \"args\": args[1:],\n \"kwargs\": kwargs,\n \"bid\": bid,\n \"time\": time(),\n }\n )\n\n # Resume action\n return func(*args, **kwargs)\n\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))\ndef extract_trace(task_cls, headless=True):\n \"\"\"\n Extracts the trace of actions and observations for a given task.\n\n Parameters:\n ------------\n task_cls: class\n The class of the task to extract the trace from.\n\n \"\"\"\n # Instantiate a new environment\n env = BrowserEnv(task_entrypoint=task_cls, headless=headless, slow_mo=1000)\n\n # Setup customized tracing\n trace = []\n monkey_patch_playwright(observation_callback=env._get_obs, trace_storage=trace)\n","source_hash":"076442bd033a07c06f90d578a41a35f67c11cc26f25dd7d23b3b4e694930c05c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:scripts.extract_finetuning_traces.extract_trace","uri":"program://WorkArena/function/scripts.extract_finetuning_traces.extract_trace#L96-L117","kind":"function","name":"extract_trace","path":"scripts/extract_finetuning_traces.py","language":"python","start_line":96,"end_line":117,"context_start_line":76,"context_end_line":131,"code":"\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))\ndef extract_trace(task_cls, headless=True):\n \"\"\"\n Extracts the trace of actions and observations for a given task.\n\n Parameters:\n ------------\n task_cls: class\n The class of the task to extract the trace from.\n\n \"\"\"\n # Instantiate a new environment\n env = BrowserEnv(task_entrypoint=task_cls, headless=headless, slow_mo=1000)\n\n # Setup customized tracing\n trace = []\n monkey_patch_playwright(observation_callback=env._get_obs, trace_storage=trace)\n\n env.reset()\n env.task.cheat(env.page, env.chat.messages)\n env.close()\n\n return trace\n\n\nif __name__ == \"__main__\":\n os.makedirs(\"trace_profiling\", exist_ok=True)\n\n task_traces = defaultdict(list)\n for task in ALL_WORKARENA_TASKS:\n print(\"Task:\", task)\n for i in range(N_PER_TASK):\n print(f\"Extracting trace {i+1}/{N_PER_TASK}\")\n trace = extract_trace(task, headless=True)\n task_traces[task].append(trace)\n\n pickle.dump(task_traces, open(\"trace_profiling/task_traces.pkl\", \"wb\"))","source_hash":"076442bd033a07c06f90d578a41a35f67c11cc26f25dd7d23b3b4e694930c05c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:scripts.extract_finetuning_traces.wrapper","uri":"program://WorkArena/function/scripts.extract_finetuning_traces.wrapper#L44-L77","kind":"function","name":"wrapper","path":"scripts/extract_finetuning_traces.py","language":"python","start_line":44,"end_line":77,"context_start_line":24,"context_end_line":97,"code":"from time import time\n\n\nN_PER_TASK = 10\n\n\ndef monkey_patch_playwright(observation_callback, trace_storage):\n \"\"\"\n A function that overrides the default playwright actions to log the actions and observations.\n\n Parameters:\n ------------\n observation_callback: callable\n A function that returns the observation of the environment.\n trace_storage: list\n A list to store the trace of the actions and observations.\n These will be appended in-place.\n\n \"\"\"\n\n def wrapper(func, interface):\n def wrapped(*args, **kwargs):\n # Get the observation\n obs = observation_callback()\n\n # Get the BID of the element on which we are acting.\n if interface.__name__ == \"Locator\":\n # Get the locator\n locator = args[0]\n # Get the BID\n bid = locator.element_handle().evaluate('(el) => el.getAttribute(\"bid\")')\n elif interface.__name__ == \"Keyboard\":\n # Get the BID of the element\n bid = \"keyboard\"\n else:\n # Get the BID of the element\n bid = args[0].evaluate('(el) => el.getAttribute(\"bid\")')\n\n logging.info(f\"Action: {func.__name__} BID: {bid} -- Args: {args[1:]} {kwargs}\")\n trace_storage.append(\n {\n \"obs\": obs,\n \"action\": func.__name__,\n \"args\": args[1:],\n \"kwargs\": kwargs,\n \"bid\": bid,\n \"time\": time(),\n }\n )\n\n # Resume action\n return func(*args, **kwargs)\n\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))\ndef extract_trace(task_cls, headless=True):\n \"\"\"","source_hash":"076442bd033a07c06f90d578a41a35f67c11cc26f25dd7d23b3b4e694930c05c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:scripts.extract_finetuning_traces.wrapped","uri":"program://WorkArena/function/scripts.extract_finetuning_traces.wrapped#L45-L75","kind":"function","name":"wrapped","path":"scripts/extract_finetuning_traces.py","language":"python","start_line":45,"end_line":75,"context_start_line":25,"context_end_line":95,"code":"\n\nN_PER_TASK = 10\n\n\ndef monkey_patch_playwright(observation_callback, trace_storage):\n \"\"\"\n A function that overrides the default playwright actions to log the actions and observations.\n\n Parameters:\n ------------\n observation_callback: callable\n A function that returns the observation of the environment.\n trace_storage: list\n A list to store the trace of the actions and observations.\n These will be appended in-place.\n\n \"\"\"\n\n def wrapper(func, interface):\n def wrapped(*args, **kwargs):\n # Get the observation\n obs = observation_callback()\n\n # Get the BID of the element on which we are acting.\n if interface.__name__ == \"Locator\":\n # Get the locator\n locator = args[0]\n # Get the BID\n bid = locator.element_handle().evaluate('(el) => el.getAttribute(\"bid\")')\n elif interface.__name__ == \"Keyboard\":\n # Get the BID of the element\n bid = \"keyboard\"\n else:\n # Get the BID of the element\n bid = args[0].evaluate('(el) => el.getAttribute(\"bid\")')\n\n logging.info(f\"Action: {func.__name__} BID: {bid} -- Args: {args[1:]} {kwargs}\")\n trace_storage.append(\n {\n \"obs\": obs,\n \"action\": func.__name__,\n \"args\": args[1:],\n \"kwargs\": kwargs,\n \"bid\": bid,\n \"time\": time(),\n }\n )\n\n # Resume action\n return func(*args, **kwargs)\n\n return wrapped\n\n # Interfaces and actions we want to monkey patch\n importlib.reload(playwright_sync)\n from playwright.sync_api import Page, Frame, Locator, Keyboard, ElementHandle\n\n # TODO: Make sure the list of interfaces and actions is exhaustive\n # It covers all that is used in WorkArena cheats as of April 11, 2024\n interfaces = [Page, Frame, Locator, Keyboard, ElementHandle]\n actions = [\"click\", \"select_option\", \"set_checked\", \"fill\", \"press\", \"type\", \"down\", \"up\"]\n\n for interface in interfaces:\n for action in actions:\n if hasattr(interface, action):\n setattr(interface, action, wrapper(getattr(interface, action), interface))\n print(f\"Monkey patched {interface.__name__}.{action}\")\n\n\n@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))","source_hash":"076442bd033a07c06f90d578a41a35f67c11cc26f25dd7d23b3b4e694930c05c","truncated":false} {"repo_id":"WorkArena","entity_id":"py:scripts.make_human_eval_curriculum","uri":"program://WorkArena/module/scripts.make_human_eval_curriculum#L1-L54","kind":"module","name":"scripts.make_human_eval_curriculum","path":"scripts/make_human_eval_curriculum.py","language":"python","start_line":1,"end_line":54,"context_start_line":1,"context_end_line":54,"code":"\"\"\"\nHuman Evaluation - Create the curriculum for all humans\n\nNote: This script separates the tasks among 14 evaluators.\n A 15th one was added subsequently to solve tasks that\n had not been completed by the initial 14 (e.g., due\n to some issues with the annotation UI).\n\n\"\"\"\n\nimport random\n\nfrom browsergym.workarena import get_all_tasks_humans\n\n\ntasks_l2 = get_all_tasks_humans(filter=\"l2\", meta_seed=42)\ntasks_l3 = get_all_tasks_humans(filter=\"l3\", meta_seed=42)\n\ntasks = tasks_l2 + tasks_l3\nrandom.shuffle(tasks)\n\nannotators = [\n \"darwiche\",\n \"parikh\",\n \"marchand\",\n \"paquet\",\n \"nayak\",\n \"huang\",\n \"subbaraj\",\n \"williams\",\n \"li\",\n \"marcotte\",\n \"rancourt\",\n \"prince_tremblay\",\n \"ashok\",\n \"bajaj\",\n]\nrandom.shuffle(annotators)\n\nprint(\"Number of tasks: \", len(tasks))\nprint(\"Number of annotators: \", len(annotators))\n\ntasks_by_annotator = {}\nn_base_assignment = len(tasks) // len(annotators)\nn_extra_assignment = len(tasks) % len(annotators)\nfor i, annotator in enumerate(annotators):\n n_assignments = n_base_assignment + (1 if i < n_extra_assignment else 0)\n tasks_by_annotator[annotator] = tasks[:n_assignments]\n tasks = tasks[n_assignments:]\n print(f\"{annotator}: {n_assignments}\")\n\n with open(f\"{annotator}.tasks\", \"w\") as f:\n for task in tasks_by_annotator[annotator]:\n f.write(f\"{task[0].__name__},{task[1]}\\n\")","source_hash":"df7880bbaa73cee59cf9cb52bfd0294adac2ed5013dca5eb2b882f352d31bd14","truncated":false} {"repo_id":"WorkArena","entity_id":"file:make_human_eval_curriculum.py","uri":"program://WorkArena/file/make_human_eval_curriculum.py","kind":"file","name":"make_human_eval_curriculum.py","path":"make_human_eval_curriculum.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import random\n\nfrom browsergym.workarena import get_all_tasks_humans\n\n\ntasks_l2 = get_all_tasks_humans(filter=\"l2\", meta_seed=42)\ntasks_l3 = get_all_tasks_humans(filter=\"l3\", meta_seed=42)\n\ntasks = tasks_l2 + tasks_l3\nrandom.shuffle(tasks)\n\nannotators = [\n \"darwiche\",\n \"parikh\",\n \"marchand\",\n \"paquet\",\n \"nayal\",\n \"huang\",\n \"subbaraj\",\n \"williams\",\n \"li\",","source_hash":"1f7ccff0b33ab5c2d69833890944dcb13b14ac9e898372ca156638b7b6c4128b","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_utils.py","uri":"program://WorkArena/file/tests/test_utils.py","kind":"file","name":"tests/test_utils.py","path":"tests/test_utils.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.utils import ui_login, url_login\n\n\n@pytest.mark.parametrize(\"login_func\", [ui_login, url_login])\ndef test_login_correct_credentials(login_func, page: Page):\n \"\"\"\n Test logging into the instance with the correct credentials\n\n \"\"\"\n # Log in with correct credentials\n instance = SNowInstance()\n login_func(instance=instance, page=page)\n","source_hash":"5252b4090cc44cfacee58149af6f716acd0ac364ed5805cb264964cb7d17ff3e","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_compositional_utils.py","uri":"program://WorkArena/file/tests/test_compositional_utils.py","kind":"file","name":"tests/test_compositional_utils.py","path":"tests/test_compositional_utils.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from copy import deepcopy\nimport json\nimport numpy as np\nimport pytest\n\nfrom browsergym.workarena.tasks.compositional.utils.knapsack import KnapsackInstanceGenarator\nfrom browsergym.workarena.tasks.compositional.utils.infeasible_configs import (\n get_infeasible_form_config,\n get_infeasible_service_catalog_config,\n get_infeasible_filter_config,\n get_infeasible_sort_config,\n)\nfrom browsergym.workarena.config import (\n CREATE_USER_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n FILTER_USER_LIST_CONFIG_PATH,\n SORT_USER_LIST_CONFIG_PATH,\n)\n\n\n@pytest.mark.parametrize(","source_hash":"cc8b41d48bbadc4534d35bffce3669ce72f838b210224f0577c63c9a7eab58c4","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_task_general.py","uri":"program://WorkArena/file/tests/test_task_general.py","kind":"file","name":"tests/test_task_general.py","path":"tests/test_task_general.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport json\nimport logging\nimport pickle\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\n\nfrom browsergym.workarena import ATOMIC_TASKS\n\n\n@retry(\n stop=stop_after_attempt(5),","source_hash":"4c38cb8bc12dc807c183f4bfdf8783bbc9c07fb1724f60b3470079c09ccaae22","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_task_setup.py","uri":"program://WorkArena/file/tests/test_task_setup.py","kind":"file","name":"tests/test_task_setup.py","path":"tests/test_task_setup.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport pytest\nimport json\nimport logging\nimport random\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena.config import ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import OrderAppleWatchTask\n\n\n@retry(","source_hash":"4e5551b1de660838ff5af8b8c2cab3675f5247b19a7ddb9ba53f756eaa789368","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_compositional.py","uri":"program://WorkArena/file/tests/test_compositional.py","kind":"file","name":"tests/test_compositional.py","path":"tests/test_compositional.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport logging\n\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena import ALL_COMPOSITIONAL_TASKS, get_all_tasks_agents\n\nAGENT_L2_SAMPLED_SET = get_all_tasks_agents(filter=\"l2\")\n\nAGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS = [sampled_set[0] for sampled_set in AGENT_L2_SAMPLED_SET], [\n sampled_set[1] for sampled_set in AGENT_L2_SAMPLED_SET\n]","source_hash":"8dead70013571e730165285f0cebcec54f7e0ad2daac826ab412b3e1718d8b10","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_validate.py","uri":"program://WorkArena/file/tests/test_validate.py","kind":"file","name":"tests/test_validate.py","path":"tests/test_validate.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport pytest\nimport json\nimport logging\nimport random\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena.config import ORDER_APPLE_WATCH_TASK_CONFIG_PATH\n\nfrom browsergym.workarena.tasks.service_catalog import OrderAppleWatchTask\nfrom browsergym.workarena.tasks.scripts.validate import validate_configs\n\n\n@retry(","source_hash":"138d4862430c4d257eb804c0ffa1f736f1c24084202f313e536e25109c07cb76","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_random_config_generation.py","uri":"program://WorkArena/file/tests/test_random_config_generation.py","kind":"file","name":"tests/test_random_config_generation.py","path":"tests/test_random_config_generation.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport json\nimport logging\nimport pickle\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\n\nfrom browsergym.workarena.tasks.form import (\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,","source_hash":"9f0ef34db444b4c05ba4f0dc8da685508f6faf715a90abb2420d8e6ca1dae05f","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_snow_instance.py","uri":"program://WorkArena/file/tests/test_snow_instance.py","kind":"file","name":"tests/test_snow_instance.py","path":"tests/test_snow_instance.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTest that the ServiceNow instance is reachable and that the credentials are correct\n\n\"\"\"\n\nimport pytest\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\n\nfrom playwright.sync_api import Page\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.utils import ui_login\n\n\ndef test_check_is_reachable():\n \"\"\"\n Test that the ServiceNow instance is reachable\n\n \"\"\"","source_hash":"9dca26d12894068c3708ceee65556c0650474fecf03fb2a1cd84cb41ed5ab204","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/utils.py","uri":"program://WorkArena/file/tests/utils.py","kind":"file","name":"tests/utils.py","path":"tests/utils.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":13,"code":"import browsergym.core\nimport logging\nimport playwright.sync_api\nimport pytest\n\n\n# setup code, executed ahead of first test\n@pytest.fixture(scope=\"session\", autouse=True)\ndef setup_playwright(playwright: playwright.sync_api.Playwright):\n # bugfix: re-use pytest-playwright's playwright instance in browsergym\n # https://github.com/microsoft/playwright-python/issues/2053\n browsergym.core._set_global_playwright(playwright)\n logging.info(\"Browsergym is using the playwright instance provided by pytest-playwright.\")","source_hash":"e86ea963482bc9b60610380eb17a5289a6989cf2cad509f0245eb3ed6023c11d","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_api.py","uri":"program://WorkArena/file/tests/test_api.py","kind":"file","name":"tests/test_api.py","path":"tests/test_api.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import numpy as np\nimport pytest\nimport random\n\nfrom time import sleep\n\nfrom browsergym.workarena.instance import SNowInstance\nfrom browsergym.workarena.api.utils import table_api_call\nfrom browsergym.workarena.api.user import create_user, set_user_preference\n\n\n@pytest.mark.parametrize(\"system\", [True, False])\ndef test_set_user_preference(system):\n admin_instance = SNowInstance()\n\n # Create a user to get a sys_id\n if not system:\n uname, pwd, sysid = create_user(SNowInstance())\n user_instance = SNowInstance(snow_credentials=(uname, pwd))\n user = sysid\n else:","source_hash":"b5b5c97cfc4898ce304231bcdc0002e7242067ca2b99c14451a9c646d5cc9466","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_task_from_config.py","uri":"program://WorkArena/file/tests/test_task_from_config.py","kind":"file","name":"tests/test_task_from_config.py","path":"tests/test_task_from_config.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTests that are not specific to any particular kind of task.\n\n\"\"\"\n\nimport pytest\nimport json\nimport logging\nimport random\n\n# bugfix: use same playwright instance in browsergym and pytest\nfrom utils import setup_playwright\nfrom playwright.sync_api import Page, TimeoutError\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom browsergym.workarena.config import (\n # navigation tasks\n ALL_MENU_PATH,\n IMPERSONATION_CONFIG_PATH,\n # form tasks\n CREATE_CHANGE_REQUEST_CONFIG_PATH,\n CREATE_HARDWARE_CONFIG_PATH,","source_hash":"93ab706a8739729d28edb6f8bed9a25568412315c56e4fbde873a76bd5bc8b54","truncated":false} {"repo_id":"WorkArena","entity_id":"file:tests/test_filter_list_task.py","uri":"program://WorkArena/file/tests/test_filter_list_task.py","kind":"file","name":"tests/test_filter_list_task.py","path":"tests/test_filter_list_task.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import pytest\nfrom playwright.sync_api import Page\nfrom browsergym.workarena.tasks.list import FilterIncidentListTask\n\n\n# These are all the same ways to express the same filter query (empty string) in ServiceNow.\n@pytest.mark.parametrize(\n \"query\",\n [\n \"assigned_toEMPTYSTRING^short_descriptionISEMPTY^description=This is a beautiful incident\",\n \"assigned_toISEMPTY^short_descriptionEMPTYSTRING^description=This is a beautiful incident^\",\n \"assigned_toISEMPTY^short_descriptionISEMPTY^description=This is a beautiful incident\",\n \"assigned_toEMPTYSTRING^short_descriptionEMPTYSTRING^description=This is a beautiful incident^\",\n \"assigned_to=^short_description=^description=This is a beautiful incident\",\n ],\n)\n@pytest.mark.slow\ndef test_validate_filter_list_task(page: Page, query):\n fixed_config = {\n \"filter_columns\": [\n \"short_description\",","source_hash":"dbcf38e837ea0255a0b0626633ee622a4a912d7a310f437fb1dc44c984cb6102","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/wa_action_traces.py","uri":"program://WorkArena/file/src/wa_action_traces.py","kind":"file","name":"src/wa_action_traces.py","path":"src/wa_action_traces.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nA demonstration of how action traces (with observations) can be extracted\nfor WorkArena tasks without modifying the task code.\n\nAuthor: Alexandre Drouin (alexandre.drouin@servicenow.com)\n\nNotes:\n- This approach relies on monkey patching the playwright actions to log the actions and observations.\n It has not been tested for parallel execution. It might work with multiprocessing, but it will for\n sure not work with multithreading.\n\n\"\"\"\n\nimport importlib\nimport logging\nimport os\nimport pickle\nimport playwright.sync_api as playwright_sync\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS","source_hash":"1054d7dd5f1d54040e1490e1641067ca454306ef20f9ff184b20114b1c52e378","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/workarena_test.py","uri":"program://WorkArena/file/src/workarena_test.py","kind":"file","name":"src/workarena_test.py","path":"src/workarena_test.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import get_all_tasks_agents\n\nAGENT_L2_SAMPLED_SET = get_all_tasks_agents(filter=\"l2\")\n\nAGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS = [sampled_set[0] for sampled_set in AGENT_L2_SAMPLED_SET], [\n sampled_set[1] for sampled_set in AGENT_L2_SAMPLED_SET\n]\nfrom time import sleep\n\nfor task, seed in zip(AGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS):\n print(\"Task:\", task)\n\n # Instantiate a new environment\n env = BrowserEnv(task_entrypoint=task, headless=False, slow_mo=1000)\n env.reset()\n\n # Cheat functions use Playwright to automatically solve the task\n env.chat.add_message(role=\"assistant\", msg=\"On it. Please wait...\")\n\n for i in range(len(env.task)):","source_hash":"df01d22c5f230a99b5ac148770824ab29ba8f81799b5091383f31016af20c1aa","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/config.py","uri":"program://WorkArena/file/src/browsergym/workarena/config.py","kind":"file","name":"src/browsergym/workarena/config.py","path":"src/browsergym/workarena/config.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from importlib import resources\nfrom json import load as json_load\nfrom os.path import exists\n\nfrom ..workarena import data_files\nfrom ..workarena.tasks import utils\n\n# ServiceNow configuration\nSNOW_DATA_LOOKBACK_MINUTES = 5\nSNOW_BROWSER_TIMEOUT = 30000 # Milliseconds\nSNOW_JS_UTILS_FILEPATH = str(resources.files(utils).joinpath(\"js_utils.js\"))\nSNOW_SUPPORTED_RELEASES = [\"washingtondc\"]\n\n# Path to the Menu navigation task configuration\nALL_MENU_PATH = str(resources.files(data_files).joinpath(\"task_configs/all_menu.json\"))\n\n# Path to the dashboard/report retrieval task configurations\nDASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH = str(\n resources.files(data_files).joinpath(\"task_configs/dashboard_retrieval_minmax_task.json\")\n)\nDASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH = str(","source_hash":"166c78b25dc1d447b69b67c69e711825fb10d1390257455d2a1359fa0372b515","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/instance.py","uri":"program://WorkArena/file/src/browsergym/workarena/instance.py","kind":"file","name":"src/browsergym/workarena/instance.py","path":"src/browsergym/workarena/instance.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport os\nimport requests\nimport re\n\nfrom playwright.sync_api import sync_playwright\nfrom typing import Optional\n\nfrom .config import SNOW_BROWSER_TIMEOUT, REPORT_FILTER_PROPERTY\n\n\nclass SNowInstance:\n \"\"\"\n Utility class to access a ServiceNow instance.\n\n \"\"\"\n\n def __init__(\n self,\n snow_url: Optional[str] = None,\n snow_credentials: Optional[tuple[str, str]] = None,","source_hash":"a4b95806b2aef860b060fcdf60edb0d0161cdaefe7e6332ddc765da699420f8d","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/install.py","uri":"program://WorkArena/file/src/browsergym/workarena/install.py","kind":"file","name":"src/browsergym/workarena/install.py","path":"src/browsergym/workarena/install.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import html\nimport json\nimport logging\nimport re\nimport tenacity\n\nfrom datetime import datetime\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom requests import HTTPError\nfrom time import sleep\n\nfrom .api.system_properties import get_sys_property, set_sys_property\nfrom .api.ui_themes import get_workarena_theme_variants\nfrom .api.user import create_user\nfrom .api.utils import table_api_call, table_column_info\nfrom .config import (\n # for knowledge base setup\n KB_FILEPATH,\n KB_NAME,\n PROTOCOL_KB_FILEPATH,","source_hash":"0fd98c8e65756ca0e4d0999ca13bd54988d08dc1ec00ffd6a1a7d20334b4dd8c","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/__init__.py","uri":"program://WorkArena/file/src/browsergym/workarena/__init__.py","kind":"file","name":"src/browsergym/workarena/__init__.py","path":"src/browsergym/workarena/__init__.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"__version__ = \"0.4.4\"\n\nimport inspect\nfrom logging import warning\n\nimport numpy as np\nfrom browsergym.core.registration import register_task\n\nfrom .tasks.comp_building_block import CompositionalBuildingBlockTask\nfrom .tasks.compositional import (\n AGENT_CURRICULUM_L2,\n AGENT_CURRICULUM_L3,\n ALL_COMPOSITIONAL_TASKS,\n ALL_COMPOSITIONAL_TASKS_L2,\n ALL_COMPOSITIONAL_TASKS_L3,\n HUMAN_CURRICULUM_L2,\n HUMAN_CURRICULUM_L3,\n)\nfrom .tasks.compositional.base import CompositionalTask, HumanEvalTask\nfrom .tasks.compositional.update_task import __TASKS__ as UPDATE_TASKS\nfrom .tasks.dashboard import __TASKS__ as DASHBOARD_TASKS","source_hash":"82abf1fd2570ab7d4253e4f55e834ff440d9b238af5203025d2ee56c7fee73ce","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/utils.py","uri":"program://WorkArena/file/src/browsergym/workarena/utils.py","kind":"file","name":"src/browsergym/workarena/utils.py","path":"src/browsergym/workarena/utils.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nGeneral utiilty functions\n\n\"\"\"\n\nimport playwright.sync_api\n\nfrom browsergym.workarena.instance import SNowInstance\n\nfrom urllib import parse\n\n\ndef impersonate_user(username: str, page: playwright.sync_api.Page):\n \"\"\"\n Impersonate a user in the ServiceNow interface\n\n Parameters:\n -----------\n username: str\n The username of the user to impersonate\n page: playwright.sync_api.Page","source_hash":"983e91a95b9afa6d7e98a3354461a5504bb5b3aba7d1923d6b96533cdee0d616","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/human_eval/tool.py","uri":"program://WorkArena/file/src/browsergym/workarena/human_eval/tool.py","kind":"file","name":"src/browsergym/workarena/human_eval/tool.py","path":"src/browsergym/workarena/human_eval/tool.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nWorkArena Human Evaluation Tool\n\nKnown issues:\n * Blocking page interaction: We can't block loading until validation is done because some validation\n functions require the page to be loaded. This means the user might act\n while validation is ongoing. However, they would need to be very quick to\n cause issues.\n\n\"\"\"\n\nimport argparse\nimport json\nimport logging\nimport os\nimport random\nimport tenacity\n\nfrom time import sleep, time\n\nfrom browsergym.core.env import BrowserEnv","source_hash":"4b03ea02b367bc478e3cb4607a6ea4c25f21a37e39a3ed5fded39c3d103ced4d","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/base.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/base.py","kind":"file","name":"src/browsergym/workarena/tasks/base.py","path":"src/browsergym/workarena/tasks/base.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nA bunch of base classes\n\n\"\"\"\n\nimport logging\n\nimport numpy as np\nimport playwright.sync_api\n\nfrom abc import ABC, abstractmethod\nfrom copy import deepcopy\nfrom typing import List, Optional, Tuple\nfrom uuid import uuid4\nfrom urllib import parse\n\nfrom browsergym.core.task import AbstractBrowserTask\nfrom ..api.user import create_user\nfrom ..api.utils import table_api_call\nfrom ..config import SNOW_BROWSER_TIMEOUT, SNOW_JS_UTILS_FILEPATH\nfrom ..utils import url_login","source_hash":"22487f03923dffd69c1c540272754c127941837bb7407403d88fcd6c6bc3e921","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/send_chat_message.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/send_chat_message.py","kind":"file","name":"src/browsergym/workarena/tasks/send_chat_message.py","path":"src/browsergym/workarena/tasks/send_chat_message.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from typing import Tuple\nfrom playwright.sync_api import Page\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..instance import SNowInstance\n\n\nclass SendChatMessageTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"Task to send a chat message in the chat. Only used as a compositional building block for the cheat function.\n Args:\n --------\n message (str):\n The message to send in the chat\n answer_format (str):\n The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return\n \"\"\"\n\n def __init__(\n self,","source_hash":"f32592044303a6ffeb794e101fddab8edc8f57a66384e0206f2e3ae4e95cde33","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/service_catalog.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/service_catalog.py","kind":"file","name":"src/browsergym/workarena/tasks/service_catalog.py","path":"src/browsergym/workarena/tasks/service_catalog.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTasks that require interacting with the service catalog\n\n\"\"\"\n\nimport json\nimport logging\nfrom typing import List\nimport numpy as np\nimport playwright.sync_api\n\nfrom playwright.sync_api import Page\nimport re\nfrom time import sleep\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .utils.form import fill_text\n\nfrom ..api.requests import (\n get_request_by_id,","source_hash":"8355f689de0f1c0c983d867abe4c048c9bac831f120b212366a0b84a2956a1a0","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/form.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/form.py","kind":"file","name":"src/browsergym/workarena/tasks/form.py","path":"src/browsergym/workarena/tasks/form.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import inspect\nimport json\nimport logging\nimport playwright.sync_api\nimport re\n\nfrom collections import OrderedDict\nfrom english_words import get_english_words_set\nfrom faker import Faker\n\nfake = Faker()\nfrom playwright.sync_api._generated import Page\nfrom tenacity import retry, stop_after_delay, retry_if_exception_type\nfrom time import sleep\nfrom typing import List, Tuple\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..api.utils import (","source_hash":"fecd3bc99fb37196e2e6fe952ba926d413f351f2057cc1155859b9e90868ce73","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/list.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/list.py","kind":"file","name":"src/browsergym/workarena/tasks/list.py","path":"src/browsergym/workarena/tasks/list.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTasks related to lists\n\n\"\"\"\n\nimport itertools\nimport json\nimport logging\nimport playwright.sync_api\nimport re\n\nfrom playwright.sync_api import Page\nfrom tenacity import retry, retry_if_exception_type, stop_after_delay\nfrom typing import List, Tuple\nfrom urllib import parse\nfrom warnings import warn\n\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..api.utils import table_api_call, table_column_info\nfrom ..config import (","source_hash":"ede6fd175268a0bcc5188722ba5dbf1356c298dc81a3903338fa333b5a751da3","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/mark_duplicate_problem.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/mark_duplicate_problem.py","kind":"file","name":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","path":"src/browsergym/workarena/tasks/mark_duplicate_problem.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\n\nfrom playwright.sync_api import Page\nfrom typing import Tuple\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\n\nfrom ..api.utils import table_api_call\n\n\nclass SetProblemAsDuplicateTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Set a problem as duplicate, assuming we start on the problems list view.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the task list.","source_hash":"db39cfa32b82e3b864204cf9f63591f8a076a3818a27dcf92bf0be9a906a05f1","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/navigation.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/navigation.py","kind":"file","name":"src/browsergym/workarena/tasks/navigation.py","path":"src/browsergym/workarena/tasks/navigation.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTasks related to basic menu navigation.\n\n\"\"\"\n\nimport json\nimport playwright.sync_api\nimport re\n\nfrom importlib import resources\nfrom playwright.sync_api import Page\nfrom urllib import parse\nfrom typing import List, Tuple\n\nfrom ..api.utils import table_api_call\nfrom .base import AbstractServiceNowTask\nfrom ..config import ALL_MENU_PATH, IMPERSONATION_CONFIG_PATH\nfrom ..instance import SNowInstance\nfrom ..utils import impersonate_user\n\n","source_hash":"63cd03a4bf31040f2ef734ae756d16e957f8a9a4595205be8d03bba65ea0385b","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/knowledge.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/knowledge.py","kind":"file","name":"src/browsergym/workarena/tasks/knowledge.py","path":"src/browsergym/workarena/tasks/knowledge.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nTasks related to knowledge bases.\n\n\"\"\"\n\nimport json\nimport logging\nimport re\n\nfrom playwright.sync_api import Page\nfrom typing import Tuple\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\nfrom .utils.utils import check_url_suffix_match\n\nfrom ..api.utils import table_api_call\nfrom ..config import KB_FILEPATH, KB_CONFIG_PATH, KB_NAME, SNOW_BROWSER_TIMEOUT\nfrom ..install import check_knowledge_base\nfrom ..instance import SNowInstance","source_hash":"900363942ec3a69b4c6d195495919d0e3a99796230c32273a33579f2a100e8a5","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/comp_building_block.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/comp_building_block.py","kind":"file","name":"src/browsergym/workarena/tasks/comp_building_block.py","path":"src/browsergym/workarena/tasks/comp_building_block.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":4,"code":"class CompositionalBuildingBlockTask:\n \"\"\"Base class for compositional building block tasks. Used to exclude these tasks from the list of tasks that are tested like atomic tasks\"\"\"\n\n pass","source_hash":"2e0dca6c05abc730077b95db3cde8bf1bbddbbb99f269981bc8ee35de483c0a1","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/dashboard.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/dashboard.py","kind":"file","name":"src/browsergym/workarena/tasks/dashboard.py","path":"src/browsergym/workarena/tasks/dashboard.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport logging\nimport numpy as np\nimport playwright.sync_api\nimport re\n\nfrom abc import ABC, abstractmethod\nfrom tenacity import retry, stop_after_attempt, wait_fixed\nfrom typing import List, Tuple\nfrom urllib import parse\n\nfrom .base import AbstractServiceNowTask\nfrom .comp_building_block import CompositionalBuildingBlockTask\nfrom .utils.utils import check_url_suffix_match\n\nfrom ..api.utils import table_api_call, table_column_info\nfrom ..config import (\n DASHBOARD_RETRIEVAL_MINMAX_CONFIG_PATH,\n DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH,\n REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,\n REPORT_RETRIEVAL_VALUE_CONFIG_PATH,","source_hash":"9e7cb3ac8e97b48cca0e79a5d6bc4ced3d220890da86d9bcf28618286b6bb180","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/utils/private_tasks.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/utils/private_tasks.py","kind":"file","name":"src/browsergym/workarena/tasks/utils/private_tasks.py","path":"src/browsergym/workarena/tasks/utils/private_tasks.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport time\nfrom ...api.utils import table_api_call\nfrom playwright.sync_api import Page\n\n\ndef create_private_task_and_get_sys_id(\n instance,\n page: Page,\n private_task_id: str,\n task_info: str,\n short_description: str,\n user_sys_id: str = None,\n) -> None:\n \"\"\"\n Create a private task in the ServiceNow instance to store the task information. Used for level 3 tasks.\n Sets the sys_id of the private task to the sys_id attribute of the task.\n Returns the sys_id of the private task.\n Parameters:\n ----------\n instance: SNowInstance","source_hash":"afb67d4a704cb99759da2fad2ba7942e3d2af2172500d5c54b374b978f4a6072","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/utils/debug.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/utils/debug.py","kind":"file","name":"src/browsergym/workarena/tasks/utils/debug.py","path":"src/browsergym/workarena/tasks/utils/debug.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import playwright.sync_api\n\n\n# TODO: is this used?\ndef debug_task(task, random_seed=3):\n with playwright.sync_api.sync_playwright() as p:\n browser = p.chromium.launch_persistent_context(\n user_data_dir=\"/tmp/workarena_cromium_user_data\",\n headless=False, # Set headless=True for a non-GUI mode\n )\n (page,) = browser.pages\n\n try:\n task.setup(seed=random_seed, page=page)\n valid_res = task.validate(page, [])\n assert valid_res is False\n task.cheat()\n assert task.validate(page, []) is True\n finally:\n task.teardown()\n browser.close()","source_hash":"104cbb46dd844f0928acf9b4b3acbfbb4c2eb65e6b0e9fcf56e33b06f9ec6c80","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/utils/form.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/utils/form.py","kind":"file","name":"src/browsergym/workarena/tasks/utils/form.py","path":"src/browsergym/workarena/tasks/utils/form.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import time\nfrom ...config import SNOW_BROWSER_TIMEOUT\n\n\ndef fill_text(page, input_field, value, iframe=None):\n \"\"\"\n Fills the value of text field, while handling autocomplete menus.\n\n Parameters\n ----------\n page : playwright.sync_api.page.Page\n The page object\n input_field : playwright locator\n The locator of the input field\n value : str\n The value to fill in\n iframe : playwright locator, optional\n The locator of the iframe that contains the input field, by default None\n\n \"\"\"\n if iframe is None:","source_hash":"80274f4247c19de30aff1fb0e2dcbb46b32a40ad68df7b8ece581072f5f489c2","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/utils/utils.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/utils/utils.py","kind":"file","name":"src/browsergym/workarena/tasks/utils/utils.py","path":"src/browsergym/workarena/tasks/utils/utils.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import logging\nimport playwright.sync_api\n\nfrom urllib import parse\n\n\ndef check_url_suffix_match(page: playwright.sync_api.Page, expected_url: str, task) -> bool:\n \"\"\"\n Check if the current page URL matches the expected URL\n \"\"\"\n expected_url = parse.unquote(expected_url)\n expected_url_suffix = parse.urlparse(expected_url).path\n\n page_url = page.evaluate(\"window.location.href\")\n page_url = parse.unquote(page_url)\n page_suffix = parse.urlparse(page_url).path\n if expected_url_suffix not in page_suffix:\n logging.debug(f\"Not in the expected URL for {task.__class__.__name__}, but in {page.url}\")\n return False\n return True\n","source_hash":"c500fe9e313080deeac5f9f574b04df0c61f777925dd3b957e9988d72c4c2fd9","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/utils/string.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/utils/string.py","kind":"file","name":"src/browsergym/workarena/tasks/utils/string.py","path":"src/browsergym/workarena/tasks/utils/string.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":15,"code":"\"\"\"\nVarious utility functions for string manipulation.\n\n\"\"\"\n\n\ndef generate_trigrams(word):\n return [word[i : i + 3] for i in range(len(word) - 2)]\n\n\ndef share_tri_gram(str1, str2):\n tri_grams1 = set(generate_trigrams(str1))\n tri_grams2 = set(generate_trigrams(str2))\n\n return bool(tri_grams1.intersection(tri_grams2))","source_hash":"8abe7f0120fd41214c67d92e1e8dac9d25d1b927efff044e1fa9f104b3933f82","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","path":"src/browsergym/workarena/tasks/compositional/manage_change_request_schedule.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import re\n\nfrom datetime import datetime, timedelta\nfrom faker import Faker\nfrom typing import List, Tuple\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.form import (\n EditChangeRequestScheduleTask,\n)\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.change_request import create_change_request\nfrom ...api.utils import table_api_call, db_delete_from_table","source_hash":"534a3f95ef7b9b38e0beae70dcf508ec8e07ac5a2c80485d6f0bcc003b96d726","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/base.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/base.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/base.py","path":"src/browsergym/workarena/tasks/compositional/base.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport time\nimport warnings\n\nfrom typing import List, Tuple\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.config import PROTOCOL_KB_FILEPATH\n\nfrom .update_task import UpdatePrivateTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..navigation import AllMenuTask\n\nfrom ...instance import SNowInstance\n\n\nclass CompositionalTask(AbstractServiceNowTask):\n # Final private task instructions\n final_private_task_instructions = 'Don\\'t forget to mark this task as \"Closed - complete\" once successfully completed. If the task appears infeasible, mark the task as \"Closed - skipped\" .'\n","source_hash":"7886617e904ebd9beb942d97ecf49b63fec9ac82ee7b361ef8d4730d31021e29","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/navigate_and_do.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/navigate_and_do.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.form import (\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,\n CreateUserTask,\n)\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterChangeRequestListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterServiceCatalogItemListTask,","source_hash":"868e03fc5047cdf1390c7697fd657323daadc799674ab14e287fc0e3bcb793d0","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateIncidentTask\n\n\nclass DashboardRetrieveIncidentAndCreateIncidentTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,","source_hash":"b2a7a4e83b2921ef9ccb4ce55bb984e21c8a858dffdc05b7949878e2242fc3b1","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/work_assignment.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/work_assignment.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/work_assignment.py","path":"src/browsergym/workarena/tasks/compositional/work_assignment.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from typing import Tuple\nfrom faker import Faker\nimport random\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ...api.incident import create_incident\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ..base import AbstractServiceNowTask\nfrom ..list import FilterIncidentListTask\nfrom ..form import EditIncidentTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..navigation import AllMenuTask\n\nfrom ...instance import SNowInstance\n","source_hash":"ccc158e2d1b1c6341fcdc0b76197f53a2c1f4ef51f906d5e7d4ebba3b212192b","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","path":"src/browsergym/workarena/tasks/compositional/mark_duplicate_problems.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..mark_duplicate_problem import SetProblemAsDuplicateTask\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.problem import create_problem\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...config import (\n # Expected columns for the different lists\n EXPECTED_PROBLEM_COLUMNS_PATH,\n)\nfrom ...instance import SNowInstance\n\n","source_hash":"8b7214660d1c91fbe2bff460dca2f615c6b2c49eb9ac4812eef6cf719279219d","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item_infeasible.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateItemRequestTask\n\n\nclass DashboardRetrieveIncidentAndRequestItemInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(","source_hash":"af34c7a219bdc75386f2e0b8035c1973df2c02f01df6fb7bcaed7c05b21f2d32","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/find_and_order_item.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/find_and_order_item.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","path":"src/browsergym/workarena/tasks/compositional/find_and_order_item.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.send_chat_message import SendChatMessageGenericTask\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\nfrom .base import HumanEvalTask\nfrom .filter_and_do import FilterAndDoTask\n","source_hash":"e1be18989429dbd38dd52ad077daf39c46de40fb70a965d00097c6ad9ac7e55c","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","path":"src/browsergym/workarena/tasks/compositional/maximize_investment_return.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import re\n\nfrom faker import Faker\nfrom typing import List, Tuple\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.send_chat_message import SendChatMessageForBudgetAllocationTask\n\nfrom .base import HumanEvalTask\nfrom .delete_record import DeleteExpenseLineKnapsack\nfrom .filter_and_do import FilterAndDoTask\nfrom .utils.knapsack import KnapsackInstanceGenarator\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.expense_line import create_expense_line\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (","source_hash":"07388f930f329cdcef0f1520ea22a3877782dd9822f17fbe8e6eeb4d32aea040","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem_infeasible.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateProblemTask\n\n\nclass DashboardRetrieveIncidentAndCreateProblemInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(\n self,","source_hash":"5d4995b7a7fccdc2664ba359fc3dc02df2a57f4db5b2d27ab636b42c69116106","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/workload_balancing.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/workload_balancing.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","path":"src/browsergym/workarena/tasks/compositional/workload_balancing.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import faker\n\nfake = faker.Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import WorkLoadBalancingMinMaxRetrievalTask\nfrom ..form import EditProblemTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import FilterProblemListForWorkLoadBalancingTask\nfrom ..navigation import AllMenuTask\nfrom ..send_chat_message import SendChatMessageGenericTask\n\nfrom ...api.problem import create_problem\nfrom ...api.report import create_report\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...instance import SNowInstance","source_hash":"8b3329e010934390c7d0fd964efd68c3845cfa7aa43e58d3a511972476abed51","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/onboard_user.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/onboard_user.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/onboard_user.py","path":"src/browsergym/workarena/tasks/compositional/onboard_user.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..form import CreateUserTask, CreateHardwareAssetTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..navigation import AllMenuTask\nfrom ..service_catalog import OrderAppleMacBookPro15Task\n\nfrom ...instance import SNowInstance\nfrom ...config import CREATE_USER_CONFIG_PATH, CREATE_HARDWARE_CONFIG_PATH\n\n\nclass OnBoardUserTask(CompositionalTask, HumanEvalTask):\n def __init__(\n self,\n seed: int = None,\n instance: SNowInstance = None,","source_hash":"67668f5a73e3374ba315c822de2358f0f61bfd1615ec95d477b91428360cd4f1","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_base.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_base.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_base.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nDashboard retrieval and do action comp tasks\n\"\"\"\n\nimport json\nfrom functools import partial\nimport random\nimport numpy as np\nfrom typing import List\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, InfeasibleCompositionalTask, HumanEvalTask\nfrom .utils.infeasible_configs import get_infeasible_service_catalog_config\nfrom ..base import AbstractServiceNowTask\nfrom ..knowledge import KnowledgeBaseSearchTask\n","source_hash":"8a1c60c15c547f10495ede3d2b3392107d62ffcbb29a6d6830b18faec0f8cdf2","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/warranty_check.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/warranty_check.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/warranty_check.py","path":"src/browsergym/workarena/tasks/compositional/warranty_check.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport time\nfrom faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import ExtractListInfoTask, FilterHardwareListTask\nfrom ..navigation import AllMenuTask\n\nfrom ...api.computer_asset import create_computer_asset\nfrom ...api.user import create_user\nfrom ...api.utils import db_delete_from_table, table_api_call\nfrom ...instance import SNowInstance\n\n","source_hash":"d044e5d7aeb33ea3993ef8b8a3553d9ef2c649bf6b7f6cd0268596b8ced95299","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/offboard_user.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/offboard_user.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/offboard_user.py","path":"src/browsergym/workarena/tasks/compositional/offboard_user.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\n\nfrom faker import Faker\n\nfake = Faker()\nfrom playwright.sync_api._generated import Page\n\nfrom .base import CompositionalTask, HumanEvalTask\nfrom .delete_record import DeleteUserTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..form import EditHardwareAssetTask\nfrom ..knowledge import KnowledgeBaseSearchTask\nfrom ..list import FilterHardwareListTask\nfrom ..navigation import AllMenuTask\n\nfrom ...api.computer_asset import create_computer_asset\nfrom ...api.user import create_user\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n","source_hash":"87909b53265ff49c92db26bd07d448ff07d2880b8498fe0b705982ea187e7f07","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","path":"src/browsergym/workarena/tasks/compositional/edit_knowledge_base.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import html\nimport json\nimport random\n\nfrom faker import Faker\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfake = Faker()\n\nfrom ...api.knowledge import give_kb_read_permissions\nfrom ...api.utils import table_api_call\nfrom ..base import AbstractServiceNowTask\nfrom .base import CompositionalTask\nfrom ...config import KB_FILEPATH, PROTOCOL_KB_NAME\nfrom ...instance import SNowInstance\nfrom ..knowledge import KnowledgeBaseSearchTask, AddCommentToKnowledgeArticleTask\nfrom ..navigation import AllMenuTask\n\n\nclass EditKnowledgeBaseTask(CompositionalTask):","source_hash":"6ca95ca5f04d0ac472b7e92d05072f8e7f10a5cc7d63c91a48f7f515eab1b0f1","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/update_task.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/update_task.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/update_task.py","path":"src/browsergym/workarena/tasks/compositional/update_task.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from playwright.sync_api import Page\nfrom typing import List, Tuple\n\nfrom ..base import AbstractServiceNowTask\nfrom ..comp_building_block import CompositionalBuildingBlockTask\nfrom ..utils.utils import check_url_suffix_match\nfrom ..utils.private_tasks import create_private_task_and_get_sys_id\n\nfrom ...api.utils import db_delete_from_table, table_api_call\n\n\nclass UpdatePrivateTask(AbstractServiceNowTask, CompositionalBuildingBlockTask):\n \"\"\"\n Set a private task to complete, assuming we start on the task viewed as form.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to use.\n start_rel_url: str\n The relative URL of the task list.","source_hash":"9f58656d60965701a0484fda0f9cb87d58f2fe642d13932c41988f60c806af81","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/__init__.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/__init__.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/__init__.py","path":"src/browsergym/workarena/tasks/compositional/__init__.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from .utils.curriculum import AGENT_CURRICULUM, HUMAN_CURRICULUM\n\nALL_COMPOSITIONAL_TASKS = []\n\nfor category, items in AGENT_CURRICULUM.items():\n category_tasks = []\n for task in items[\"buckets\"]:\n category_tasks += task\n ALL_COMPOSITIONAL_TASKS += category_tasks\n\n\ndef specialize_task_class_to_level(task_cls, level):\n \"\"\"\n Function to hardcode the level for the tasks\n \"\"\"\n new_name = f\"{task_cls.__name__}L{level}\"\n patched_cls = f\"\"\"\nclass {new_name}(task_cls):\n def __init__(self, **kwargs):\n super().__init__(level={level}, **kwargs)\n\"\"\"","source_hash":"ce06e5db7a30c146529c50fce2b87e4098ad680b0d087d0f35272dfc7fcdacce","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog_infeasible.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from .dash_do_base import DashboardRetrieveCatalogAndDoInfeasibleTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n)\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.service_catalog import (","source_hash":"a875ec76d7ec237ac26b25f88e0682fa36725ad1602a4b57fa7110fa7bf2159d","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_catalog.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from .dash_do_base import DashboardRetrieveCatalogAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.service_catalog import (\n OrderDeveloperLaptopTask,\n OrderIpadMiniTask,\n OrderIpadProTask,\n OrderSalesLaptopTask,\n OrderStandardLaptopTask,\n OrderAppleWatchTask,\n OrderAppleMacBookPro15Task,\n OrderDevelopmentLaptopPCTask,\n OrderLoanerLaptopTask,\n)\n\n\nclass DashboardRetrieveCatalogAndOrderDeveloperLaptopTask(DashboardRetrieveCatalogAndDoTask):","source_hash":"701dcb7459dbfa6b14fa2f8be02c74e6720ba1450613105bb2b89bc4c4168412","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_incident_infeasible.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask\nfrom .utils.infeasible_configs import get_infeasible_form_config\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateIncidentTask\n\n\nclass DashboardRetrieveIncidentAndCreateIncidentInfeasibleTask(\n DashboardRetrieveIncidentAndDoInfeasibleTask\n):\n def __init__(","source_hash":"71c09c00c32516f1ea1ef39de8434d3e7a6d0f22b68ad9e631db5be2807d6365","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/filter_and_do.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/filter_and_do.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/filter_and_do.py","path":"src/browsergym/workarena/tasks/compositional/filter_and_do.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from faker import Faker\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom browsergym.workarena.tasks.list import FilterListTask\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\n\nfrom .base import CompositionalTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...instance import SNowInstance\n\n\nclass FilterAndDoTask(CompositionalTask):\n def __init__(\n self,\n seed: int,","source_hash":"3c742a70117463a5777dc98a2235c9d00afd493bb98ab5d0bd6a4a14ed955c71","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_filter.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_filter.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_filter.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import random\nfrom playwright.sync_api._generated import Page\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterUserListTask,\n)\n\n\nclass DashboardRetrieveIncidentAndFilterListTask(DashboardRetrieveIncidentAndDoTask):","source_hash":"48450d0d404f550a36aee922eb1d800e18b7cd426813bcd7cb187312b9087562","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/expense_management.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/expense_management.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/expense_management.py","path":"src/browsergym/workarena/tasks/compositional/expense_management.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import re\n\nfrom datetime import timedelta\nfrom faker import Faker\nfrom typing import List, Tuple\n\nfake = Faker()\n\nfrom playwright.sync_api._generated import Page\n\nfrom .base import HumanEvalTask\nfrom .delete_record import DeleteExpenseLineExpenseManagementTask\nfrom .filter_and_do import FilterAndDoTask\n\nfrom ..base import AbstractServiceNowTask\n\nfrom ...api.change_request import create_change_request\nfrom ...api.expense_line import create_expense_line\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...config import (\n # Expected columns for the different lists","source_hash":"f7d6e90f4b175c33c688ddc498d5d47628cf8ecfb3717f9d1ebc2fe630864b00","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_request_item.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import random\nfrom playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateItemRequestTask\n\n\nclass DashboardRetrieveIncidentAndRequestItemTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,","source_hash":"877787fd3fe6fa5c65d1feecb4ad4b3e378c96a506795ad86f5c81a81b8287e5","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","path":"src/browsergym/workarena/tasks/compositional/navigate_and_do_infeasible.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from faker import Faker\n\nfake = Faker()\nfrom functools import partial\n\nfrom playwright.sync_api._generated import Page\n\nfrom browsergym.workarena.tasks.form import (\n CreateChangeRequestTask,\n CreateHardwareAssetTask,\n CreateIncidentTask,\n CreateProblemTask,\n CreateUserTask,\n)\nfrom browsergym.workarena.tasks.list import (\n FilterAssetListTask,\n FilterChangeRequestListTask,\n FilterHardwareListTask,\n FilterIncidentListTask,\n FilterServiceCatalogItemListTask,\n FilterUserListTask,","source_hash":"c35ae061a5a24a1be9492997d7c4b77d9732107855975c4b2a1822f9f39f2ef7","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/delete_record.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/delete_record.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/delete_record.py","path":"src/browsergym/workarena/tasks/compositional/delete_record.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import faker\n\nfaker = faker.Faker()\nimport json\n\nfrom playwright.sync_api import Page\nfrom typing import List, Tuple\n\nfrom .base import AbstractServiceNowTask\n\nfrom ..utils.utils import check_url_suffix_match\n\nfrom ...api.utils import db_delete_from_table, table_api_call\n\n\nclass DeleteRecordTask(AbstractServiceNowTask):\n \"\"\"\n Delete a record from a list.\n\n Parameters:\n -----------","source_hash":"7d7b3fa5da6967ad0b039724e8b80dddf277c3d67f324999308ebe00423bdce8","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","path":"src/browsergym/workarena/tasks/compositional/dash_do_create_problem.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from playwright.sync_api._generated import Page\nfrom typing import Tuple\n\nfrom .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask\n\nfrom ..base import AbstractServiceNowTask\nfrom ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask\n\nfrom ...api.utils import table_api_call, db_delete_from_table\nfrom ...instance import SNowInstance\n\nfrom browsergym.workarena.tasks.navigation import AllMenuTask\nfrom browsergym.workarena.tasks.form import CreateProblemTask\n\n\nclass DashboardRetrieveIncidentAndCreateProblemTask(DashboardRetrieveIncidentAndDoTask):\n def __init__(\n self,\n instance: SNowInstance = None,\n seed: int = None,\n fixed_config: list[AbstractServiceNowTask] = None,","source_hash":"70b5aec310455cc3b12a49aa43caa9f4f0502df556c9da9dd6eb20d7ed308ccb","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/utils/knapsack.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/utils/knapsack.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","path":"src/browsergym/workarena/tasks/compositional/utils/knapsack.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import numpy as np\n\n\nclass KnapsackInstanceGenarator:\n \"\"\"\n Generates a knapsack instance with the given number of items and maximum capacity, and solves it.\n The instance is guaranteed to have a unique optimal solution in \"random\" or \"single_item\" mode .\n\n Args:\n - random: Random number generator\n - num_items: Number of items\n - max_capacity: Maximum capacity of the knapsack\n - mode: Mode of generation. Choice of \"random\", \"trivial\", \"single_item\", \"single_item_uniform\", \"n_items\"\n - random: Randomly generate the instance and return it; guaranteed to have a unique optimal solution\n - trivial: Generate a trivial instance with all items fitting in the knapsack; return the instance\n - single_item: Generate an instance where the optimal solution has only one item\n - n_items: Generate an instance with all items having uniform weight and value; n items fitting in the knapsack\n - single_item_uniform: Generate an instance with all items having uniform weight and value; optimal solution has only one item and it can be any\n - num_items_in_solution: Number of items in the optimal solution. Required for \"n_items\" mode.\n - default_return: Default return value for investments having uniform weight and value. Required for \"n_items\" and \"single_item_uniform\" modes.\n \"\"\"","source_hash":"4f9cc1b89b2984e98bc08cfae22997ee1e4a94cc53ad73c7711004df69eff519","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","path":"src/browsergym/workarena/tasks/compositional/utils/infeasible_configs.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import numpy as np\n\nfrom faker import Faker\n\nfake = Faker()\n\n\ndef get_infeasible_form_config(config, random: np.random, provide_reason: bool = True):\n \"\"\"\n Get an infeasible form config from a feasible config by replacing the name of one of the task_fields with a random word\n\n Args:\n --------\n config (dict):\n The feasible form config to be transformed into an infeasible one\n random (np.random):\n The random number generator to use\n provide_reason (bool):\n Whether to provide a reason for the infeasibility. If False, the list of reasons will be [\"\"] so that\n any infeasibility can be detected by the absence of a reason\n","source_hash":"881c8ede4723e531ab1325fe43ad19a05436b59348e1669260d8ef6c2558fb2d","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/compositional/utils/curriculum.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/compositional/utils/curriculum.py","kind":"file","name":"src/browsergym/workarena/tasks/compositional/utils/curriculum.py","path":"src/browsergym/workarena/tasks/compositional/utils/curriculum.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"# from .edit_knowledge_base import __TASKS__ as EDIT_KNOWLEDGE_BASE_TASKS, __L2_TASKS__ as EDIT_KNOWLEDGE_BASE_L2_TASKS, __L3_TASKS__ as EDIT_KNOWLEDGE_BASE_L3TASKS\nfrom ..dash_do_catalog import (\n DASH_AND_ORDER,\n DASH_COMPUTE_MEAN_AND_ORDER,\n DASH_COMPUTE_MEDIAN_AND_ORDER,\n DASH_COMPUTE_MODE_AND_ORDER,\n)\nfrom ..dash_do_create_incident import DASH_AND_CREATE_INCIDENT, DASH_COMPUTE_AND_CREATE_INCIDENT\nfrom ..dash_do_create_problem import DASH_AND_CREATE_PROBLEM, DASH_COMPUTE_AND_CREATE_PROBLEM\nfrom ..dash_do_filter import (\n DASH_COMPUTE_MIN_FILTER_LIST,\n DASH_COMPUTE_MAX_FILTER_LIST,\n DASH_COMPUTE_MEAN_FILTER_LIST,\n DASH_COMPUTE_MEDIAN_FILTER_LIST,\n DASH_COMPUTE_MODE_FILTER_LIST,\n)\nfrom ..dash_do_request_item import (\n DASH_AND_REQUEST,\n DASH_COMPUTE_MEAN_AND_REQUEST,\n DASH_COMPUTE_MEDIAN_AND_REQUEST,\n DASH_COMPUTE_MODE_AND_REQUEST,","source_hash":"6659cf2e29de7ef9f818f36ff73483189a601b4278ae9287f4b0402dfb660730","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/scripts/service_catalog.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/scripts/service_catalog.py","kind":"file","name":"src/browsergym/workarena/tasks/scripts/service_catalog.py","path":"src/browsergym/workarena/tasks/scripts/service_catalog.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport multiprocessing\nimport random\nimport re\n\nfrom itertools import product, combinations\nfrom browsergym.workarena.tasks.service_catalog import META_CONFIGS\nfrom browsergym.workarena.config import (\n ORDER_DEVELOPER_LAPTOP_TASK_CONFIG_PATH,\n ORDER_IPAD_MINI_TASK_CONFIG_PATH,\n ORDER_IPAD_PRO_TASK_CONFIG_PATH,\n ORDER_SALES_LAPTOP_TASK_CONFIG_PATH,\n ORDER_STANDARD_LAPTOP_TASK_CONFIG_PATH,\n ORDER_APPLE_WATCH_TASK_CONFIG_PATH,\n ORDER_APPLE_MAC_BOOK_PRO15_TASK_CONFIG_PATH,\n ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH,\n ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH,\n)\nfrom browsergym.workarena.tasks.service_catalog import __TASKS__\n\n# The number of configurations to generate per item, as described in the WorkArena paper","source_hash":"fe396541611f89489d460897fa115b76b4d12a68ae7ef40ee11279e7c87c1ee4","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/scripts/generate_dashboard_configs.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/scripts/generate_dashboard_configs.py","kind":"file","name":"src/browsergym/workarena/tasks/scripts/generate_dashboard_configs.py","path":"src/browsergym/workarena/tasks/scripts/generate_dashboard_configs.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nGenerate configurations for the report and dashboard tasks\n\nNotes: sometimes it crashes (e.g., timeout, etc.). Just relaunch and it will be fine.\n\n\"\"\"\n\nimport json\nimport multiprocessing\nimport random\nimport tenacity\n\nfrom functools import partial\nfrom playwright.sync_api import sync_playwright\n\nfrom browsergym.workarena.api.utils import table_api_call, table_column_info\nfrom browsergym.workarena.config import (\n REPORT_DATE_FILTER,\n REPORT_PATCH_FLAG,\n REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,\n REPORT_RETRIEVAL_VALUE_CONFIG_PATH,","source_hash":"af67032d1d67d699dfe66ffc5c84cdc7ddf3b98b7925a0556a2bade0ea989647","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/scripts/validate.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/scripts/validate.py","kind":"file","name":"src/browsergym/workarena/tasks/scripts/validate.py","path":"src/browsergym/workarena/tasks/scripts/validate.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport logging\nimport multiprocessing\n\nfrom browsergym.workarena.config import (\n # navigation tasks\n ALL_MENU_PATH,\n IMPERSONATION_CONFIG_PATH,\n # form tasks\n CREATE_CHANGE_REQUEST_CONFIG_PATH,\n CREATE_HARDWARE_CONFIG_PATH,\n CREATE_INCIDENT_CONFIG_PATH,\n CREATE_PROBLEM_CONFIG_PATH,\n CREATE_USER_CONFIG_PATH,\n # list tasks\n FILTER_ASSET_LIST_CONFIG_PATH,\n FILTER_CHANGE_REQUEST_LIST_CONFIG_PATH,\n FILTER_HARDWARE_LIST_CONFIG_PATH,\n FILTER_INCIDENT_LIST_CONFIG_PATH,\n FILTER_SERVICE_CATALOG_ITEM_LIST_CONFIG_PATH,\n FILTER_USER_LIST_CONFIG_PATH,","source_hash":"438497344b6348df0f9bafc5cfc75d3afe616d26b1725ce28bf066ddd487bde1","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","kind":"file","name":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","path":"src/browsergym/workarena/tasks/scripts/extract_all_menu_items.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport os\n\nfrom playwright.sync_api import sync_playwright\n\n\n# Load environment variables\nSNOW_INSTANCE_URL = os.getenv(\"SNOW_INSTANCE_URL\")\nSNOW_INSTANCE_UNAME = os.getenv(\"SNOW_INSTANCE_UNAME\")\nSNOW_INSTANCE_PWD = os.getenv(\"SNOW_INSTANCE_PWD\")\n\n# ==================================================================================================================\n# This file is a script that extracts all the menu tasks from the ServiceNow instance. It uses #\n# Playwright to navigate to the ServiceNow instance, log in, and extract all the menu items. It then saves #\n# menu items to a JSON file. The extracted menu items can be used to create tasks for the WorkArena benchmark. #\n# ==================================================================================================================\n\n\nif __name__ == \"__main__\":\n\n base_paths = []","source_hash":"bcfc5ae58d3a4578900ba61a477d01f5aa7f66edf885375dc6884b2aa2a68f3c","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/scripts/list.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/scripts/list.py","kind":"file","name":"src/browsergym/workarena/tasks/scripts/list.py","path":"src/browsergym/workarena/tasks/scripts/list.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport multiprocessing\nimport random\nimport re\n\nfrom browsergym.workarena.tasks.list import __TASKS__\nfrom playwright.sync_api import sync_playwright\nfrom tqdm import tqdm\n\n# Split between filter and sort tasks\nFILTER_TASKS = [\n task for task in __TASKS__ if re.compile(r\"^Filter\\w+ListTask$\").match(task.__name__)\n]\nSORT_TASKS = [task for task in __TASKS__ if re.compile(r\"^Sort\\w+ListTask$\").match(task.__name__)]\n\n\ndef generate_sort_task_configs(task_class, num_configs_per_field_count=50):\n name = task_class.__name__\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n task_name = re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n all_configs = []","source_hash":"0b2f69bd41ea291c121f9c964fbe3a656f53306642f6aac1cef3ca6431966133","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/scripts/navigation.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/scripts/navigation.py","kind":"file","name":"src/browsergym/workarena/tasks/scripts/navigation.py","path":"src/browsergym/workarena/tasks/scripts/navigation.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\n\nfrom browsergym.workarena.api.utils import table_api_call, SNowInstance\n\nNUM_CONFIGS = 650 # number of impersonation tasks in the paper\n\n\ndef get_all_impersonation_users():\n instance = SNowInstance()\n candidate_users = [\n u[\"first_name\"] + \" \" + u[\"last_name\"]\n for u in table_api_call(\n instance=instance,\n table=\"sys_user\",\n params={\"sysparm_query\": \"user_name!=admin\"},\n )[\"result\"]\n if u[\"first_name\"].strip() and u[\"last_name\"].strip()\n ]\n\n return candidate_users\n","source_hash":"d862081a85ba01dd98a705fdf7f313b8ba228d293e120b237d136245a61a8ad1","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/scripts/knowledge.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/scripts/knowledge.py","kind":"file","name":"src/browsergym/workarena/tasks/scripts/knowledge.py","path":"src/browsergym/workarena/tasks/scripts/knowledge.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport random\n\nfrom browsergym.workarena.api.utils import SNowInstance\nfrom browsergym.workarena.config import KB_FILEPATH, KB_CONFIG_PATH\nfrom browsergym.workarena.tasks.knowledge import KnowledgeBaseSearchTask\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt\nfrom tqdm import tqdm\n\n\ndef generate_all_kb_configs(instance=None, num_configs=1000) -> list[dict]:\n \"\"\"Generate all possible KB configs\"\"\"\n instance = instance if instance is not None else SNowInstance()\n with open(KB_FILEPATH, \"r\") as f:\n kb_entries = json.load(f)\n all_configs = []\n for kb_entry in kb_entries:\n for question in kb_entry[\"questions\"]:\n config = {\n \"item\": kb_entry[\"item\"],","source_hash":"42bbf7018f62eaf8d7862b431484c68cd8ccbce2fa1fb14b282251f2103a41da","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/tasks/scripts/generate_forms.py","uri":"program://WorkArena/file/src/browsergym/workarena/tasks/scripts/generate_forms.py","kind":"file","name":"src/browsergym/workarena/tasks/scripts/generate_forms.py","path":"src/browsergym/workarena/tasks/scripts/generate_forms.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport logging\nimport multiprocessing\nimport re\n\nfrom browsergym.workarena.tasks.form import __TASKS__\nfrom playwright.sync_api import sync_playwright\nfrom tenacity import retry, stop_after_attempt, retry_if_exception_type\nfrom tqdm import tqdm\n\n\ndef camel_to_snake(name):\n \"\"\"Convert camel case to snake case.\"\"\"\n name = re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)\n return re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", name).lower()\n\n\ndef generate_form_task_configs(task_name, task_class, num_configs=1):\n \"\"\"Generate forms by using random setup and validating the feasibility of the task; also ensure that the task is new.\"\"\"\n\n @retry(","source_hash":"c27a971356f9790770401d19aaca904b9cfd54d2b239b527628615becab8b0cd","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/computer_asset.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/computer_asset.py","kind":"file","name":"src/browsergym/workarena/api/computer_asset.py","path":"src/browsergym/workarena/api/computer_asset.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport numpy as np\nimport time\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_computer_asset(\n instance: SNowInstance,\n asset_tag: str,\n warranty_expiration_date: str = None,\n user_sys_id: str = None,\n computer_model_info: dict = None,\n random: np.random = None,\n):\n \"\"\"Create a hardware asset -computer model- and assign it to a user","source_hash":"ffe646fd6da6f4b6daa0f1ead6141a6f60c4726abf9df804c9458c9f145cbc43","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/requested_items.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/requested_items.py","kind":"file","name":"src/browsergym/workarena/api/requested_items.py","path":"src/browsergym/workarena/api/requested_items.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import faker\n\nfake = faker.Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_requested_item(\n instance: SNowInstance,\n user_sys_id: str,\n system_name: str,\n quantity: int = 1,\n short_description: str = None,\n) -> list[str]:\n \"\"\"\n Create a requested item for a given user\n\n Parameters:\n -----------\n instance: SNowInstance","source_hash":"8345f4b00d6ff1b010cf3f637e9013a9272d50d34e4c3e78ec3e841f9678b30d","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/problem.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/problem.py","kind":"file","name":"src/browsergym/workarena/api/problem.py","path":"src/browsergym/workarena/api/problem.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import faker\n\nfake = faker.Faker()\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_problem(\n instance: SNowInstance,\n priority: str,\n user_sys_id: str,\n problem_hashtag: str,\n short_description: str = None,\n return_number: bool = False,\n) -> list[str]:\n \"\"\"\n Create a problem with a random cause, description, and short description. The problem is assigned to a user and\n is created with a hashtag.\n\n Parameters:","source_hash":"404afdbb05023af559733eceafd6ca91beda088acfecb48fba5bdf38b5720f53","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/report.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/report.py","kind":"file","name":"src/browsergym/workarena/api/report.py","path":"src/browsergym/workarena/api/report.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import numpy as np\n\nfrom ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef create_report(\n instance: SNowInstance,\n table: str,\n filter_hashtag: str,\n field: str,\n plot_title: str,\n filter_field: str = \"short_description\",\n random: np.random = None,\n) -> list[str]:\n \"\"\"\n Create a report for for the given table using a filter (str added to the short description).\n The report is created with a random color palette and colors and a random plot type (pie or bar).\n\n Parameters:\n -----------","source_hash":"9cd49370ce26284f465e3966efcee20252b943bd6841b59d51c56f9741a5a5e1","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/cost_center.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/cost_center.py","kind":"file","name":"src/browsergym/workarena/api/cost_center.py","path":"src/browsergym/workarena/api/cost_center.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":19,"code":"import warnings\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef get_cost_center_sysid(instance, cost_center_name):\n \"\"\"Get the sys_id of a cost center by its name\"\"\"\n sys_id = table_api_call(\n instance=instance,\n table=\"cmn_cost_center\",\n params={\"sysparm_query\": f\"name={cost_center_name}\", \"sysparm_fields\": \"sys_id\"},\n )[\"result\"][0]\n\n return sys_id","source_hash":"f25146421287d540d4da7c0c62903b36a8b6b47630ee8dfb86031286c68d12cc","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/ui_themes.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/ui_themes.py","kind":"file","name":"src/browsergym/workarena/api/ui_themes.py","path":"src/browsergym/workarena/api/ui_themes.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nUtility functions for UI themes\n\n\"\"\"\n\nfrom .utils import table_api_call\n\n\ndef get_workarena_theme_variants(instance):\n \"\"\"\n Get the list of available WorkArena UI themes\n\n Parameters:\n -----------\n instance: SNowInstance\n The ServiceNow instance to get the UI themes from\n\n Returns:\n --------\n list[dict]\n The list of available WorkArena UI themes and their information","source_hash":"f47f07867a875add020395f9135b289245d2098631b5666f84d15c5e7ddef74b","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/utils.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/utils.py","kind":"file","name":"src/browsergym/workarena/api/utils.py","path":"src/browsergym/workarena/api/utils.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import requests\n\nfrom ..instance import SNowInstance\n\nfrom requests.exceptions import HTTPError\nfrom time import sleep\n\n# ServiceNow API configuration\nSNOW_API_HEADERS = {\"Content-Type\": \"application/json\", \"Accept\": \"application/json\"}\n\n\ndef table_api_call(\n instance: SNowInstance,\n table: str,\n data: dict = {},\n params: dict = {},\n json: dict = {},\n method: str = \"GET\",\n wait_for_record: bool = False,\n max_retries: int = 5,\n raise_on_wait_expired: bool = True,","source_hash":"b2e954d6b0ba8e20b20d5c27e4fa8f2b4002fba9be1894bfe02af36abea910d5","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/system_properties.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/system_properties.py","kind":"file","name":"src/browsergym/workarena/api/system_properties.py","path":"src/browsergym/workarena/api/system_properties.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from .utils import table_api_call\n\n\ndef set_sys_property(instance, property_name: str, value: str):\n \"\"\"\n Set a sys_property in the instance.\n\n Parameters:\n -----------\n instance: SNowInstance\n The instance to set the property in\n property_name: str\n The name of the property to set\n value: str\n The value to set for the property\n\n \"\"\"\n\n property = table_api_call(\n instance=instance,\n table=\"sys_properties\",","source_hash":"f83cac1ee5137c7f36b6440639a94d76daa5fb6c9e196107e5005a613a412a1e","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/change_request.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/change_request.py","kind":"file","name":"src/browsergym/workarena/api/change_request.py","path":"src/browsergym/workarena/api/change_request.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import faker\nimport numpy as np\n\nfake = faker.Faker()\n\nfrom datetime import datetime, timedelta\n\nfrom .category import get_categories\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_change_request(\n instance: SNowInstance,\n user_sys_id: str,\n impact: int,\n risk: int,\n start_date: datetime = \"\",\n end_date: datetime = \"\",\n hashtag: str = \"\",","source_hash":"f59e6e3f6df1d3c5ae25aa359dad6d80cfc1f03998a01e2f8e27a3850a260c2c","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/knowledge.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/knowledge.py","kind":"file","name":"src/browsergym/workarena/api/knowledge.py","path":"src/browsergym/workarena/api/knowledge.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from ..instance import SNowInstance\nfrom .utils import table_api_call\n\n\ndef give_kb_read_permissions(admin_instance, user_sys_id, user_name, kb_sys_id, kb_name):\n # Need admin permissions to give KB permissions to the user\n\n # Create user criteria\n user_criteria_data = {\n \"user\": user_sys_id,\n \"name\": f\"{user_name} read KB\",\n \"short_description\": f\"Let {user_name} read {kb_name}\",\n }\n criteria_response = table_api_call(\n instance=admin_instance, table=\"user_criteria\", json=user_criteria_data, method=\"POST\"\n )[\"result\"]\n criteria_sys_id = criteria_response[\"sys_id\"]\n\n # Add user criteria entry to allow users to access the ADHOC KB\n kb_uc_can_read_mtom_data = {\n \"user_criteria\": criteria_sys_id,","source_hash":"94fbcd0d7c02f4df5998ebdea8b57047d07ab588fc0c3a278f69f77eed40a034","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/user.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/user.py","kind":"file","name":"src/browsergym/workarena/api/user.py","path":"src/browsergym/workarena/api/user.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from faker import Faker\nimport numpy as np\nimport time\n\nfake = Faker()\n\nfrom ..instance import SNowInstance\nfrom .ui_themes import get_workarena_theme_variants\nfrom .utils import table_api_call\n\n\ndef create_user(\n instance: SNowInstance,\n first_name: str = None,\n last_name: str = None,\n user_name: str = None,\n return_full_response: bool = False,\n user_roles: list[str] = [\"admin\"],\n random: np.random = np.random,\n) -> list[str]:\n \"\"\"","source_hash":"98bc7caf8445540bb0ebae75e319e2bf9b27fcee24c2302c55ffa20900bd6899","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/requests.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/requests.py","kind":"file","name":"src/browsergym/workarena/api/requests.py","path":"src/browsergym/workarena/api/requests.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nAPI to interact with requests in ServiceNow\n\n\"\"\"\n\nimport json\n\nfrom collections import defaultdict\n\nfrom .utils import SNowInstance, table_api_call, db_delete_from_table\n\n\ndef delete_request(instance: SNowInstance, sys_id: str) -> None:\n \"\"\"\n Deletes a request from an instance along with all its items and their options\n\n Parameters:\n -----------\n sys_id: str\n The sys_id of the request to delete\n","source_hash":"cf6bd04d3926d47474e3f77fa5c7ba8e8a6e37ef8e874814693f9886b55af7ef","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/incident.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/incident.py","kind":"file","name":"src/browsergym/workarena/api/incident.py","path":"src/browsergym/workarena/api/incident.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"from faker import Faker\nfrom ..instance import SNowInstance\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\n\ndef create_incident(\n instance: SNowInstance,\n incident_number: int,\n caller_sys_id: str,\n category: str,\n impact: int,\n urgency: int,\n priority: int,\n incident_hastag: str = None,\n assigned_to: str = None,\n):\n incident_config = {\n \"task_effective_number\": incident_number,","source_hash":"6d56a9b1ed9c07d1f27e04ee8fe20c00904c30fbfb9bda24469cdda689680a7d","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/expense_line.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/expense_line.py","kind":"file","name":"src/browsergym/workarena/api/expense_line.py","path":"src/browsergym/workarena/api/expense_line.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import json\nimport time\n\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .cost_center import get_cost_center_sysid\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_expense_line(\n instance: SNowInstance,\n amount: float,\n number: str,\n date: str,\n short_description: str = None,\n expense_hashtag: str = \"\",\n task_sys_id: str = None,","source_hash":"31f22c9e0ca79ae2178200d8b1f5e6a38f386c1573dedc0d64d4ef5c323843c9","truncated":false} {"repo_id":"WorkArena","entity_id":"file:src/browsergym/workarena/api/category.py","uri":"program://WorkArena/file/src/browsergym/workarena/api/category.py","kind":"file","name":"src/browsergym/workarena/api/category.py","path":"src/browsergym/workarena/api/category.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"import warnings\nfrom faker import Faker\n\nfake = Faker()\n\nfrom .utils import table_api_call\n\nfrom ..instance import SNowInstance\n\n\ndef create_category(\n instance: SNowInstance,\n list_name: str,\n category_name: str = None,\n) -> list[str]:\n \"\"\"\n NOTE: This function creates a new category in the given list. Because categories are in a drop-down list, adding more\n categories will make the list longer and this will affect the difficulty of the task. Use only if you are certain you know\n what you are doing.\n\n Create a category for a given list","source_hash":"e288b03e745ab3465609d932eface1369bbff4f7c1fc79a19c56bf0c967219f0","truncated":false} {"repo_id":"WorkArena","entity_id":"file:scripts/extract_finetuning_traces.py","uri":"program://WorkArena/file/scripts/extract_finetuning_traces.py","kind":"file","name":"scripts/extract_finetuning_traces.py","path":"scripts/extract_finetuning_traces.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nA demonstration of how observation/action traces can be extracted\nfor WorkArena tasks without modifying the task code.\n\nAuthor: Alexandre Drouin (alexandre.drouin@servicenow.com)\n\nNotes:\n- This approach relies on monkey patching the playwright actions to log the actions and observations.\n It has not been tested for parallel execution. It might work with multiprocessing, but it will for\n sure not work with multithreading.\n\n\"\"\"\n\nimport importlib\nimport logging\nimport os\nimport pickle\nimport playwright.sync_api as playwright_sync\n\nfrom browsergym.core.env import BrowserEnv\nfrom browsergym.workarena import ALL_WORKARENA_TASKS","source_hash":"076442bd033a07c06f90d578a41a35f67c11cc26f25dd7d23b3b4e694930c05c","truncated":false} {"repo_id":"WorkArena","entity_id":"file:scripts/make_human_eval_curriculum.py","uri":"program://WorkArena/file/scripts/make_human_eval_curriculum.py","kind":"file","name":"scripts/make_human_eval_curriculum.py","path":"scripts/make_human_eval_curriculum.py","language":"python","start_line":1,"end_line":1,"context_start_line":1,"context_end_line":21,"code":"\"\"\"\nHuman Evaluation - Create the curriculum for all humans\n\nNote: This script separates the tasks among 14 evaluators.\n A 15th one was added subsequently to solve tasks that\n had not been completed by the initial 14 (e.g., due\n to some issues with the annotation UI).\n\n\"\"\"\n\nimport random\n\nfrom browsergym.workarena import get_all_tasks_humans\n\n\ntasks_l2 = get_all_tasks_humans(filter=\"l2\", meta_seed=42)\ntasks_l3 = get_all_tasks_humans(filter=\"l3\", meta_seed=42)\n\ntasks = tasks_l2 + tasks_l3\nrandom.shuffle(tasks)\n","source_hash":"df7880bbaa73cee59cf9cb52bfd0294adac2ed5013dca5eb2b882f352d31bd14","truncated":false}