Skip to content

Commit

Permalink
feat: support skipping prompts for installing GUI dependencies (#395)
Browse files Browse the repository at this point in the history
* feat: support skipping prompts for installing GUI dependencies

Signed-off-by: Stephen Crowe <[email protected]>
  • Loading branch information
crowecawcaw authored Jul 11, 2024
1 parent 8f21717 commit 74293ac
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
9 changes: 7 additions & 2 deletions src/deadline/client/cli/_groups/bundle_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ def _decide_cancel_submission(upload_group: AssetUploadGroup) -> bool:
is_flag=True,
help="Allows user to choose Bundle and adds a 'Load a different job bundle' option to the Job-Specific Settings UI",
)
@click.option(
"--install-gui",
is_flag=True,
help="Installs GUI dependencies if they are not installed already",
)
@click.option(
"--output",
type=click.Choice(
Expand All @@ -264,13 +269,13 @@ def _decide_cancel_submission(upload_group: AssetUploadGroup) -> bool:
"parsed/consumed by custom scripts.",
)
@_handle_error
def bundle_gui_submit(job_bundle_dir, browse, output, **args):
def bundle_gui_submit(job_bundle_dir, browse, output, install_gui, **args):
"""
Opens GUI to submit an Open Job Description job bundle to AWS Deadline Cloud.
"""
from ...ui import gui_context_for_cli

with gui_context_for_cli() as app:
with gui_context_for_cli(automatically_install_dependencies=install_gui) as app:
from ...ui.job_bundle_submitter import show_job_bundle_submitter

if not job_bundle_dir and not browse:
Expand Down
9 changes: 7 additions & 2 deletions src/deadline/client/cli/_groups/config_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ def config_show():


@cli_config.command(name="gui")
@click.option(
"--install-gui",
is_flag=True,
help="Installs GUI dependencies if they are not installed already",
)
@_handle_error
def config_gui():
def config_gui(install_gui: bool):
"""
Open the workstation configuration settings GUI.
"""
from ...ui import gui_context_for_cli

with gui_context_for_cli():
with gui_context_for_cli(automatically_install_dependencies=install_gui):
from ...ui.dialogs.deadline_config_dialog import DeadlineConfigDialog

DeadlineConfigDialog.configure_settings()
Expand Down
18 changes: 11 additions & 7 deletions src/deadline/client/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,22 @@ def gui_error_handler(message_title: str, parent: Any = None):


@contextmanager
def gui_context_for_cli():
def gui_context_for_cli(automatically_install_dependencies: bool):
"""
A context manager that initializes a Qt GUI context for
the CLI handler to use.
For example:
with gui_context_for_cli() as app:
with gui_context_for_cli(automatically_install_dependencies) as app:
from deadline.client.ui.cli_job_submitter import show_cli_job_submitter
show_cli_job_submitter()
app.exec()
If automatically_install_dependencies is true, dependencies will be installed without prompting the user. Useful
if the command is triggered not from a command line.
"""
import importlib
import os
Expand All @@ -73,11 +76,12 @@ def gui_context_for_cli():
has_pyside6 = importlib.util.find_spec("PySide6")
has_pyside2 = importlib.util.find_spec("PySide2")
if not (has_pyside6 or has_pyside2):
message = "Optional GUI components for deadline are unavailable. Would you like to install PySide?"
will_install_gui = click.confirm(message, default=False)
if not will_install_gui:
click.echo("Unable to continue without GUI, exiting")
sys.exit(1)
if not automatically_install_dependencies:
message = "Optional GUI components for deadline are unavailable. Would you like to install PySide?"
will_install_gui = click.confirm(message, default=False)
if not will_install_gui:
click.echo("Unable to continue without GUI, exiting")
sys.exit(1)

# this should match what's in the pyproject.toml
pyside6_pypi = "PySide6-essentials==6.6.*"
Expand Down

0 comments on commit 74293ac

Please sign in to comment.