Skip to content

Commit

Permalink
feat(VisualReplayStrategy): Remove model copy logic; avoid unnecessar…
Browse files Browse the repository at this point in the history
…y segmentations (#669)

* preferences_dir -> root_dir; add data_dir; remove copying logic; disable dashboard from tray; avoid unnecessary segmentations; bugfixes

* fix json serialize error

* with session

* fix template paths

* black; flake8

* make dir if not exists

* fix confest.py: RECORDING_DIRECTORY_PATH -> RECORDING_DIR_PATH

* fix test_share.py: RECORDING_DIRECTORY_PATH -> RECORDING_DIR_PATH
  • Loading branch information
abrichr authored May 12, 2024
1 parent 80f0a7f commit 45c06c3
Show file tree
Hide file tree
Showing 21 changed files with 113 additions and 3,989 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Envirionment
.env
config.local.json
config.json
data

# Python
__pycache__
cache
.cache
*.egg-info
*~
.venv
Expand Down Expand Up @@ -37,4 +38,3 @@ src

dist/
build/
videos/
86 changes: 45 additions & 41 deletions openadapt/app/dashboard/api/recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ def attach_routes(self) -> None:
def get_recordings() -> dict[str, list[Recording]]:
"""Get all recordings."""
session = crud.get_new_session()
recordings = crud.get_all_recordings(session)
return {"recordings": recordings}
with session:
recordings = crud.get_all_recordings(session)
return {"recordings": recordings}

@staticmethod
async def start_recording() -> dict[str, str]:
Expand Down Expand Up @@ -59,42 +60,45 @@ async def get_recording_detail(websocket: WebSocket, recording_id: int) -> None:
"""Get a specific recording and its action events."""
await websocket.accept()
session = crud.get_new_session()

recording = crud.get_recording_by_id(recording_id, session)

await websocket.send_json(
{"type": "recording", "value": recording.asdict()}
)

action_events = get_events(recording, session=session)

await websocket.send_json(
{"type": "num_events", "value": len(action_events)}
)

for action_event in action_events:
event_dict = row2dict(action_event)
try:
image = display_event(action_event)
width, height = image.size
image = image2utf8(image)
diff = image2utf8(display_event(action_event, diff=True))
mask = image2utf8(action_event.screenshot.diff_mask)
except Exception as e:
logger.exception("Failed to display event: {}", e)
image = None
diff = None
mask = None
width, height = 0, 0
event_dict["screenshot"] = image
event_dict["diff"] = diff
event_dict["mask"] = mask
event_dict["dimensions"] = {"width": width, "height": height}
if event_dict["key"]:
event_dict["key"] = str(event_dict["key"])
if event_dict["canonical_key"]:
event_dict["canonical_key"] = str(event_dict["canonical_key"])
await websocket.send_json({"type": "action_event", "value": event_dict})

await websocket.close()
return
with session:
recording = crud.get_recording_by_id(recording_id, session)

await websocket.send_json(
{"type": "recording", "value": recording.asdict()}
)

action_events = get_events(recording, session=session)

await websocket.send_json(
{"type": "num_events", "value": len(action_events)}
)

for action_event in action_events:
event_dict = row2dict(action_event)
try:
image = display_event(action_event)
width, height = image.size
image = image2utf8(image)
diff = image2utf8(display_event(action_event, diff=True))
mask = image2utf8(action_event.screenshot.diff_mask)
except Exception as e:
logger.exception("Failed to display event: {}", e)
image = None
diff = None
mask = None
width, height = 0, 0
event_dict["screenshot"] = image
event_dict["diff"] = diff
event_dict["mask"] = mask
event_dict["dimensions"] = {"width": width, "height": height}
if event_dict["key"]:
event_dict["key"] = str(event_dict["key"])
if event_dict["canonical_key"]:
event_dict["canonical_key"] = str(event_dict["canonical_key"])
if event_dict["reducer_names"]:
event_dict["reducer_names"] = list(event_dict["reducer_names"])
await websocket.send_json(
{"type": "action_event", "value": event_dict}
)

await websocket.close()
2 changes: 1 addition & 1 deletion openadapt/app/dashboard/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Shell } from '@/components/Shell'
import { CSPostHogProvider } from './providers';

export const metadata = {
title: 'OpenAdapt',
title: 'OpenAdapt.AI',
}

export default function RootLayout({
Expand Down
2 changes: 1 addition & 1 deletion openadapt/app/dashboard/components/Shell/Shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Shell = ({ children }: Props) => {
<Text className="h-full flex items-center px-5 gap-x-2">
<Image src={logo.src} alt="OpenAdapt" w={40} />
<Text>
OpenAdapt AI
OpenAdapt.AI
</Text>
</Text>
</AppShell.Header>
Expand Down
Loading

0 comments on commit 45c06c3

Please sign in to comment.