Skip to content

Commit

Permalink
Reinstate case summary when initing Operator (#28)
Browse files Browse the repository at this point in the history
This also teaches it how to probe interfaces for their inputs and track
yaml !includes
  • Loading branch information
youngmit committed Feb 14, 2020
1 parent 81b5d36 commit dd16ef9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
52 changes: 35 additions & 17 deletions armi/bookkeeping/report/reportingUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import re
import os
import collections
import pathlib
import textwrap
import sys
import time
Expand All @@ -33,6 +34,8 @@
from armi.utils import iterables
from armi.utils import units
from armi.utils import pathTools
from armi.utils import textProcessors
from armi import interfaces
from armi.bookkeeping import report
from armi.reactor.flags import Flags
from armi.reactor.components import ComponentType
Expand Down Expand Up @@ -60,7 +63,7 @@ def _writeCaseInformation(o, cs):
"{} - {}".format(cs["runType"], o.__class__.__name__),
),
(strings.Operator_CurrentUser, armi.USER),
(strings.Operator_ArmiCodebase, cs["armiLocation"]),
(strings.Operator_ArmiCodebase, armi.ROOT),
(strings.Operator_WorkingDirectory, os.getcwd()),
(strings.Operator_PythonInterperter, sys.version),
(strings.Operator_MasterMachine, os.environ.get("COMPUTERNAME", "?")),
Expand All @@ -75,24 +78,43 @@ def _writeCaseInformation(o, cs):
def _listInputFiles(cs):
"""
Gathers information about the input files of this case.
Returns
-------
inputInfo : list
(label, fileName, shaHash) tuples
"""

pathToLoading = pathlib.Path(cs.inputDirectory) / cs["loadingFile"]

if pathToLoading.is_file():
includedBlueprints = [
inclusion[0]
for inclusion in textProcessors.findYamlInclusions(pathToLoading)
]
else:
includedBlueprints = []

inputInfo = []
inputFiles = [
("Case Settings", cs.caseTitle + ".yaml"),
("Blueprints", cs["loadingFile"]),
("Geometry", cs["geomFile"]),
]
if cs["shuffleLogic"]:
inputFiles.append(("Fuel Management", cs["shuffleLogic"]))
if cs["controlLogic"]:
inputFiles.append(("Control Logic", cs["controlLogic"]))
if cs["orificeSettingsFile"]:
inputFiles.append(("Orifice Settings", cs["orificeSettingsFile"]))
inputFiles = (
[
("Case Settings", cs.caseTitle + ".yaml"),
("Blueprints", cs["loadingFile"]),
]
+ [("Included blueprints", inclBp) for inclBp in includedBlueprints]
+ [("Geometry", cs["geomFile"])]
)

activeInterfaces = interfaces.getActiveInterfaceInfo(cs)
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 fName in fileNames:
inputFiles.append((label, fName))

if cs["reloadDBName"] and cs["runType"] == RunTypes.SNAPSHOTS:
inputFiles.append(("Database", cs["reloadDBName"]))
for label, fName in inputFiles:
Expand Down Expand Up @@ -166,10 +188,6 @@ def _writeReactorCycleInformation(o, cs):
if armi.MPI_RANK > 0:
return # prevent the worker nodes from printing the same thing

# make sure armiLocation is consistent with what's truly running.
if os.path.join(cs["armiLocation"], "armi") != armi.ROOT:
warnings.Operator_executionScriptDiffersFromArmiLocation(armi.ROOT)

_writeCaseInformation(o, cs)
_writeInputFileInformation(cs)
_writeMachineInformation()
Expand Down
7 changes: 6 additions & 1 deletion armi/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,12 @@ def specifyInputs(cs) -> Dict[str, List[str]]: # pylint: disable=unused-argumen
The files returned by an implementation of this method are those that one would
want copied to a remote location when cloning a Case or CaseSuite to a remote
location
location.
Note
----
This existed before the advent of ARMI plugins. Perhaps it can be better served
as a plugin hook. Potential future work.
Parameters
----------
Expand Down
3 changes: 3 additions & 0 deletions armi/operators/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def __init__(self, cs):
self.powerFractions = self._getPowerFractions()
self._checkReactorCycleAttrs()

# Create the welcome headers for the case (case, input, machine, and some basic reactor information)
reportingUtils.writeWelcomeHeaders(self, cs)

def _getCycleLengths(self):
"""Return the cycle length for each cycle of the system as a list."""
return utils.expandRepeatedFloats(self.cs["cycleLengths"]) or (
Expand Down

0 comments on commit dd16ef9

Please sign in to comment.