Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into drewj/block-rotate/1939
Browse files Browse the repository at this point in the history
* origin/main:
  Updating cluster settings (#1958)
  Reducing warnings while building the docs (#1959)
  Moving anl-afci-177 test files to their own directory (#1957)
  • Loading branch information
drewj-tp committed Oct 21, 2024
2 parents 27f4275 + 1f70838 commit 367cf54
Show file tree
Hide file tree
Showing 29 changed files with 140 additions and 133 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ coverage_results.*
dist-*/
dist/
doc/_build
doc/anl-afci-177
doc/gallery
doc/gallery-src/framework/*.yaml
doc/tutorials/anl-afci-177*
Expand Down
2 changes: 1 addition & 1 deletion armi/bookkeeping/db/tests/test_database3.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def test_open(self):

def test_loadCS(self):
cs = self.db.loadCS()
self.assertEqual(cs["numProcessors"], 1)
self.assertEqual(cs["nTasks"], 1)
self.assertEqual(cs["nCycles"], 2)

def test_loadBlueprints(self):
Expand Down
2 changes: 1 addition & 1 deletion armi/bookkeeping/report/newReportUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def insertSettingsData(cs, report):
"burnSteps",
"skipCycles",
"cycleLength",
"numProcessors",
"nTasks",
]:
report[COMPREHENSIVE_REPORT][CASE_PARAMETERS].addRow([key, cs[key]])

Expand Down
14 changes: 9 additions & 5 deletions armi/bookkeeping/tests/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
also re-exported by `__init__.py`, so that other things (like the documentation system)
can use it without having to import the rest of ARMI.
"""
import os

from armi.tests import TEST_ROOT


# These files are needed to run the data_model ipython notebook, which is done in
# test_historyTracker, and when building the docs.
TUTORIAL_FILES = [
"anl-afci-177-blueprints.yaml",
"anl-afci-177-coreMap.yaml",
"anl-afci-177-fuelManagement.py",
"anl-afci-177.yaml",
"data_model.ipynb",
os.path.join(TEST_ROOT, "anl-afci-177", "anl-afci-177-blueprints.yaml"),
os.path.join(TEST_ROOT, "anl-afci-177", "anl-afci-177-coreMap.yaml"),
os.path.join(TEST_ROOT, "anl-afci-177", "anl-afci-177-fuelManagement.py"),
os.path.join(TEST_ROOT, "anl-afci-177", "anl-afci-177.yaml"),
os.path.join(TEST_ROOT, "tutorials", "data_model.ipynb"),
]
19 changes: 14 additions & 5 deletions armi/bookkeeping/tests/test_historyTracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,29 @@ class TestHistoryTracker(ArmiTestHelper):

@classmethod
def setUpClass(cls):
# We need to be in the TUTORIAL_DIR so that for `filesToMove` to work right.
os.chdir(TUTORIAL_DIR)

# Do this work in a temp dir, to avoid race conditions.
cls.dirChanger = TemporaryDirectoryChanger(filesToMove=TUTORIAL_FILES)
cls.dirChanger = TemporaryDirectoryChanger()
cls.dirChanger.__enter__()

os.mkdir("tutorials")
os.mkdir(CASE_TITLE)

for filePath in TUTORIAL_FILES:
dirName = CASE_TITLE if CASE_TITLE in filePath else "tutorials"
outFile = os.path.join(
cls.dirChanger.destination, dirName, os.path.basename(filePath)
)
shutil.copyfile(filePath, outFile)

os.chdir(os.path.join(cls.dirChanger.destination, "tutorials"))
runTutorialNotebook()

@classmethod
def tearDownClass(cls):
cls.dirChanger.__exit__(None, None, None)

def setUp(self):
cs = settings.Settings(f"{CASE_TITLE}.yaml")
cs = settings.Settings(f"../{CASE_TITLE}/{CASE_TITLE}.yaml")
newSettings = {}
newSettings["db"] = True
newSettings["nCycles"] = 2
Expand Down
2 changes: 1 addition & 1 deletion armi/cases/tests/test_suiteBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"..",
"..",
"tests",
"tutorials",
"anl-afci-177",
"anl-afci-177.yaml",
)
)
Expand Down
2 changes: 1 addition & 1 deletion armi/cli/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ModifyCaseSettingsCommand(EntryPoint):
Run the entry point like this::
$ python -m armi modify --numProcessors=3 *.yaml
$ python -m armi modify --nTasks=3 *.yaml
"""

Expand Down
8 changes: 4 additions & 4 deletions armi/cli/tests/test_runEntryPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,15 @@ def test_modifyCaseSettingsCommandInvoke(self):
for fileName in ["armiRun.yaml", "refSmallReactor.yaml"]:
copyfile(os.path.join(TEST_ROOT, fileName), fileName)

# pass in --numProcessors=333
mcs.parse_args(["--numProcessors=333", "--rootDir", ".", "armiRun.yaml"])
# pass in --nTasks=333
mcs.parse_args(["--nTasks=333", "--rootDir", ".", "armiRun.yaml"])

# invoke the CLI
mcs.invoke()

# validate the change to numProcessors was made
# validate the change to nTasks was made
txt = open("armiRun.yaml", "r").read()
self.assertIn("numProcessors: 333", txt)
self.assertIn("nTasks: 333", txt)


class TestReportsEntryPoint(unittest.TestCase):
Expand Down
18 changes: 5 additions & 13 deletions armi/settings/fwSettings/globalSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@
CONF_MATERIAL_NAMESPACE_ORDER = "materialNamespaceOrder"
CONF_MIN_MESH_SIZE_RATIO = "minMeshSizeRatio"
CONF_MODULE_VERBOSITY = "moduleVerbosity"
CONF_MPI_TASKS_PER_NODE = "mpiTasksPerNode"
CONF_N_CYCLES = "nCycles"
CONF_NON_UNIFORM_ASSEM_FLAGS = "nonUniformAssemFlags"
CONF_NUM_PROCESSORS = "numProcessors"
CONF_N_TASKS = "nTasks"
CONF_OPERATOR_LOCATION = "operatorLocation"
CONF_OUTPUT_CACHE_LOCATION = "outputCacheLocation"
CONF_OUTPUT_FILE_EXTENSION = "outputFileExtension"
Expand Down Expand Up @@ -154,11 +153,12 @@ def defineSettings() -> List[setting.Setting]:
"""
settings = [
setting.Setting(
CONF_NUM_PROCESSORS,
CONF_N_TASKS,
default=1,
label="CPUs",
description="Number of CPUs to request on the cluster",
label="parallel tasks",
description="Number of parallel tasks to request on the cluster",
schema=vol.All(vol.Coerce(int), vol.Range(min=1)),
oldNames=[("numProcessors", None)],
),
setting.Setting(
CONF_INITIALIZE_BURN_CHAIN,
Expand Down Expand Up @@ -587,14 +587,6 @@ def defineSettings() -> List[setting.Setting]:
description="Description needed",
schema=vol.All(vol.Coerce(float), vol.Range(min=0, max=1)),
),
setting.Setting(
CONF_MPI_TASKS_PER_NODE,
default=0,
label="MPI Tasks per Node",
description="Number of independent processes that are allocated to each "
"cluster node. 0 means 1 process per CPU.",
schema=vol.All(vol.Coerce(int), vol.Range(min=0)),
),
setting.Setting(
CONF_N_CYCLES,
default=1,
Expand Down
7 changes: 1 addition & 6 deletions armi/settings/fwSettings/tests/test_fwSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestSchema(unittest.TestCase):
def setUp(self):
self.cs = caseSettings.Settings()
self.settings = {
"numProcessors": {
"nTasks": {
"valid": 1,
"invalid": -1,
"error": vol.error.MultipleInvalid,
Expand Down Expand Up @@ -91,11 +91,6 @@ def setUp(self):
"invalid": 2,
"error": vol.error.MultipleInvalid,
},
"mpiTasksPerNode": {
"valid": 0,
"invalid": -1,
"error": vol.error.MultipleInvalid,
},
"nCycles": {"valid": 1, "invalid": -1, "error": vol.error.MultipleInvalid},
"power": {"valid": 0, "invalid": -1, "error": vol.error.MultipleInvalid},
"skipCycles": {
Expand Down
4 changes: 2 additions & 2 deletions armi/settings/tests/test_inspectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ def test_assignCS(self):
self.assertIn("nCycles", keys)

def test_createQueryRevertBadPathToDefault(self):
query = createQueryRevertBadPathToDefault(self.inspector, "numProcessors")
query = createQueryRevertBadPathToDefault(self.inspector, "nTasks")
self.assertEqual(
str(query),
"<Query: Setting numProcessors points to a nonexistent location:\n1>",
"<Query: Setting nTasks points to a nonexistent location:\n1>",
)

def test_correctCyclesToZeroBurnup(self):
Expand Down
2 changes: 1 addition & 1 deletion armi/settings/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_getSettingsSetByUser(self):
# some default settings values
for sett in ["availabilityFactor", "db"]:
self.assertIn(sett, settingsList)
self.assertNotIn("numProcessors", settingsList)
self.assertNotIn("nTasks", settingsList)

def test_setModuleVerbosities(self):
# init settings and use them to set module-level logging levels
Expand Down
10 changes: 5 additions & 5 deletions armi/settings/tests/test_settingsIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def setUp(self):
def test_basicSettingsReader(self):
reader = settingsIO.SettingsReader(self.cs)

self.assertEqual(reader["numProcessors"], 1)
self.assertEqual(reader["nTasks"], 1)
self.assertEqual(reader["nCycles"], 1)

self.assertFalse(getattr(reader, "filelessBP"))
Expand Down Expand Up @@ -165,18 +165,18 @@ def test_writeShort(self):
self.cs.loadFromInputFile(self.filepathYaml)
txt = open(self.filepathYaml, "r").read()
self.assertIn("nCycles: 55", txt)
self.assertNotIn("numProcessors", txt)
self.assertNotIn("nTasks", txt)

def test_writeMedium(self):
"""Setting output as a sparse file that only includes defaults if they are
user-specified.
"""
with open(self.filepathYaml, "w") as stream:
# Specify a setting that is also a default
self.cs.writeToYamlStream(stream, "medium", ["numProcessors"])
self.cs.writeToYamlStream(stream, "medium", ["nTasks"])
txt = open(self.filepathYaml, "r").read()
self.assertIn("nCycles: 55", txt)
self.assertIn("numProcessors: 1", txt)
self.assertIn("nTasks: 1", txt)

def test_writeFull(self):
"""Setting output as a full, all defaults included file.
Expand All @@ -189,7 +189,7 @@ def test_writeFull(self):
txt = open(self.filepathYaml, "r").read()
self.assertIn("nCycles: 55", txt)
# check a default setting
self.assertIn("numProcessors: 1", txt)
self.assertIn("nTasks: 1", txt)

def test_writeYaml(self):
self.cs.writeToYamlFile(self.filepathYaml)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion armi/tests/test_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_getSettings(self):
settings = app.getSettings()

self.assertGreater(len(settings), 100)
self.assertEqual(settings["numProcessors"].value, 1)
self.assertEqual(settings["nTasks"].value, 1)
self.assertEqual(settings["nCycles"].value, 1)

def test_splashText(self):
Expand Down
1 change: 1 addition & 0 deletions armi/tests/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from armi.tests import TEST_ROOT

TUTORIALS = os.path.join(TEST_ROOT, "tutorials")
ANL_ACFI_177 = os.path.join(TEST_ROOT, "anl-afci-177")


class NotebookTests(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions armi/tests/tutorials/data_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"metadata": {},
"outputs": [],
"source": [
"o=armi.init(fName=\"anl-afci-177.yaml\");\n",
"o=armi.init(fName=\"../anl-afci-177/anl-afci-177.yaml\");\n",
"o.r.core.sortAssemsByRing() # makes innermost assemblies appear first"
]
},
Expand Down Expand Up @@ -468,7 +468,7 @@
"outputs": [],
"source": [
"from armi.bookkeeping import db\n",
"databaseLocation = \"anl-afci-177.h5\"\n",
"databaseLocation = \"../tutorials/anl-afci-177.h5\"\n",
"cycle, timeNode = 0, 1\n",
"dbo = db.databaseFactory(databaseLocation, \"r\")\n",
"with dbo:\n",
Expand Down
4 changes: 2 additions & 2 deletions armi/tests/tutorials/param_sweep.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"from armi.cases import suiteBuilder\n",
"from armi.cases.inputModifiers import inputModifiers\n",
"\n",
"cs = settings.Settings('anl-afci-177.yaml')\n",
"cs = settings.Settings('../anl-afci-177/anl-afci-177.yaml')\n",
"case = cases.Case(cs)"
]
},
Expand Down Expand Up @@ -268,7 +268,7 @@
"source": [
"def loadSuite():\n",
" print('Loading suite results...')\n",
" cs = settings.Settings('anl-afci-177.yaml')\n",
" cs = settings.Settings('../anl-afci-177/anl-afci-177.yaml')\n",
" suite = cases.CaseSuite(cs)\n",
" suite.discover(patterns=[\"anl-afci-177-????.yaml\"])\n",
" suite = sorted(suite, key=lambda c: c.cs.inputDirectory)\n",
Expand Down
31 changes: 16 additions & 15 deletions armi/utils/directoryChangers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class DirectoryChanger:
Filenames to bring back from the destination to the cwd. Note that if any of these
files do not exist then the file will be skipped and a warning will be provided.
dumpOnException : bool, optional
Flag to tell system to retrieve the entire directory if an exception
is raised within a the context manager.
Flag to tell system to retrieve the entire directory if an exception is raised within a the
context manager.
outputPath : str, optional
Output path for filesToRetrieve. If None, default is the initial working directory
from which the DirectoryChanger is called.
Output path for filesToRetrieve. If None, default is the initial working directory from
which the DirectoryChanger is called.
"""

def __init__(
Expand Down Expand Up @@ -177,10 +177,9 @@ def _transferFiles(initialPath, destinationPath, fileList):
"""
Transfer files into or out of the directory.
This is used in ``moveFiles`` and ``retrieveFiles`` to shuffle files about when
creating a target directory or when coming back, respectively. Beware that this
uses ``shutil.copy()`` under the hood, which doesn't play nicely with
directories. Future revisions should improve this.
This is used in ``moveFiles`` and ``retrieveFiles`` to shuffle files about when creating a
target directory or when coming back, respectively. Beware that this uses ``shutil.copy()``
under the hood, which doesn't play nicely with directories.
Parameters
----------
Expand All @@ -189,20 +188,22 @@ def _transferFiles(initialPath, destinationPath, fileList):
destinationPath: str
Path to the folder to move file to.
fileList : list of str or list of tuple
File names to move from initial to destination. If this is a
simple list of strings, the files will be transferred. Alternatively
tuples of (initialName, finalName) are allowed if you want the file
renamed during transit. In the non-tuple option, globs/wildcards
File names to move from initial to destination. If this is a simple list of strings, the
files will be transferred. Alternatively tuples of (initialName, finalName) are allowed
if you want the file renamed during transit. In the non-tuple option, globs/wildcards
are allowed.
.. warning:: On Windows the max number of characters in a path is 260.
If you exceed this you will see FileNotFound errors here.
Warning
-------
On Windows the max number of characters in a path is 260.
If you exceed this you will see FileNotFound errors here.
"""
if not fileList:
return

if not os.path.exists(destinationPath):
os.makedirs(destinationPath)

for pattern in fileList:
if isinstance(pattern, tuple):
# allow renames in transit
Expand Down
Loading

0 comments on commit 367cf54

Please sign in to comment.