Skip to content

Commit 61d01c6

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

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

openadapt/app/dashboard/api/recordings.py

Lines changed: 12 additions & 6 deletions
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/record.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,9 @@ def record_audio(
10421042
"""Record audio narration during the recording and store data in database.
10431043
10441044
Args:
1045-
terminate_processing: An event to signal the termination of the process.
10461045
recording_timestamp: The timestamp of the recording.
1046+
terminate_processing: An event to signal the termination of the process.
1047+
started_counter: Value to increment once started.
10471048
"""
10481049
utils.configure_logging(logger, LOG_LEVEL)
10491050
utils.set_start_time(recording_timestamp)

openadapt/utils.py

Lines changed: 0 additions & 18 deletions
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)