Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mention CPU arch name in comment for uploaded test report, if it's known by archspec #3227

Merged
merged 9 commits into from
Mar 30, 2020
25 changes: 25 additions & 0 deletions easybuild/tools/systemtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
_log.debug("Failed to import 'distro' Python module: %s", err)
HAVE_DISTRO = False

try:
from archspec.cpu import host as archspec_cpu_host
HAVE_ARCHSPEC = True
except ImportError as err:
_log.debug("Failed to import 'archspec' Python module: %s", err)
HAVE_ARCHSPEC = False



# Architecture constants
AARCH32 = 'AArch32'
Expand Down Expand Up @@ -344,6 +352,22 @@ def get_cpu_family():
return family


def get_cpu_arch_name():
"""
Determine CPU architecture name via archspec (if available).
"""
cpu_arch_name = None
if HAVE_ARCHSPEC:
res = archspec_cpu_host()
if res:
cpu_arch_name = res.name

if cpu_arch_name is None:
cpu_arch_name = UNKNOWN

return cpu_arch_name


def get_cpu_model():
"""
Determine CPU model, e.g., Intel(R) Core(TM) i5-2540M CPU @ 2.60GHz
Expand Down Expand Up @@ -746,6 +770,7 @@ def get_system_info():
return {
'core_count': get_avail_core_count(),
'total_memory': get_total_memory(),
'cpu_arch_name': get_cpu_arch_name(),
'cpu_model': get_cpu_model(),
'cpu_speed': get_cpu_speed(),
'cpu_vendor': get_cpu_vendor(),
Expand Down
7 changes: 6 additions & 1 deletion easybuild/tools/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from easybuild.tools.jenkins import aggregate_xml_in_dirs
from easybuild.tools.parallelbuild import build_easyconfigs_in_parallel
from easybuild.tools.robot import resolve_dependencies
from easybuild.tools.systemtools import get_system_info
from easybuild.tools.systemtools import UNKNOWN, get_system_info
from easybuild.tools.version import FRAMEWORK_VERSION, EASYBLOCKS_VERSION


Expand Down Expand Up @@ -264,6 +264,11 @@ def post_easyconfigs_pr_test_report(pr_nr, test_report, msg, init_session_state,
'os_version': system_info['os_version'],
'pyver': system_info['python_version'].split(' ')[0],
}

# also mention CPU architecture name, but only if it's known
if system_info['cpu_arch_name'] != UNKNOWN:
short_system_info['cpu_model'] += " (%s)" % system_info['cpu_arch_name']
boegel marked this conversation as resolved.
Show resolved Hide resolved

comment_lines = [
"Test report by @%s" % user,
('**FAILED**', '**SUCCESS**')[success],
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ GC3Pie
python-graph-dot
python-hglib
requests

archspec; python_version >= '2.7'
33 changes: 31 additions & 2 deletions test/framework/systemtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
from easybuild.tools.systemtools import CPU_VENDORS, AMD, APM, ARM, CAVIUM, IBM, INTEL
from easybuild.tools.systemtools import MAX_FREQ_FP, PROC_CPUINFO_FP, PROC_MEMINFO_FP
from easybuild.tools.systemtools import check_python_version, pick_dep_version
from easybuild.tools.systemtools import det_parallelism, get_avail_core_count, get_cpu_architecture, get_cpu_family
from easybuild.tools.systemtools import get_cpu_features, get_cpu_model, get_cpu_speed, get_cpu_vendor
from easybuild.tools.systemtools import det_parallelism, get_avail_core_count, get_cpu_arch_name, get_cpu_architecture
from easybuild.tools.systemtools import get_cpu_family, get_cpu_features, get_cpu_model, get_cpu_speed, get_cpu_vendor
from easybuild.tools.systemtools import get_gcc_version, get_glibc_version, get_os_type, get_os_name, get_os_version
from easybuild.tools.systemtools import get_platform_name, get_shared_lib_ext, get_system_info, get_total_memory

Expand Down Expand Up @@ -338,6 +338,11 @@ def setUp(self):
self.orig_platform_uname = st.platform.uname
self.orig_get_tool_version = st.get_tool_version
self.orig_sys_version_info = st.sys.version_info
self.orig_HAVE_ARCHSPEC = st.HAVE_ARCHSPEC
if hasattr(st, 'archspec_cpu_host'):
self.orig_archspec_cpu_host = st.archspec_cpu_host
else:
self.orig_archspec_cpu_host = None

def tearDown(self):
"""Cleanup after systemtools test."""
Expand All @@ -349,6 +354,9 @@ def tearDown(self):
st.platform.uname = self.orig_platform_uname
st.get_tool_version = self.orig_get_tool_version
st.sys.version_info = self.orig_sys_version_info
st.HAVE_ARCHSPEC = self.orig_HAVE_ARCHSPEC
if self.orig_archspec_cpu_host is not None:
st.archspec_cpu_host = self.orig_archspec_cpu_host
super(SystemToolsTest, self).tearDown()

def test_avail_core_count_native(self):
Expand Down Expand Up @@ -529,6 +537,27 @@ def test_cpu_architecture(self):
MACHINE_NAME = name
self.assertEqual(get_cpu_architecture(), machine_names[name])

def test_cpu_arch_name_native(self):
"""Test getting CPU arch name."""
arch_name = get_cpu_arch_name()
self.assertTrue(isinstance(arch_name, string_type))

def test_cpu_arch_name(self):
"""Test getting CPU arch name."""

class MicroArch(object):
def __init__(self, name):
self.name = name

st.HAVE_ARCHSPEC = True
st.archspec_cpu_host = lambda: MicroArch('haswell')
arch_name = get_cpu_arch_name()
self.assertEqual(arch_name, 'haswell')

st.archspec_cpu_host = lambda: None
arch_name = get_cpu_arch_name()
self.assertEqual(arch_name, 'UNKNOWN')

def test_cpu_vendor_native(self):
"""Test getting CPU vendor."""
cpu_vendor = get_cpu_vendor()
Expand Down