Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openadapt/app/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def populate_menu(self, menu: QMenu, action: Callable, action_type: str) -> None
menu.addAction(no_recordings_action)
self.recording_actions[action_type].append(no_recordings_action)
else:
for idx, recording in enumerate(recordings):
for recording in recordings:
formatted_timestamp = datetime.fromtimestamp(
recording.timestamp
).strftime("%Y-%m-%d %H:%M:%S")
Expand Down
5 changes: 3 additions & 2 deletions openadapt/start.py → openadapt/deprecated/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
Usage:
python3 -m openadapt.start
"""

import subprocess

from loguru import logger

from openadapt.app.main import run_app
from openadapt.app.main import start


def main() -> None:
Expand All @@ -24,7 +25,7 @@ def main() -> None:
subprocess.run(["git", "pull", "-q"])
logger.info("Updated the OpenAdapt App")

run_app() # start gui
start() # start gui

@abrichr abrichr Jun 18, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shashank40 thank you for putting this together!

@KIRA009 do you know whether we are using this file openadapt/start.py anywhere? Git blame shows last update was about a year go

@shashank40 I think this file is deprecated. Can you please clarify what caused you to attempt to run it? If it's documented somewhere we should clarify that it is deprecated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not. This script looks like it updates the state of your local repo, but I don't think this is needed any more now that we have apps

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abrichr @KIRA009 as my app was not working after download, i used this script to spin up the app.

python -m openadapter.start runs a client for us and that is what i used this for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shashank40 please feel free to move this file to openadapt/deprecated, and remove any mention of it in any documentation that you encountered 🙏

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shashank40 Sorry for being confused, but when you say the app wasn't working in the first instance, did you mean the compiled version (the link you find on https://openadapt.ai/) or did you set it up manually from the git repo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KIRA009
I meant the compiled app as i commented here.
#771 (comment)



if __name__ == "__main__":
Expand Down
14 changes: 7 additions & 7 deletions openadapt/strategies/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ class VanillaReplayStrategy(strategies.base.BaseReplayStrategy):
def __init__(
self,
recording: models.Recording,
replay_instructions: str = "",
instructions: str = "",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shashank40 if you remove the rest of this PR and only include the changes to this file I will be happy to merge it 👍

process_events: bool = PROCESS_EVENTS,
) -> None:
"""Initialize the VanillaReplayStrategy.

Args:
recording (models.Recording): The recording object.
replay_instructions (str): Natural language instructions
instructions (str): Natural language instructions
for how recording should be replayed.
process_events (bool): Flag indicating whether to process the events.
Defaults to True.
"""
super().__init__(recording)
self.replay_instructions = replay_instructions
self.instructions = instructions
self.process_events = process_events
self.action_history = []
self.action_event_idx = 0
Expand Down Expand Up @@ -89,7 +89,7 @@ def get_next_action_event(
window_event,
action_events,
self.action_history,
self.replay_instructions,
self.instructions,
)
if not action_event:
raise StopIteration()
Expand Down Expand Up @@ -161,7 +161,7 @@ def generate_action_event(
current_window_event: models.WindowEvent,
recorded_actions: list[models.ActionEvent],
replayed_actions: list[models.ActionEvent],
replay_instructions: str,
instructions: str,
) -> models.ActionEvent:
"""Modify the given ActionEvents according to the given replay instructions.

Expand All @@ -176,7 +176,7 @@ def generate_action_event(
recording
replayed_actions (list[models.ActionEvent]): list of actions produced during
current replay
replay_instructions (str): proposed modifications in natural language
instructions (str): proposed modifications in natural language
instructions

Returns:
Expand All @@ -195,7 +195,7 @@ def generate_action_event(
current_window=current_window_dict,
recorded_actions=recorded_action_dicts,
replayed_actions=replayed_action_dicts,
replay_instructions=replay_instructions,
replay_instructions=instructions,
)
prompt_adapter = adapters.get_default_prompt_adapter()
content = prompt_adapter.prompt(
Expand Down
24 changes: 17 additions & 7 deletions openadapt/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ def dict2html(
children = indicate_missing(children, all_children, "...")
html_str = "\n".join(children)
elif isinstance(obj, dict):
rows_html = "\n".join([f"""
rows_html = "\n".join(
[
f"""
<tr>
<th>{format_key(key, value)}</th>
<td>{dict2html(value, max_children)}</td>
</tr>
""" for key, value in obj.items() if value not in EMPTY])
"""
for key, value in obj.items()
if value not in EMPTY
]
)
html_str = f"<table>{rows_html}</table>"
else:
html_str = html.escape(str(obj))
Expand All @@ -154,8 +160,8 @@ def dict2html(

@logger.catch
def main(
recording: Recording = None,
recording_id: int = None,
recording: Recording = None,
diff_video: bool = False,
cleanup: bool = True,
) -> bool:
Expand Down Expand Up @@ -223,7 +229,8 @@ def main(
if SCRUB:
recording_dict = scrub.scrub_dict(recording_dict)

CSS = string.Template("""
CSS = string.Template(
"""
table {
outline: 1px solid black;
}
Expand Down Expand Up @@ -257,7 +264,8 @@ def main(
.screenshot:active img:nth-child(3) {
display: block;
}
""").substitute(
"""
).substitute(
IMG_WIDTH_PCT=IMG_WIDTH_PCT,
)

Expand Down Expand Up @@ -381,11 +389,13 @@ def main(
</table>
""",
),
Div(text=f"""
Div(
text=f"""
<table>
{dict2html(action_event_dict)}
</table>
"""),
"""
),
),
]
)
Expand Down