PageRenderTime 24ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/nightly_test_niflheim.el6.py

https://gitlab.com/marcindulak/gpaw
Python | 119 lines | 115 code | 3 blank | 1 comment | 3 complexity | ad1fa998ecf4ce5722f4d20f5aa3735e MD5 | raw file
  1. #!/usr/bin/python
  2. import os
  3. import sys
  4. import time
  5. import glob
  6. import tempfile
  7. def fail(subject, email=None, filename='/dev/null'):
  8. if email is not None:
  9. assert os.system('mail -s "%s" %s < %s' %
  10. (subject, email, filename)) == 0
  11. raise SystemExit
  12. day = time.localtime()[6]
  13. if '--debug' in sys.argv[1:]:
  14. args = '--debug'
  15. np = 2 ** (1 + (day + 1) % 3)
  16. else:
  17. args = ''
  18. np = 2 ** (1 + day % 3)
  19. if '--dir' in sys.argv:
  20. i = sys.argv.index('--dir')
  21. dir = os.path.abspath(sys.argv[i + 1])
  22. else:
  23. dir = None
  24. if '--email' in sys.argv:
  25. i = sys.argv.index('--email')
  26. email = sys.argv[i + 1]
  27. else:
  28. email = None
  29. # allow overwrite of np
  30. if '--np' in sys.argv:
  31. i = sys.argv.index('--np')
  32. np = int(sys.argv[i + 1])
  33. tmpdir = tempfile.mkdtemp(prefix='gpaw-parallel-', dir=dir)
  34. os.chdir(tmpdir)
  35. # Checkout a fresh version and install:
  36. if os.system('cd ~/gpaw-nightly-tests/gpaw && '
  37. 'git pull > pull.out 2>&1 && '
  38. 'git archive --format tar --prefix gpaw/ HEAD | '
  39. '(cd {0}; tar -xf -)'.format(tmpdir)) != 0:
  40. fail('Checkout of gpaw failed!')
  41. if os.system('cd ~/gpaw-nightly-tests/ase && '
  42. 'git pull > pull.out 2>&1 && '
  43. 'git archive --format tar --prefix ase/ HEAD | '
  44. '(cd {0}; tar -xf -)'.format(tmpdir)) != 0:
  45. fail('Checkout of ASE failed!')
  46. os.chdir('gpaw')
  47. if os.system('source /home/opt/modulefiles/modulefiles_el6.sh&& ' +
  48. 'export PYTHONDONTWRITEBYTECODE=1&& ' +
  49. 'module load NUMPY/1.7.1-1&& ' +
  50. 'module load intel-compilers&& ' +
  51. 'module load openmpi&& ' +
  52. 'python setup.py --remove-default-flags ' +
  53. '--customize=doc/platforms/Linux/Niflheim/sl230s.py ' +
  54. 'install --home=%s 2>&1 | ' % tmpdir +
  55. 'grep -v "c/libxc/src"') != 0:
  56. fail('Installation failed!')
  57. os.system('mv ../ase/ase ../lib64/python')
  58. # import gpaw from where it was installed
  59. sys.path.insert(0, '%s/%s/python' % (tmpdir, 'lib64'))
  60. # this import requires numpy!
  61. from gpaw import __version__
  62. os.system('wget --no-check-certificate --quiet ' +
  63. 'http://wiki.fysik.dtu.dk/gpaw-files/gpaw-setups-latest.tar.gz')
  64. os.system('tar xvzf gpaw-setups-latest.tar.gz')
  65. setups = tmpdir + '/gpaw/' + glob.glob('gpaw-setups-[0-9]*')[0]
  66. # Run test-suite:
  67. print('Run')
  68. if os.system('source /home/opt/modulefiles/modulefiles_el6.sh&& ' +
  69. 'export PYTHONDONTWRITEBYTECODE=1&& ' +
  70. 'module load NUMPY/1.7.1-1&& ' +
  71. 'module load SCIPY/0.12.0-1&& ' +
  72. 'module load SCIENTIFICPYTHON&& ' +
  73. 'module load CMR&& ' +
  74. 'module load intel-compilers&& ' +
  75. 'module load openmpi&& ' +
  76. # libfftw3.so crashes
  77. 'module unload fftw&& ' + # all fftw must be unloaded
  78. 'export GPAW_FFTWSO=""&& ' + # and use numpy fftw
  79. 'export PYTHONPATH=%s/lib64/python:$PYTHONPATH; ' % tmpdir +
  80. 'export GPAW_SETUP_PATH=%s; ' % setups +
  81. 'export OMP_NUM_THREADS=1; ' +
  82. 'mpiexec -np %d ' % np +
  83. tmpdir + '/bin/gpaw-python ' +
  84. 'tools/gpaw test %s >& test.out' % args) != 0:
  85. fail('GPAW %s: Testsuite crashed!' % str(__version__), email, 'test.out')
  86. try:
  87. failed = open('failed-tests.txt').readlines()
  88. except IOError:
  89. pass
  90. else:
  91. # Send mail:
  92. n = len(failed)
  93. if n == 1:
  94. subject = 'One failed test: ' + failed[0][:-1]
  95. else:
  96. subject = '%d failed tests: %s, %s' % (n,
  97. failed[0][:-1], failed[1][:-1])
  98. if n > 2:
  99. subject += ', ...'
  100. subject = 'GPAW %s: ' % str(__version__) + subject
  101. fail(subject, email, 'test.out')
  102. print('Done')
  103. os.system('cd; rm -rf ' + tmpdir)