-
-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor config and pyinstaller build #618
Conversation
508b7b8
to
c4e36c5
Compare
6413723
to
6d95768
Compare
ca04a15
to
f269ecf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work! I left a few comments, please let me know if you would like to chat about any of it 🙏
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Pythonx` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
openadapt/entrypoint.py
Outdated
|
||
|
||
from openadapt.alembic.context_loader import load_alembic_context | ||
from openadapt.app import tray # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is noqa
required here?
openadapt/record.py
Outdated
@@ -967,11 +972,15 @@ def read_mouse_events( | |||
@trace(logger) | |||
def record( | |||
task_description: str, | |||
terminate_event: multiprocessing.Event = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about renaming this terminate_process
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it makes sense, this flag is mostly used as a way to stop from reading and processing events, so maybe terminate_event_processing
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or terminate_processing
to be more terse, either works
openadapt/build_utils.py
Outdated
sys.stdout = self.old_stdout | ||
sys.stderr = self.old_stderr | ||
|
||
return StdoutStderrOverride() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about this slight refactor:
def is_running_from_executable() -> bool:
"""Determine if the Python script is running as an executable."""
return getattr(sys, 'frozen', False)
class RedirectOutput:
"""Context manager to redirect stdout and stderr to /dev/null."""
def __enter__(self) -> 'RedirectOutput':
if is_running_from_executable():
self.old_stdout = sys.stdout
self.old_stderr = sys.stderr
null_stream = open(os.devnull, 'a')
sys.stdout = sys.stderr = null_stream
return self
def __exit__(self, exc_type: type, exc_value: Exception, traceback: type) -> None:
if is_running_from_executable():
sys.stdout.close()
sys.stderr.close()
sys.stdout = self.old_stdout
sys.stderr = self.old_stderr
def redirect_stdout_stderr() -> RedirectOutput:
"""Get the RedirectOutput instance for use as a context manager."""
return RedirectOutput()
- Open /dev/null once and assign it to both stdout and stderr to avoid opening it twice.
__enter__
properly returns an instance of the class itself ('RedirectOutput').__exit__
ensures that the original streams are restored even if an exception occurs within the block.
f269ecf
to
1ae5c75
Compare
@KIRA009 there appears to be a regression affecting the pipes at the end of a recording: bug.movThe progress bar appears to complete before all events are saved. This behavior does not happen on |
1b4d52b
to
d669d08
Compare
d669d08
to
7c8345f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
What kind of change does this PR introduce?
This PR changes the config to use json files, and exposes some configuration for modifications through the dashboard. This PR also adds build scripts to create executables for both macos and windows os-es.
Screen.Recording.2024-04-20.at.10.58.44.PM.mov
Summary
This PR adds a page to the dashboard that will allow users to alter certain configuration settings for the project.
It also modifies the release workflow to add a build step that builds the executables for windows and macos, and then uploads them as artifacts to the latest release
Checklist
How can your code be run and tested?
To build the project into an executable app, run the following command in a poetry shell
To run the project, you can now use the following command in a poetry shell