From d1d37603b2d82fe9c4666c7ec492b14677fea766 Mon Sep 17 00:00:00 2001 From: Stephen Crowe Date: Fri, 5 Jul 2024 14:18:58 -0700 Subject: [PATCH 1/2] feat: support skipping prompts for installing GUI dependencies Signed-off-by: Stephen Crowe --- .../client/cli/_groups/bundle_group.py | 9 +++++++-- .../client/cli/_groups/config_group.py | 9 +++++++-- src/deadline/client/ui/__init__.py | 18 +++++++++++------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/deadline/client/cli/_groups/bundle_group.py b/src/deadline/client/cli/_groups/bundle_group.py index b64fda18..7f549f0b 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( + "-y", + is_flag=True, + help="Accept prompts about installing GUI dependencies", +) @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, y, **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=y) 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..46b2ef40 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( + "-y", + is_flag=True, + help="Accept prompts about installing GUI dependencies", +) @_handle_error -def config_gui(): +def config_gui(y: 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=y): 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.*" From 49c0491e7121e498462ea423a7d1d76aa0467a9f Mon Sep 17 00:00:00 2001 From: Stephen Crowe Date: Wed, 10 Jul 2024 13:48:23 -0700 Subject: [PATCH 2/2] Update flag name Signed-off-by: Stephen Crowe --- src/deadline/client/cli/_groups/bundle_group.py | 8 ++++---- src/deadline/client/cli/_groups/config_group.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/deadline/client/cli/_groups/bundle_group.py b/src/deadline/client/cli/_groups/bundle_group.py index 7f549f0b..919e5469 100644 --- a/src/deadline/client/cli/_groups/bundle_group.py +++ b/src/deadline/client/cli/_groups/bundle_group.py @@ -252,9 +252,9 @@ def _decide_cancel_submission(upload_group: AssetUploadGroup) -> bool: help="Allows user to choose Bundle and adds a 'Load a different job bundle' option to the Job-Specific Settings UI", ) @click.option( - "-y", + "--install-gui", is_flag=True, - help="Accept prompts about installing GUI dependencies", + help="Installs GUI dependencies if they are not installed already", ) @click.option( "--output", @@ -269,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, y, **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(automatically_install_dependencies=y) 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 46b2ef40..18c6d882 100644 --- a/src/deadline/client/cli/_groups/config_group.py +++ b/src/deadline/client/cli/_groups/config_group.py @@ -84,18 +84,18 @@ def config_show(): @cli_config.command(name="gui") @click.option( - "-y", + "--install-gui", is_flag=True, - help="Accept prompts about installing GUI dependencies", + help="Installs GUI dependencies if they are not installed already", ) @_handle_error -def config_gui(y: bool): +def config_gui(install_gui: bool): """ Open the workstation configuration settings GUI. """ from ...ui import gui_context_for_cli - with gui_context_for_cli(automatically_install_dependencies=y): + with gui_context_for_cli(automatically_install_dependencies=install_gui): from ...ui.dialogs.deadline_config_dialog import DeadlineConfigDialog DeadlineConfigDialog.configure_settings()