Run massive simulations when your client needs it. Pay nothing when they don’t.
Note: This tutorial shows how to use observer events to automatically monitor SWASH simulation error files and get notified when problems occur.
For a comprehensive guide on observer events with more advanced features and examples, see the full Observer Events tutorial.
When running SWASH simulations, errors can occur that might not immediately stop the simulation but indicate problems that need attention. SWASH writes error information to files like Errfile-001, Errfile-002, etc., where the number corresponds to the vCPU that encountered the error. Manually checking these files is tedious, especially for long-running simulations.
Use Inductiva's observer events to automatically monitor your SWASH simulation's error files and get email notifications when severe errors are detected.
Here's how to set up automatic error monitoring for your SWASH simulation:
from inductiva import events
# Register an observer to monitor any Errfile for severe errors
events.register(
trigger=events.triggers.ObserverFileRegex(
task_id=task.id,
file_path="Errfile-*", # Wildcard matches Errfile-001, Errfile-002, etc.
regex=r"Severe error (.+)"), # Captures text after "Severe error "
action=events.actions.EmailNotification(
email_address="your@email.com")
)
Errfile-* in your task's working directory (e.g., Errfile-001, Errfile-002, etc.)* wildcards to match multiple error files, ensuring you catch errors from any vCPU that encounters problemsr"Severe error (.+)" detects lines containing "Severe error " and captures the error message that followsThe Errfile-* pattern uses Linux-style wildcard matching to monitor multiple error files:
Errfile-* matches any file starting with "Errfile-" followed by any charactersErrfile-001, Errfile-002, Errfile-003, etc.You can modify the regex pattern to detect different types of errors:
# Detect any error (case insensitive)
regex=r"(?i)error"
# Detect specific error types
regex=r"(?i)(fatal|critical|severe) error"
# Detect errors with specific patterns
regex=r"Error \d+: .*"
When a severe error is detected, you'll receive an email:

Here's a complete example of running a SWASH simulation with error monitoring:
import inductiva
swash = inductiva.simulators.SWASH()
task = swash.run(...)
# Set up error monitoring after creating the task
events.register(
trigger=events.triggers.ObserverFileRegex(
task_id=task.id,
file_path="Errfile-*", # Wildcard matches any Errfile
regex=r"Severe error (.+)"),
action=events.actions.EmailNotification(
email_address="your@email.com")
)
# The observer will automatically monitor for errors during execution
This approach ensures you're immediately aware of any issues with your SWASH simulation, allowing you to take corrective action without delay.