You’ve mastered your domain. Let us handle the infrastructure.
Note: This tutorial demonstrates passive tracking, where observer triggers run on the background and automatically send notifications when events occur. For active tracking, refer to the Real-Time Monitoring & Auto Termination tutorial, where monitoring runs on your local machine.
Simulations often produce subtle signals instead of outright failures:
error.log, done.flag, or Errfile-001) indicating success, warning, or failure.ERROR, WARNING, convergence stats).Errfile-001, Errfile-002, etc., where the number corresponds to the process or thread that encountered the error).Manually monitoring these events is tedious and error-prone, especially for long-running or multiple parallel tasks.
Inductiva's observer events let you watch for file or log events and automatically take action, such as sending an email.
Key features:
* patterns (e.g., Errfile-* to match Errfile-001, Errfile-002, etc.).done flag appears.( … ) allow you to capture important parts of a line, such as:
💡 If you are new to regex, see the official Python regex guide:
https://docs.python.org/3/library/re.html
Inductiva provides two main observer trigger classes for monitoring file events:
Detects when a specific file appears in your task's working directory.
Parameters:
task_id (str): The ID of the task to monitorfile_path (str): The path of the file to watch for (relative to task directory). Supports wildcard patterns like Errfile-* to match multiple files.Use cases: Completion flags, error files, or other milestone files. Wildcard patterns are useful for monitoring multiple files from parallel simulations.
Detects patterns inside log files using regular expressions.
Parameters:
task_id (str): The ID of the task to monitorfile_path (str): The path of the log file to monitor. Supports wildcard patterns like Errfile-* to monitor multiple files.regex (str): Regular expression pattern to match against file contentsUse cases: Error detection, progress tracking, value monitoring with captured groups. Wildcard patterns are useful for monitoring files from multiple processes in parallel simulations.
💡 If you are new to regex, see the official Python regex guide: https://docs.python.org/3/library/re.html
The EmailNotification action sends email alerts when observer triggers are activated.
Parameters:
email_address (str): The email address to send notifications toOnce you understand the observer classes, you can register them using events.register():
from inductiva import events
# Register an observer that triggers when "done.flag" appears
events.register(
trigger=events.triggers.ObserverFileExists(
task_id=task.id,
file_path="done.flag"),
action=events.actions.EmailNotification(
email_address="your@email.com")
)
Result: You'll receive an email when the done.flag file is created.
Email received:

from inductiva import events
# Register an observer that triggers when any error file appears
# Useful for parallel simulations where errors can occur on any process
events.register(
trigger=events.triggers.ObserverFileExists(
task_id=task.id,
file_path="Errfile-*"), # Matches Errfile-001, Errfile-002, etc.
action=events.actions.EmailNotification(
email_address="your@email.com")
)
Result: You'll receive an email when any error file is created, regardless of which process encountered the error.
from inductiva import events
# Register an observer that triggers on error patterns in logs
# Regex captures groups: (\d+) = step number, (.+) = error message
events.register(
trigger=events.triggers.ObserverFileRegex(
task_id=task.id,
file_path="output.log",
regex=r"ERROR at step (\d+): (.+)"), # Capture step and message
action=events.actions.EmailNotification(
email_address="your@email.com")
)
Result: You'll receive an email whenever a line in output.log matches the error pattern.
Regex Explanation:
ERROR at step (\d+): (.+) matches error messages with step numbers(\d+): captures the step number(.+): captures the error messageExample: If a log line reads ERROR at step 42: Overflow in calculation, then:
(\d+) captures 42(.+) captures Overflow in calculationEmail received:

Observers are an easy-to-use and flexible mechanism for monitoring simulation progress and automatically responding to important events.