Skip to content

Commit

Permalink
fix: Remove delay after hitting Submit button (#42)
Browse files Browse the repository at this point in the history
Signed-off-by: Esteban Papp <[email protected]>
  • Loading branch information
amznestebanpapp authored Sep 15, 2023
1 parent a122840 commit 28e4114
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 37 deletions.
44 changes: 9 additions & 35 deletions src/deadline/client/ui/dialogs/submit_job_progress_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -279,15 +284,14 @@ 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,
job_bundle_dir,
asset_manager,
deadline,
auto_accept=str2bool(get_setting("settings.auto_accept")),
parent=self,
)
except Exception as exc:
logger.exception("error submitting job")
Expand Down

0 comments on commit 28e4114

Please sign in to comment.