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

fix: Remove delay after hitting Submit button #42

Merged
merged 3 commits into from
Sep 15, 2023
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
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