7.9. Templated email

7.9.1. Overview

The templated email task supports custom templates using Jinja2. Templates allow you to control the structure and content of notification emails generated by the templated_email task.

If no template is provided, a default template will be used.

7.9.2. Default Template

If no template is provided, the system uses a default template:

Job {{ jobid }} completed

Total paths: {{ path_count }}

Files:
- <each file path>

7.9.3. Supported Placeholders

The following placeholders are available and will be replaced at runtime:

Placeholder

Type

Description

{{ jobid }}

string

Job ID

{{ paths }}

list

List of processed and skipped file paths

{{ path_count }}

integer

Total number of processed/skipped files

Note

Currently, only the placeholders listed above are supported.

7.9.4. Example Template

Job {{ jobid }} completed successfully.

Total files processed: {{ path_count }}

Files:
{% for p in paths %}
- {{ p }}
{% endfor %}

7.9.5. Usage

Provide the template file path when triggering the task:

from arcapix.dynamo.server.tasks.mailtemplate import templated_email

templated_email(
    jobid="12345",
    email_from="noreply@example.com",
    email_to=["user@example.com"],
    paths=[{"path": "/mmfs1/data/file1"}, {"path": "/mmfs1/data/file2"}],
    template="/path/to/template.txt"
)

7.9.6. Template Requirements

  • Templates must follow Jinja2 syntax

  • Only the documented placeholders are supported

  • The template file must exist on the worker node where the task will run. If the worker runs on multiple nodes in a site, place the template in a location all nodes can access, such as under /mmfs1