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 6ac2074d1..c561b725f 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 @@ -67,6 +67,13 @@ class SubmitJobToDeadlineDialog(QDialog): attachments: (FlatAssetReferences): The job attachments that have been added to the job by the user. on_create_job_bundle_callback: A function to call when the dialog needs to create a Job Bundle. It is called with arguments (widget, job_bundle_dir, settings, queue_parameters, asset_references) + on_pre_submit_callback: A function to call just prior to the dialog submitting the Job Bundle. It is + called with arguments (widget, job_bundle_dir, settings, queue_parameters, asset_references). + This callback can be used to validate or modify a scene file before submitting. + on_post_submit_callback: A function to call just after the dialog has submitted the Job Bundle. It + is called with arguments (widget, job_bundle_dir, settings, queue_parameters, asset_references). + This callback may may be required if the `on_pre_submit_callback` modifies the scene file to + prepare it for submission and work needs to be done to modify the scene back to a working state. parent: parent of the widget f: Qt Window Flags show_host_requirements_tab: Display the host requirements tab in dialog if set to True. Default @@ -82,6 +89,8 @@ def __init__( auto_detected_attachments: AssetReferences, attachments: AssetReferences, on_create_job_bundle_callback, + on_pre_submit_callback=None, + on_post_submit_callback=None, parent=None, f=Qt.WindowFlags(), show_host_requirements_tab=False, @@ -93,6 +102,8 @@ def __init__( self.job_settings_type = type(initial_job_settings) self.on_create_job_bundle_callback = on_create_job_bundle_callback + self.on_pre_submit_callback = on_pre_submit_callback + self.on_post_submit_callback = on_post_submit_callback self.create_job_response: Optional[Dict[str, Any]] = None self.deadline_authentication_status = DeadlineAuthenticationStatus.getInstance() self.show_host_requirements_tab = show_host_requirements_tab @@ -400,6 +411,18 @@ def on_submit(self): # Submit the job try: + # Execute any PreSubmission function defined. + if self.on_pre_submit_callback: + self.on_pre_submit_callback( + self, + job_history_bundle_dir, + settings, + queue_parameters, + asset_references, + purpose=JobBundlePurpose.SUBMISSION + ) + + deadline = api.get_boto3_client("deadline") job_history_bundle_dir = create_job_history_bundle_dir( @@ -470,6 +493,17 @@ def on_submit(self): deadline, auto_accept=str2bool(get_setting("settings.auto_accept")), ) + + # Execute any PostSubmission function defined. + if self.on_post_submit_callback: + self.on_post_submit_callback( + self, + job_history_bundle_dir, + settings, + queue_parameters, + asset_references, + purpose=JobBundlePurpose.SUBMISSION + ) except UserInitiatedCancel as uic: logger.info("Canceling submission.") QMessageBox.information(self, f"{settings.submitter_name} Job Submission", str(uic))