Skip to content

Commit

Permalink
feat: Allow pre-submit and post-submit callbacks
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Hughes <[email protected]>

This will allow passing a pre/post submit callback into the deadline
callback which would allow for customization and validation of scenes

Signed-off-by: Alex Hughes <[email protected]>
  • Loading branch information
Ahuge committed Apr 10, 2024
1 parent 4d40b8c commit febec4d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit febec4d

Please sign in to comment.