Skip to content

Commit

Permalink
Merge 325a8fc into cfc2335
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed May 23, 2024
2 parents cfc2335 + 325a8fc commit bc34c5b
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/mac_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: ARMI MacOS Tests

on:
push:
paths-ignore:
- 'doc/**'
pull_request:
paths-ignore:
- 'doc/**'

jobs:
build:

runs-on: macos-14

steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Upgrade PIP
run: python -m pip install --upgrade pip
- name: Run Unit Tests on MacOS
run: |
brew install openmpi
pip install -e .[memprof,mpi,test]
pytest -x armi
29 changes: 28 additions & 1 deletion armi/bookkeeping/report/reportingUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,31 @@ def _getSystemInfoWindows():
return subprocess.run(cmd, capture_output=True, text=True, shell=True).stdout


def _getSystemInfoMac():
"""Get system information, assuming the system is MacOS.
Returns
-------
str
Basic system information: OS name, OS version, basic processor information
Examples
--------
Example results:
System Software Overview:
System Version: macOS 12.1 (21C52)
Kernel Version: Darwin 21.2.0
...
Hardware Overview:
Model Name: MacBook Pro
...
"""
cmd = "system_profiler SPSoftwareDataType SPHardwareDataType"
return subprocess.check_output(cmd, shell=True).decode("utf-8")


def _getSystemInfoLinux():
"""Get system information, assuming the system is Linux.
Expand Down Expand Up @@ -369,10 +394,12 @@ def getSystemInfo():
return _getSystemInfoWindows()
elif "linux" in sys.platform:
return _getSystemInfoLinux()
elif "darwin" in sys.platform:
return _getSystemInfoMac()
else:
runLog.warning(
f"Cannot get system information for {sys.platform} because ARMI only "
+ "supports Linux and Windows."
+ "supports Linux, Windows, and MacOS."
)
return ""

Expand Down
24 changes: 24 additions & 0 deletions armi/bookkeeping/report/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import logging
import os
import subprocess
import sys
import unittest
from unittest.mock import patch

Expand All @@ -24,6 +25,7 @@
from armi.bookkeeping.report import data, reportInterface
from armi.bookkeeping.report.reportingUtils import (
_getSystemInfoLinux,
_getSystemInfoMac,
_getSystemInfoWindows,
getNodeName,
getSystemInfo,
Expand Down Expand Up @@ -91,14 +93,36 @@ def test_getSystemInfoWindows(self, mockSubprocess):
out = _getSystemInfoWindows()
self.assertEqual(out, windowsResult)

@patch("subprocess.run")
def test_getSystemInfoMac(self, mockSubprocess):
"""Test _getSystemInfoMac() on any operating system, by mocking the system call."""
macResult = b"""System Software Overview:
System Version: macOS 12.1 (21C52)
Kernel Version: Darwin 21.2.0
...
Hardware Overview:
Model Name: MacBook Pro
..."""

mockSubprocess.return_value = _MockReturnResult(macResult)

out = _getSystemInfoMac()
self.assertEqual(out, macResult.decode("utf-8"))

def test_getSystemInfo(self):
"""Basic sanity check of getSystemInfo() running in the wild.
This test should pass if it is run on Window or mainstream Linux distros. But we expect this
to fail if the test is run on some other OS.
"""
if "darwin" in sys.platform:
# too comlicated to test MacOS in this method
return

out = getSystemInfo()
substrings = ["OS ", "Processor(s):"]

for sstr in substrings:
self.assertIn(sstr, out)

Expand Down
1 change: 1 addition & 0 deletions doc/release/0.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Bug Fixes

Quality Work
------------
#. Supporting MacOS in CI. (`PR#1713 <https://github.com/terrapower/armi/pull/1713>`_)
#. We now enforce a maximum line length of 120 characters, using ``ruff``. (`PR#1646 <https://github.com/terrapower/armi/pull/1646>`_)
#. Move ``.coveragerc`` file information into ``pyproject.toml``. (`PR#1692 <https://github.com/terrapower/armi/pull/1692>`_)
#. TBD
Expand Down
2 changes: 1 addition & 1 deletion doc/user/inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ The ARMI data model is represented schematically below, and the blueprints are d
Defines :py:class:`~armi.reactor.components.component.Component` inputs for a
:py:class:`~armi.reactor.blocks.Block`.

:ref:`asssemblies <assemblies>`:
:ref:`assemblies <assemblies>`:
Defines vertical stacks of blocks used to define the axial profile of an
:py:class:`~armi.reactor.assemblies.Assembly`.

Expand Down

0 comments on commit bc34c5b

Please sign in to comment.