Skip to content

Commit

Permalink
fix: slightly clearer logic for disable terminal ui
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Oct 5, 2023
1 parent 6a119e7 commit 5cfa9b0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions worker/workers/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ def __init__(self, this_model_manager, this_bridge_data):
def startup_terminal_ui(self):
# Setup UI if requested
in_notebook = hasattr(__builtins__, "__IPYTHON__")
if not in_notebook and not self.bridge_data.disable_terminal_ui:
# Don't allow this if auto-downloading is not enabled as how will the user see download prompts?
if hasattr(self.bridge_data, "always_download") and not self.bridge_data.always_download:
logger.warning("Terminal UI can not be enabled without also enabling 'always_download'")
else:
from worker.ui import TerminalUI
if in_notebook:
return

if self.bridge_data.disable_terminal_ui:
return

# Don't allow this if auto-downloading is not enabled as how will the user see download prompts?
if hasattr(self.bridge_data, "always_download") and not self.bridge_data.always_download:
logger.warning("Terminal UI can not be enabled without also enabling 'always_download'")
else:
from worker.ui import TerminalUI

self.ui_class = TerminalUI(self.bridge_data)
self.ui = threading.Thread(target=self.ui_class.run, daemon=True)
self.ui.start()
self.ui_class = TerminalUI(self.bridge_data)
self.ui = threading.Thread(target=self.ui_class.run, daemon=True)
self.ui.start()

def on_restart(self):
"""Called when the worker loop is restarted. Make sure to invoke super().on_restart() when overriding."""
Expand Down

0 comments on commit 5cfa9b0

Please sign in to comment.