feat: add customizable job state notification email templates - #137
Open
faureadr wants to merge 1 commit into
Open
feat: add customizable job state notification email templates#137faureadr wants to merge 1 commit into
faureadr wants to merge 1 commit into
Conversation
This commit introduces the ability for administrators to fully customize the notification emails sent to users upon various job state changes (Running, Terminated, Error, Suspended, Resuming) using simple text templates. It features a robust, safe-fail mechanism: if a configured template is missing, malformed, or contains unknown formatting tags, OAR will gracefully fall back to its default hardcoded notification strings without interrupting the scheduler. Changes included: - oar/lib/job_handling.py: * Implemented `get_custom_notification_message` with safe dictionary mapping and try/except blocks. * Modified `set_job_state` to inject custom templates into `tools.notify_user`, using the `or` operator for seamless fallbacks. - etc/oar/templates/mail/default/: Added 5 default rich-text template examples (mail_running.txt, mail_terminated.txt, mail_error.txt, mail_suspended.txt, mail_resuming.txt). - oar/tools/oar.conf.in: Added commented configuration variables (MAIL_TEMPLATE_RUNNING, MAIL_TEMPLATE_TERMINATED, etc.) to link the templates. - tests/lib/test_job_handling.py: Added `test_get_custom_notification_message` to validate template formatting, missing configs, and bad syntax handling using Pytest. - README.rst: Added a "Features" section to document this new capability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This commit introduces the ability for administrators to fully customize the notification emails sent to users upon various job state changes (Running, Terminated, Error, Suspended, Resuming) using simple text templates.
It features a robust, safe-fail mechanism: if a configured template is missing, malformed, or contains unknown formatting tags, OAR will gracefully fall back to its default hardcoded notification strings without interrupting the scheduler.
Changes
oar/lib/job_handling.py:get_custom_notification_messagewith safe dictionary mapping andtry/exceptblocks.set_job_stateto inject custom templates intotools.notify_user, using theoroperator for seamless fallbacks.etc/oar/templates/mail/default/: Added 5 default rich-text template examples (mail_running.txt,mail_terminated.txt,mail_error.txt,mail_suspended.txt,mail_resuming.txt).oar/tools/oar.conf.in: Added commented configuration variables (MAIL_TEMPLATE_RUNNING,MAIL_TEMPLATE_TERMINATED, etc.) to link the templates.tests/lib/test_job_handling.py: Addedtest_get_custom_notification_messageto validate template formatting, missing configs, and bad syntax handling using Pytest.README.rst: Added a "Features" section to document this new capability.