Skip to content

Commit

Permalink
Merge ba14d0c into 1cf4a7d
Browse files Browse the repository at this point in the history
  • Loading branch information
ntouran committed Feb 3, 2020
2 parents 1cf4a7d + ba14d0c commit 015772d
Show file tree
Hide file tree
Showing 12 changed files with 369 additions and 27 deletions.
31 changes: 20 additions & 11 deletions armi/cases/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,6 @@ def clone(self, additionalFiles=None, title=None, modifiedSettings=None):
for inputFileSetting in [
"loadingFile",
"geomFile",
"shuffleLogic",
"explicitRepeatShuffles",
]:
fileName = self.cs[inputFileSetting]
if fileName:
Expand Down Expand Up @@ -619,18 +617,24 @@ def compare(

return code

def writeInputs(self):
def writeInputs(self, sourceDir: Optional[str]=None):
"""
Write the inputs to disk.
This allows input objects that have been modified in memory (e.g.
for a parameter sweep or migration) to be written out as input
for a forthcoming case.
Parameters
----------
sourceDir : str, optional
The path to copy inputs from (if different from the cs.path). Needed
in SuiteBuilder cases to find the baseline inputs from plugins (e.g. shuffleLogic)
Notes
-----
This will rename the ``loadingFile`` and ``geomFile`` to be ``title-blueprints + '.yaml'`` and
``title + '-geom.xml'`` respectively.
``title + '-geom.yaml'`` respectively.
See Also
--------
Expand All @@ -647,37 +651,42 @@ def writeInputs(self):
self.bp
self.geom
self.cs["loadingFile"] = self.title + "-blueprints.yaml"
self.cs["geomFile"] = self.title + "-geom.xml"
if self.geom:
self.cs["geomFile"] = self.title + "-geom.yaml"
self.geom.writeGeom(self.cs["geomFile"])
if self.independentVariables:
self.cs["independentVariables"] = [
"({}, {})".format(repr(varName), repr(val))
for varName, val in self.independentVariables.items()
]

self.cs.writeToYamlFile(self.title + ".yaml")
self.geom.writeGeom(self.cs["geomFile"])

with open(self.cs["loadingFile"], "w") as loadingFile:
blueprints.Blueprints.dump(self.bp, loadingFile)

copyInterfaceInputs(self.cs, self.directory)
# copy input files from other modules (e.g. fuel management, control logic, etc.)
copyInterfaceInputs(self.cs, ".", sourceDir)

self.cs.writeToYamlFile(self.title + ".yaml")


def copyInterfaceInputs(cs, destination):
def copyInterfaceInputs(cs, destination: str, sourceDir: Optional[str]=None):
"""
Copy sets of files that are considered "input" from each active interface.
This enables developers to add new inputs in a plugin-dependent/
modular way.
"""
activeInterfaces = interfaces.getActiveInterfaceInfo(cs)
sourceDir = sourceDir or cs.inputDirectory
for klass, kwargs in activeInterfaces:
if not kwargs.get("enabled", True):
# Don't consider disabled interfaces
continue
interfaceFileNames = klass.specifyInputs(cs)
for label, fileNames in interfaceFileNames.items():
for f in fileNames:
if not f:
continue
pathTools.copyOrWarn(
label, pathTools.armiAbsPath(cs.inputDirectory, f), destination
label, pathTools.armiAbsPath(sourceDir, f), destination
)
2 changes: 1 addition & 1 deletion armi/cases/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def writeInputs(self):
Similar to this but doesn't let you write out new geometry or blueprints objects.
"""
for case in self:
case.writeInputs()
case.writeInputs(sourceDir=self.cs.inputDirectory)

def writeTable(self, tableResults):
"""Write a table summarizing the test differences."""
Expand Down
7 changes: 0 additions & 7 deletions armi/cases/suiteBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,6 @@ def buildSuite(self, namingFunc=None):
"""
caseSuite = suite.CaseSuite(self.baseCase.cs)

assert (
self.baseCase.geom is not None
), ".geom is build on request, this forces it to be created"
assert (
self.baseCase.bp is not None
), ".bp is build on request, this forces it to be created"

if namingFunc is None:

def namingFunc(index, _case, _mods): # pylint: disable=function-redefined
Expand Down
3 changes: 2 additions & 1 deletion armi/physics/fuelCycle/fuelHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def __init__(self, r, cs):

@staticmethod
def specifyInputs(cs):
return {"fuel management": [cs["shuffleLogic"]]}
files = [cs[label] for label in ["shuffleLogic", "explicitRepeatShuffles"] if cs[label]]
return {"fuel management": files}

def interactBOC(self, cycle=None):
"""
Expand Down
5 changes: 3 additions & 2 deletions armi/reactor/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@

def loadFromCs(cs):
"""Function to load Geoemtry based on supplied ``CaseSettings``."""
from armi.utils import directoryChangers # circular import protection

from armi.utils import directoryChangers # pylint: disable=import-outside-toplevel; circular import protection
if not cs["geomFile"]:
return None
with directoryChangers.DirectoryChanger(cs.inputDirectory):
geom = SystemLayoutInput()
geom.readGeomFromFile(cs["geomFile"])
Expand Down
2 changes: 1 addition & 1 deletion armi/settings/fwSettings/globalSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def defineSettings() -> List[setting.Setting]:
setting.Setting(
CONF_OUTPUT_CACHE_LOCATION,
default="",
label="Location of output cache.",
label="Location of output cache",
description="Location where cached calculations are stored and "
"retrieved if exactly the same as the calculation requested. Empty "
"string will not cache",
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 @@ -50,7 +50,7 @@
"metadata": {},
"outputs": [],
"source": [
"o=armi.init(fName=\"../../../armi/tests/tutorials/anl-afci-177.yaml\")"
"o=armi.init(fName=\"../../../armi/tests/tutorials/anl-afci-177.yaml\");"
]
},
{
Expand Down Expand Up @@ -517,7 +517,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 015772d

Please sign in to comment.