Skip to content

Commit

Permalink
feat(tray): performance and UX improvements
Browse files Browse the repository at this point in the history
* write_video_event; pre_callback/post_callback

* add Recording.config; read Screenshot.image from video; asserts if diff_video

* add FrameCache

* maybe_obfuscate; video_dir_path; event_type_modifier

* update .gitignore

* replace notifypy with pyqttoast

* add video event to perf_q; fix documentation

* add build.py main guard

* reduce visualize import time

* add RedirectOutput.null_stream

* add on_ready argument to record; remove Notify

* add task description input dialog; replace QTimer with Connection

* configure replay strategy

* handle argument types in replay dialog; remove replay_instructions where not used

* show "No recordings available"

* add delete menu

* on_ready -> status_pipe; oaThread -> Thread; disable app action; sticky toasts; log_memory arg; view_file false

* pass args to strategy class; add Config.ROOT_DIR_PATH; matplotlib use Qt5Agg

* remove extensions.thread

* Union -> |

* fix mouse playback bug; sleep in NaiveReplayStrategy

* improve parse_code_snippet; validate ActionEvent properties; fix ActionEvent.from_dict

* fix: timestamp int -> float

* fix: redundant_mouse_move -> remove_move_before_click

* add ActionEvent.reducer_names

* add common.MOUSE_CLICK_EVENTS; remove sleep in naive.py; disable remove_move_before_click

* fix: num_total -> num_total_

* RECORD_FULL_VIDEO; LOG_MEMORY; num_copies

* visualize recording_timestamp

* black

* flake8

* fix tests: add row2dicts drop_cols

* replay status pipe

* ignore reducer_names in get_action_prompt_dict
  • Loading branch information
abrichr authored May 10, 2024
1 parent 4f4cab0 commit 88b9726
Show file tree
Hide file tree
Showing 31 changed files with 1,420 additions and 538 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ src

dist/
build/
videos/
13 changes: 13 additions & 0 deletions openadapt/adapters/ultralytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,33 @@
See https://docs.ultralytics.com/models/fast-sam/#predict-usage for details.
"""
# flake8: noqa: E402

from pathlib import Path
from tempfile import TemporaryDirectory
import os

from loguru import logger
from PIL import Image


# use() required when invoked from tray
import matplotlib

# importing is required for use() to work
from PySide6.QtCore import Qt # noqa

matplotlib.use("Qt5Agg")


from ultralytics import FastSAM
from ultralytics.models.fastsam import FastSAMPrompt
import fire
import numpy as np

from openadapt import cache


MODEL_NAMES = (
"FastSAM-x.pt",
"FastSAM-s.pt",
Expand Down
32 changes: 32 additions & 0 deletions openadapt/alembic/versions/8495f5471e23_add_recording_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""add Recording.config
Revision ID: 8495f5471e23
Revises: 30a5ba9d6453
Create Date: 2024-05-02 15:08:30.109181
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "8495f5471e23"
down_revision = "30a5ba9d6453"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("recording", schema=None) as batch_op:
batch_op.add_column(sa.Column("config", sa.JSON(), nullable=True))

# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("recording", schema=None) as batch_op:
batch_op.drop_column("config")

# ### end Alembic commands ###
28 changes: 22 additions & 6 deletions openadapt/app/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ def is_running(self) -> bool:
self.reset()
return self.record_proc is not None

def start(self, func: callable, args: tuple) -> None:
def start(self, func: callable, args: tuple, kwargs: dict) -> None:
"""Start the recording process."""
self.record_proc = multiprocessing.Process(target=func, args=args)
self.record_proc = multiprocessing.Process(
target=func,
args=args,
kwargs=kwargs,
)
self.record_proc.start()


Expand Down Expand Up @@ -136,13 +140,25 @@ def is_recording() -> bool:
return record_proc.is_running()


def quick_record() -> None:
"""Run a recording session with no option for recording name (uses date instead)."""
def quick_record(
task_description: str | None = None,
status_pipe: multiprocessing.connection.Connection | None = None,
) -> None:
"""Run a recording session."""
global record_proc
new_session()
now = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
task_description = task_description or datetime.now().strftime("%d/%m/%Y %H:%M:%S")
record_proc.start(
record, (now, record_proc.terminate_processing, record_proc.terminate_recording)
record,
(
task_description,
record_proc.terminate_processing,
record_proc.terminate_recording,
status_pipe,
),
{
"log_memory": False,
},
)


Expand Down
2 changes: 1 addition & 1 deletion openadapt/app/dashboard/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This module contains the functions to run the dashboard web application."""


from threading import Thread
import os
import pathlib
import subprocess
Expand All @@ -10,7 +11,6 @@

from openadapt.build_utils import is_running_from_executable
from openadapt.config import config
from openadapt.extensions.thread import Thread

from .api.index import run_app

Expand Down
Loading

0 comments on commit 88b9726

Please sign in to comment.