Skip to content

Commit

Permalink
Optional extension around parameter validation of loaded callback fun…
Browse files Browse the repository at this point in the history
…ction

This will call the `validate_function_signature` function within the new deadline-cloud callback loader to validate the parameters of the loaded callback.py
This is optional as I am unsure how much we care about this. It would fail anyways but this way at least we could raise some error notifying people that the signature looks incorrect.

Signed-off-by: Alex Hughes <[email protected]>
  • Loading branch information
Ahuge committed Apr 19, 2024
1 parent 72035a9 commit 111433b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/deadline/nuke_submitter/deadline_submitter_for_nuke.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ def on_create_job_bundle_callback(
trace=traceback.format_exc()
)
)

if not callback_loader.validate_function_signature(on_pre_submit_callback):
raise DeadlineOperationError(
"Python function at {path}:on_pre_submit_callback does not match function signature: {signature}."
.format(
path=os.environ.get("DEADLINE_PRE_SUBMIT_CALLBACK"),
signature=callback_loader.CALLBACK_REFERENCE_SIGNATURE,
)
)
callback_kwargs["on_pre_submit_callback"] = on_pre_submit_callback

if os.path.exists(os.environ.get("DEADLINE_POST_SUBMIT_CALLBACK", "")):
Expand All @@ -361,6 +370,14 @@ def on_create_job_bundle_callback(
trace=traceback.format_exc()
)
)
if not callback_loader.validate_function_signature(on_post_submit_callback):
raise DeadlineOperationError(
"Python function at {path}:on_post_submit_callback does not match function signature: {signature}."
.format(
path=os.environ.get("DEADLINE_POST_SUBMIT_CALLBACK"),
signature=callback_loader.CALLBACK_REFERENCE_SIGNATURE,
)
)
callback_kwargs["on_post_submit_callback"] = on_post_submit_callback


Expand Down

0 comments on commit 111433b

Please sign in to comment.