diff --git a/src/deadline/client/cli/_groups/bundle_group.py b/src/deadline/client/cli/_groups/bundle_group.py index b64fda18..919e5469 100644 --- a/src/deadline/client/cli/_groups/bundle_group.py +++ b/src/deadline/client/cli/_groups/bundle_group.py @@ -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( @@ -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: diff --git a/src/deadline/client/cli/_groups/config_group.py b/src/deadline/client/cli/_groups/config_group.py index 0a68faf1..18c6d882 100644 --- a/src/deadline/client/cli/_groups/config_group.py +++ b/src/deadline/client/cli/_groups/config_group.py @@ -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() diff --git a/src/deadline/client/ui/__init__.py b/src/deadline/client/ui/__init__.py index b48d22d4..e61dd96e 100644 --- a/src/deadline/client/ui/__init__.py +++ b/src/deadline/client/ui/__init__.py @@ -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 @@ -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.*"