Skip to content

Commit edfde8f

Browse files
committed
Dashboard/report tasks pull the filter from the sys property
1 parent 88bce00 commit edfde8f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/browsergym/workarena/tasks/dashboard.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
DASHBOARD_RETRIEVAL_VALUE_CONFIG_PATH,
2020
REPORT_RETRIEVAL_MINMAX_CONFIG_PATH,
2121
REPORT_RETRIEVAL_VALUE_CONFIG_PATH,
22-
REPORT_DATE_FILTER,
23-
REPORT_TIME_FILTER,
2422
REPORT_PATCH_FLAG,
2523
)
2624
from ..instance import SNowInstance
@@ -31,6 +29,15 @@
3129
# - We currently don't support maps because they are clickable and would require a more evolved cheat function
3230
SUPPORTED_PLOT_TYPES = ["area", "bar", "column", "line", "pie", "spline"]
3331

32+
# Get report filter config
33+
config = SNowInstance().report_filter_config
34+
if config is None:
35+
REPORT_DATE_FILTER = REPORT_TIME_FILTER = None
36+
else:
37+
REPORT_DATE_FILTER = config["report_date_filter"]
38+
REPORT_TIME_FILTER = config["report_time_filter"]
39+
del config
40+
3441

3542
class DashboardRetrievalTask(AbstractServiceNowTask, ABC):
3643
"""
@@ -299,6 +306,12 @@ def get_init_scripts(self) -> List[str]:
299306
def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:
300307
super().setup_goal(page=page)
301308

309+
# Check that the report filters are properly setup
310+
if REPORT_DATE_FILTER is None or REPORT_TIME_FILTER is None:
311+
raise RuntimeError(
312+
"The report date and time filters are not set. Please run the install script to set them."
313+
)
314+
302315
# Configure task
303316
# ... sample a configuration
304317
self.config = (
@@ -619,6 +632,12 @@ def _generate_random_config(
619632
The types of questions to sample from (uniformely)
620633
621634
"""
635+
# Check that the report filters are properly setup
636+
if REPORT_DATE_FILTER is None or REPORT_TIME_FILTER is None:
637+
raise RuntimeError(
638+
"The report date and time filters are not set. Please run the install script to set them."
639+
)
640+
622641
# Generate a bunch of reports based on valid table fields
623642
ON_THE_FLY_REPORTS = []
624643
for table in [

0 commit comments

Comments
 (0)