From ce4ad06890cba7acc0f5949c7c86832cb3a2690d Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Thu, 14 Sep 2023 18:09:29 -0700 Subject: [PATCH] fix: Remove delay after hitting Submit button Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- .../ui/dialogs/submit_job_progress_dialog.py | 44 ++++--------------- .../dialogs/submit_job_to_deadline_dialog.py | 8 +++- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/src/deadline/client/ui/dialogs/submit_job_progress_dialog.py b/src/deadline/client/ui/dialogs/submit_job_progress_dialog.py index e0954f71..a6390b13 100644 --- a/src/deadline/client/ui/dialogs/submit_job_progress_dialog.py +++ b/src/deadline/client/ui/dialogs/submit_job_progress_dialog.py @@ -70,21 +70,23 @@ class SubmitJobProgressDialog(QDialog): hashing_thread_progress_report = Signal(ProgressReportMetadata) upload_thread_progress_report = Signal(ProgressReportMetadata) - @staticmethod + def __init__(self, parent: QWidget) -> None: + super().__init__(parent=parent) + self._build_ui() + def start_submission( + self, farm_id: str, queue_id: str, storage_profile_id: str, job_bundle_dir: str, asset_manager: S3AssetManager, deadline_client: BaseClient, - parent: QWidget = None, auto_accept: bool = False, ) -> Optional[Dict[str, Any]]: """ - Static method that runs the SubmitJobProgressDialog. Returns the response - from calling create job. If an error occurs or the submission is canceled - then None is returned. + Starts a submission. Returns the response from calling create job. If an error occurs + or the submission is canceled then None is returned. Args: farm_id (str): Id of the farm to submit to @@ -96,37 +98,9 @@ def start_submission( asset_manager (S3AssetManager): A job attachments S3AssetManager configured for the farm/queue to submit to deadline_client (BaseClient): A boto client for Amazon Deadline Cloud - parent (QWidget): Parent widget of the dialog. auto_accept (bool, default False): Flag for whether any confirmation prompts should automatically be accepted. - config (ConfigParser, optional): The Amazon Deadline Cloud configuration object to - use instead of the config file. - """ - job_progress_dialog = SubmitJobProgressDialog( - farm_id, - queue_id, - storage_profile_id, - job_bundle_dir, - asset_manager, - deadline_client, - parent=parent, - auto_accept=auto_accept, - ) - return job_progress_dialog.exec() - - def __init__( - self, - farm_id: str, - queue_id: str, - storage_profile_id: str, - job_bundle_dir: str, - asset_manager: S3AssetManager, - deadline_client: BaseClient, - parent: QWidget = None, - auto_accept: bool = False, - ) -> None: - super().__init__(parent=parent) - + """ self._farm_id = farm_id self._queue_id = queue_id self._storage_profile_id = storage_profile_id @@ -143,8 +117,8 @@ def __init__( self.__upload_thread: Optional[threading.Thread] = None self.__create_job_thread: Optional[threading.Thread] = None - self._build_ui() self._start_submission() + return self.exec() def _build_ui(self): """Builds up the Dialog UI""" diff --git a/src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py b/src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py index abe53ed0..a50c0d29 100644 --- a/src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py +++ b/src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py @@ -11,6 +11,7 @@ from PySide2.QtCore import QSize, Qt # pylint: disable=import-error from PySide2.QtGui import QKeyEvent # pylint: disable=import-error from PySide2.QtWidgets import ( # pylint: disable=import-error; type: ignore + QApplication, QDialog, QDialogButtonBox, QFormLayout, @@ -252,6 +253,10 @@ def on_submit(self): asset_references = self.job_attachments.get_asset_references() + job_progress_dialog = SubmitJobProgressDialog(parent=self) + job_progress_dialog.show() + QApplication.instance().processEvents() + # Submit the job try: deadline = api.get_boto3_client("deadline") @@ -279,7 +284,7 @@ def on_submit(self): session=queue_role_session, ) - self.create_job_response = SubmitJobProgressDialog.start_submission( + self.create_job_response = job_progress_dialog.start_submission( farm_id, queue_id, storage_profile_id, @@ -287,7 +292,6 @@ def on_submit(self): asset_manager, deadline, auto_accept=str2bool(get_setting("settings.auto_accept")), - parent=self, ) except Exception as exc: logger.exception("error submitting job")