Skip to content

Commit

Permalink
Define copyOutput on ExecutionOptions (#1227)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgjarrett authored Mar 29, 2023
1 parent 2a3a892 commit 70fdd06
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 28 deletions.
3 changes: 3 additions & 0 deletions armi/physics/executers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class ExecutionOptions:
savePhysicsFiles : bool
Dump the physics kernel I/O files from the execution to a dedicated directory that
will not be overwritten so they will be available after the run.
copyOutput : bool
Copy the output from running the executable back to the working directory.
applyResultsToReactor : bool
Update the in-memory reactor model with results upon completion. Set to False
when information from a run is needed for auxiliary purposes rather than progressing
Expand All @@ -78,6 +80,7 @@ def __init__(self, label=None):
self.applyResultsToReactor = True
self.paramsToScaleSubset = None
self.savePhysicsFiles = False
self.copyOutput = True

def __repr__(self):
return f"<{self.__class__.__name__}: {self.label}>"
Expand Down
1 change: 0 additions & 1 deletion armi/physics/neutronics/globalFlux/globalFluxInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ def __init__(self, label: Optional[str] = None):
# can happen in eig if Fredholm Alternative satisfied
self.includeFixedSource = False
self.eigenvalueProblem = True
self.copyOutput = True
self.kernelName: str
self.isRestart = None
self.energyDepoCalcMethodStep = None # for gamma transport/normalization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from armi.reactor.tests import test_reactors
from armi.tests import ISOAA_PATH


# pylint: disable=abstract-method
class MockReactorParams:
def __init__(self):
Expand Down Expand Up @@ -223,31 +222,6 @@ def _setTightCouplingTrue(self):
def _setTightCouplingFalse(self):
self.cs["tightCoupling"] = False

def test_collectInputsAndOutputs(self):
"""
Verify that the executer can select to not copy back output.
"""
executer = self.gfi.getExecuter()
cs = settings.Settings()
executer.options.fromUserSettings(cs)
executer.options.inputFile = "test.inp"
executer.options.outputFile = "test.out"
executer.options.copyOutput = False
inputs, outputs = executer._collectInputsAndOutputs()
self.assertEqual(
"test.inp", inputs[0], "Input file was not successfully identified."
)
self.assertTrue(outputs == [], "Outputs were returned erroneously!")

executer.options.copyOutput = True
inputs, outputs = executer._collectInputsAndOutputs()
self.assertEqual(
"test.inp", inputs[0], "Input file was not successfully identified."
)
self.assertEqual(
"test.out", outputs[0], "Output file was not successfully identified."
)


class TestGlobalFluxInterfaceWithExecutersNonUniform(unittest.TestCase):
"""Tests for global flux execution with non-uniform assemblies."""
Expand Down
56 changes: 56 additions & 0 deletions armi/physics/tests/test_executers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,35 @@
import os
import unittest

from armi.reactor import geometry
from armi import settings
from armi.physics import executers

# pylint: disable=abstract-method
class MockReactorParams:
def __init__(self):
self.cycle = 1
self.timeNode = 2


class MockCoreParams:
pass


class MockCore:
def __init__(self):
# just pick a random geomType
self.geomType = geometry.GeomType.CARTESIAN
self.symmetry = "full"
self.p = MockCoreParams()


class MockReactor:
def __init__(self):
self.core = MockCore()
self.o = None
self.p = MockReactorParams()


class TestExecutionOptions(unittest.TestCase):
def test_runningDirectoryPath(self):
Expand All @@ -39,5 +66,34 @@ def test_runningDirectoryPath(self):
self.assertEqual(os.path.basename(e.runDir), "9c1c83cb-0")


class TestExecuters(unittest.TestCase):
def setUp(self):
e = executers.ExecutionOptions(label=None)
self.executer = executers.DefaultExecuter(e, MockReactor())

def test_collectInputsAndOutputs(self):
"""
Verify that the executer can select to not copy back output.
"""
cs = settings.Settings()
self.executer.options.inputFile = "test.inp"
self.executer.options.outputFile = "test.out"
self.executer.options.copyOutput = False
inputs, outputs = self.executer._collectInputsAndOutputs()
self.assertEqual(
"test.inp", inputs[0], "Input file was not successfully identified."
)
self.assertTrue(outputs == [], "Outputs were returned erroneously!")

self.executer.options.copyOutput = True
inputs, outputs = self.executer._collectInputsAndOutputs()
self.assertEqual(
"test.inp", inputs[0], "Input file was not successfully identified."
)
self.assertEqual(
"test.out", outputs[0], "Output file was not successfully identified."
)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion doc/release/0.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ What's new in ARMI
#. The method ``Material.density3`` is now called ``density``, and the old ``density`` is now called ``pseudoDensity``. (`PR#1163 <https://github.com/terrapower/armi/pull/1163>`_)
#. Added documentation for the thermal expansion approach used in ARMI. (`PR#1204 <https://github.com/terrapower/armi/pull/1204>`_)
#. Use TemporaryDirectoryChanger for executer.run() so dirs are cleaned up during run. (`PR#1219 <https://github.com/terrapower/armi/pull/1219>`_)
#. New option ``copyOutput`` for globalFluxInterface to not copy output back to working directory. (`PR#1218 <https://github.com/terrapower/armi/pull/1218>`_)
#. New option ``copyOutput`` for globalFluxInterface to not copy output back to working directory. (`PR#1218 <https://github.com/terrapower/armi/pull/1218>`_, `PR#1227 <https://github.com/terrapower/armi/pull/1227>`_)

Bug fixes
---------
Expand Down

0 comments on commit 70fdd06

Please sign in to comment.