Skip to content

Commit e1fb56d

Browse files
committed
feat: Remove implicit scrubbing in display_event function and recursively convert reqd properties to str
1 parent 0d3fb7a commit e1fb56d

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

openadapt/app/dashboard/api/recordings.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ async def get_recording_detail(websocket: WebSocket, recording_id: int) -> None:
7373
{"type": "num_events", "value": len(action_events)}
7474
)
7575

76+
def convert_to_str(event_dict: dict) -> dict:
77+
if "key" in event_dict:
78+
event_dict["key"] = str(event_dict["key"])
79+
if "canonical_key" in event_dict:
80+
event_dict["canonical_key"] = str(event_dict["canonical_key"])
81+
if "reducer_names" in event_dict:
82+
event_dict["reducer_names"] = list(event_dict["reducer_names"])
83+
if "children" in event_dict:
84+
for child in event_dict["children"]:
85+
convert_to_str(child)
86+
7687
for action_event in action_events:
7788
event_dict = row2dict(action_event)
7889
try:
@@ -85,12 +96,7 @@ async def get_recording_detail(websocket: WebSocket, recording_id: int) -> None:
8596
width, height = 0, 0
8697
event_dict["screenshot"] = image
8798
event_dict["dimensions"] = {"width": width, "height": height}
88-
if event_dict["key"]:
89-
event_dict["key"] = str(event_dict["key"])
90-
if event_dict["canonical_key"]:
91-
event_dict["canonical_key"] = str(event_dict["canonical_key"])
92-
if event_dict["reducer_names"]:
93-
event_dict["reducer_names"] = list(event_dict["reducer_names"])
99+
convert_to_str(event_dict)
94100
await websocket.send_json(
95101
{"type": "action_event", "value": event_dict}
96102
)

openadapt/utils.py

-18
Original file line numberDiff line numberDiff line change
@@ -572,24 +572,6 @@ def display_event(
572572
x = recording.monitor_width * width_ratio / 2
573573
y = recording.monitor_height * height_ratio / 2
574574
text = action_event.text
575-
576-
if config.SCRUB_ENABLED:
577-
import spacy
578-
579-
if spacy.util.is_package(
580-
config.SPACY_MODEL_NAME
581-
): # Check if the model is installed
582-
from openadapt.privacy.providers.presidio import (
583-
PresidioScrubbingProvider,
584-
)
585-
586-
text = PresidioScrubbingProvider().scrub_text(text, is_separated=True)
587-
else:
588-
logger.warning(
589-
f"SpaCy model not installed! {config.SPACY_MODEL_NAME=}. Using"
590-
" original text."
591-
)
592-
593575
image = draw_text(x, y, text, image, outline=True)
594576
else:
595577
raise Exception("unhandled {action_event.name=}")

0 commit comments

Comments
 (0)