Skip to content
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

feat: support skipping prompts for installing GUI dependencies #395

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
epmog marked this conversation as resolved.
Show resolved Hide resolved
"""
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
Loading