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
This commit is contained in:
parent
1ad9f6268b
commit
12b9fad7b6
2 changed files with 72 additions and 6 deletions
|
@ -7,9 +7,42 @@
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
|
|
||||||
|
import spack.version
|
||||||
from spack.architecture import OperatingSystem
|
from spack.architecture import OperatingSystem
|
||||||
from spack.util.module_cmd import module
|
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):
|
class Cnl(OperatingSystem):
|
||||||
""" Compute Node Linux (CNL) is the operating system used for the Cray XC
|
""" Compute Node Linux (CNL) is the operating system used for the Cray XC
|
||||||
|
@ -28,12 +61,11 @@ def __init__(self):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name + str(self.version)
|
return self.name + str(self.version)
|
||||||
|
|
||||||
def _detect_crayos_version(self):
|
@classmethod
|
||||||
output = module("avail", "PrgEnv-cray")
|
def _detect_crayos_version(cls):
|
||||||
matches = re.findall(r'PrgEnv-cray/(\d+).\d+.\d+', output)
|
release_attrs = read_cle_release_file()
|
||||||
major_versions = set(matches)
|
v = spack.version.Version(release_attrs['RELEASE'])
|
||||||
latest_version = max(major_versions)
|
return v[0]
|
||||||
return latest_version
|
|
||||||
|
|
||||||
def arguments_to_detect_version_fn(self, paths):
|
def arguments_to_detect_version_fn(self, paths):
|
||||||
import spack.compilers
|
import spack.compilers
|
||||||
|
|
34
lib/spack/spack/test/operating_system.py
Normal file
34
lib/spack/spack/test/operating_system.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue