summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-07-01 10:44:46 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2019-07-01 18:36:02 -0700
commit12b9fad7b6bf578cf7d0c942e585e311cc9b4cb7 (patch)
tree7eba293d14096b43992a2d287671ab184938f4af /lib
parent1ad9f6268b7c6da466f9ce33387887dd94c55acd (diff)
downloadspack-12b9fad7b6bf578cf7d0c942e585e311cc9b4cb7.tar.gz
spack-12b9fad7b6bf578cf7d0c942e585e311cc9b4cb7.tar.bz2
spack-12b9fad7b6bf578cf7d0c942e585e311cc9b4cb7.tar.xz
spack-12b9fad7b6bf578cf7d0c942e585e311cc9b4cb7.zip
cray: use the cle-release file to determine CNL version
- CNL OS previously used the *Cray PE* version to determine the OS version. Cray does not synchronize PE and CLE releases; you can run CLE7 with PrgEnv 6 (and NERSC currently does). - Fix Spack's OS detection by using the cle-release file to detect the OS version. This file is updated with every CLE OS release. - Add some tests for our parsing logic
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/operating_systems/cnl.py44
-rw-r--r--lib/spack/spack/test/operating_system.py34
2 files changed, 72 insertions, 6 deletions
diff --git a/lib/spack/spack/operating_systems/cnl.py b/lib/spack/spack/operating_systems/cnl.py
index 2e3b566ede..a64cf5b55f 100644
--- a/lib/spack/spack/operating_systems/cnl.py
+++ b/lib/spack/spack/operating_systems/cnl.py
@@ -7,9 +7,42 @@ import re
import llnl.util.tty as tty
+import spack.version
from spack.architecture import OperatingSystem
from spack.util.module_cmd import module
+#: Location of the Cray CLE release file, which we look at to get the CNL
+#: OS version.
+_cle_release_file = '/etc/opt/cray/release/cle-release'
+
+
+def read_cle_release_file():
+ """Read the CLE release file and return a dict with its attributes.
+
+ The release file looks something like this::
+
+ RELEASE=6.0.UP07
+ BUILD=6.0.7424
+ ...
+
+ The dictionary we produce looks like this::
+
+ {
+ "RELEASE": "6.0.UP07",
+ "BUILD": "6.0.7424",
+ ...
+ }
+
+ """
+ with open(_cle_release_file) as release_file:
+ result = {}
+ for line in release_file:
+ # use partition instead of split() to ensure we only split on
+ # the first '=' in the line.
+ key, _, value = line.partition('=')
+ result[key] = value.strip()
+ return result
+
class Cnl(OperatingSystem):
""" Compute Node Linux (CNL) is the operating system used for the Cray XC
@@ -28,12 +61,11 @@ class Cnl(OperatingSystem):
def __str__(self):
return self.name + str(self.version)
- def _detect_crayos_version(self):
- output = module("avail", "PrgEnv-cray")
- matches = re.findall(r'PrgEnv-cray/(\d+).\d+.\d+', output)
- major_versions = set(matches)
- latest_version = max(major_versions)
- return latest_version
+ @classmethod
+ def _detect_crayos_version(cls):
+ release_attrs = read_cle_release_file()
+ v = spack.version.Version(release_attrs['RELEASE'])
+ return v[0]
def arguments_to_detect_version_fn(self, paths):
import spack.compilers
diff --git a/lib/spack/spack/test/operating_system.py b/lib/spack/spack/test/operating_system.py
new file mode 100644
index 0000000000..1f34354409
--- /dev/null
+++ b/lib/spack/spack/test/operating_system.py
@@ -0,0 +1,34 @@
+# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+import spack.operating_systems.cnl as cnl
+
+
+def test_read_cle_release_file(tmpdir, monkeypatch):
+ """test reading the Cray cle-release file"""
+ cle_release_path = tmpdir.join('cle-release')
+ with cle_release_path.open('w') as f:
+ f.write("""\
+RELEASE=6.0.UP07
+BUILD=6.0.7424
+DATE=20190611
+ARCH=noarch
+NETWORK=ari
+PATCHSET=35-201906112304
+DUMMY=foo=bar
+""")
+
+ monkeypatch.setattr(cnl, '_cle_release_file', str(cle_release_path))
+ attrs = cnl.read_cle_release_file()
+
+ assert attrs['RELEASE'] == '6.0.UP07'
+ assert attrs['BUILD'] == '6.0.7424'
+ assert attrs['DATE'] == '20190611'
+ assert attrs['ARCH'] == 'noarch'
+ assert attrs['NETWORK'] == 'ari'
+ assert attrs['PATCHSET'] == '35-201906112304'
+ assert attrs['DUMMY'] == 'foo=bar'
+
+ assert cnl.Cnl._detect_crayos_version() == 6