Skip to content

Commit

Permalink
fix(build): remove deprecated modules; remove numpy2 from poetry.lock
Browse files Browse the repository at this point in the history
* fix: Fix build issues due to numpy

* fix: Fix broken imports

* chore: Remove uses of nicegui and clean up files
  • Loading branch information
KIRA009 authored Nov 8, 2024
1 parent 02cb0fe commit de91850
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 1,176 deletions.
2 changes: 1 addition & 1 deletion openadapt/app/dashboard/api/recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from fastapi import APIRouter, WebSocket

from openadapt.app import cards
from openadapt.custom_logger import logger
from openadapt.db import crud
from openadapt.deprecated.app import cards
from openadapt.events import get_events
from openadapt.models import Recording
from openadapt.plotting import display_event
Expand Down
112 changes: 1 addition & 111 deletions openadapt/deprecated/app/cards.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""openadapt.app.cards module.
"""openadapt.deprecated.app.cards module.
This module provides functions for managing UI cards in the OpenAdapt application.
"""
Expand All @@ -7,10 +7,6 @@
import multiprocessing
import time

from nicegui import ui

from openadapt.app.objects.local_file_picker import LocalFilePicker
from openadapt.app.util import get_scrub, set_dark, set_scrub, sync_switch
from openadapt.record import record
from openadapt.utils import WrapStdout

Expand Down Expand Up @@ -67,55 +63,6 @@ def start(self, func: callable, args: tuple, kwargs: dict) -> None:
record_proc = RecordProc()


def settings(dark_mode: bool) -> None:
"""Display the settings dialog.
Args:
dark_mode (bool): Current dark mode setting.
"""
with ui.dialog() as settings, ui.card():
dark_switch = ui.switch(
"Dark mode", on_change=lambda: set_dark(dark_mode, dark_switch.value)
)
sync_switch(dark_switch, dark_mode)

scrub_switch = ui.switch(
"Scrubbing", on_change=lambda: set_scrub(scrub_switch.value)
)
sync_switch(scrub_switch, get_scrub())

ui.button("Close", on_click=lambda: settings.close())
settings.open()


def select_import(f: callable) -> None:
"""Display the import file selection dialog.
Args:
f (callable): Function to call when import button is clicked.
"""

async def pick_file() -> None:
result = await LocalFilePicker(".")
ui.notify(f"Selected {result[0]}" if result else "No file selected.")
selected_file.text = result[0] if result else ""
import_button.enabled = True if result else False

with ui.dialog() as import_dialog, ui.card():
with ui.column():
ui.button("Select File", on_click=pick_file).props("icon=folder")
selected_file = ui.label("")
selected_file.visible = False
import_button = ui.button(
"Import",
on_click=lambda: f(selected_file.text, delete.value),
)
import_button.enabled = False
delete = ui.checkbox("Delete file after import")

import_dialog.open()


def stop_record() -> None:
"""Stop the current recording session."""
global record_proc
Expand Down Expand Up @@ -152,60 +99,3 @@ def quick_record(
"log_memory": False,
},
)


def recording_prompt(options: list[str], record_button: ui.button) -> None:
"""Display the recording prompt dialog.
Args:
options (list): List of autocomplete options.
record_button (nicegui.widgets.Button): Record button widget.
"""
if not record_proc.is_running():
with ui.dialog() as dialog, ui.card():
ui.label("Enter a name for the recording: ")
ui.input(
label="Name",
placeholder="test",
autocomplete=options,
on_change=lambda e: result.set_text(e),
)
result = ui.label()

with ui.row():
ui.button("Close", on_click=dialog.close)
ui.button("Enter", on_click=lambda: on_record())

dialog.open()

def terminate() -> None:
global record_proc
record_proc.set_terminate_processing()

# wait for process to terminate
record_proc.wait()
ui.notify("Stopped recording")
record_button._props["name"] = "radio_button_checked"
record_button.on("click", lambda: recording_prompt(options, record_button))

record_proc.reset()

def begin() -> None:
name = result.text.__getattribute__("value")

ui.notify(
f"Recording {name}... Press CTRL + C in terminal window to cancel",
)
global record_proc
record_proc.start(
record,
(name, record_proc.terminate_processing, record_proc.terminate_recording),
)
record_button._props["name"] = "stop"
record_button.on("click", lambda: terminate())
record_button.update()

def on_record() -> None:
global record_proc
dialog.close()
begin()
100 changes: 0 additions & 100 deletions openadapt/deprecated/app/main.py

This file was deleted.

42 changes: 0 additions & 42 deletions openadapt/deprecated/app/objects/console.py

This file was deleted.

Loading

0 comments on commit de91850

Please sign in to comment.