Python in batch jobs
For a single python script you can use the
python -u my_script.py
-ustands for "unbuffered". You can use the environment variable
PYTHONUNBUFFEREDto set unbuffered I/O for your whole batch script.
#SBATCH -n 1
There is some performance penalty for having unbuffered print statements, so you may want to reduce the number of print statements, or run buffered for production runs.