Skip to content

Add --mail-type and --mail-user arguments

Lex Gallon requested to merge add-email-args into master

How did I test this?

First install my patched smux:

  1. On my laptop, scp -rp smux/ lexg@m3-login3:/scratch/nq46/lexg/smux2.
  2. On M3, cd /scratch/nq46/lexg/smux2.
  3. python -m venv venv
  4. . venv/bin/activate
  5. pip install .

With my venv loaded and patched smux installed, verify that --help works properly:

(venv) [lexg@m3-login3 smux2 (master)]$ smux new-session --help
usage: smux new-session [-h] [--ntasks <n>] [--nodes <n>] [--mem <n>] [--cpuspertask <n>] [--qos <n>] [-J <n>]
                        [-A <n>] [-p PARTITION] [-r RESERVATION] [-t TIME] [--gres <n>] [-o <n>] [-e <n>]
                        [--mail-type <n>] [--mail-user <n>]
...

  --mail-type <n>       Notify user by email when certain event types occur
                        (https://slurm.schedmd.com/srun.html#OPT_mail-type)
  --mail-user <n>       User to receive email notification of state changes as defined by --mail-type
                        (https://slurm.schedmd.com/srun.html#OPT_mail-user)

And I confirmed that setting --mail-type and --mail-user indeed resulted in emails being sent to my inbox (see job ID 42013037).

smux new-session --mail-user=lex.gallon@monash.edu --mail-type=ALL

Double-confirm by checking sacct: Confirm the flags were set in the corresponding job command too:

(venv) [lexg@m3-login3 smux2 (master)]$ sacct -j 42013037 --format=SubmitLine%140
                                                                                                                                  SubmitLine 
-------------------------------------------------------------------------------------------------------------------------------------------- 
         sbatch --ntasks 1 -J interactive_session --mail-type=ALL --mail-user=lex.gallon@monash.edu --output=smux-%j.out --error=smux-%j.err 
                                                                                                                                             
                                                                                                                                             
                                                        srun --pty -O --ntasks 1 --jobid 42013037 tmux attach-session -t interactive_session 

And also confirm that not setting those arguments results in no emails being sent, as expected.

smux new-session

Merge request reports

Loading