Skip to content

Commit

Permalink
Cleaning and fixing assorted items (#685)
Browse files Browse the repository at this point in the history
Changes made:

- The MANIFEST.in was not updated for the next detailed axial expansion test data files.
- The change to `cleanPath()` has been reverted to the old defaults of "remove file from all processes" for the core ARMI use cases.
- Fixed a bug in runLog where `time` wasn't imported.
- Removed a bunch of useless `pytlint` warnings.
- Adding code coverage to FuelHandlers
  • Loading branch information
john-science committed May 25, 2022
1 parent 45bc1fa commit d3889e0
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 29 deletions.
21 changes: 12 additions & 9 deletions MANIFEST.in
@@ -1,3 +1,4 @@
include armi/bookkeeping/tests/armiRun-A0039-aHist-ref.txt
include armi/nuclearDataIO/cccc/tests/fixtures/labels.ascii
include armi/nuclearDataIO/cccc/tests/fixtures/labels.binary
include armi/nuclearDataIO/cccc/tests/fixtures/mc2v3.dlayxs
Expand All @@ -20,12 +21,11 @@ include armi/nuclearDataIO/tests/fixtures/mc2v3-AB.gamiso
include armi/nuclearDataIO/tests/fixtures/mc2v3-AB.isotxs
include armi/nuclearDataIO/tests/fixtures/mc2v3-AB.pmatrx
include armi/nuclearDataIO/tests/fixtures/mc2v3.dlayxs
include armi/nuclearDataIO/tests/fixtures/simple_cartesian.rzflux
include armi/nuclearDataIO/tests/fixtures/simple_cartesian.rtflux
include armi/nuclearDataIO/tests/fixtures/simple_cartesian.pwdint
include armi/nuclearDataIO/tests/fixtures/simple_cartesian.rtflux
include armi/nuclearDataIO/tests/fixtures/simple_cartesian.rzflux
include armi/nuclearDataIO/tests/fixtures/simple_hexz.geodst
include armi/nuclearDataIO/tests/fixtures/simple_hexz.nhflux
include armi/bookkeeping/tests/armiRun-A0039-aHist-ref.txt
include armi/nuclearDataIO/tests/labels.ascii
include armi/nuclearDataIO/tests/labels.binary
include armi/nuclearDataIO/tests/library-file-generation
Expand All @@ -39,29 +39,32 @@ include armi/nuclearDataIO/tests/longLivedRipleData.dat
include armi/nuclearDataIO/tests/simple_hexz.inp
include armi/nuclearDataIO/tests/z036.dat
include armi/tests/1DslabXSByCompTest.yaml
include armi/tests/COMPXS.ascii
include armi/tests/ISOAA
include armi/tests/ThRZGeom.xml
include armi/tests/ThRZSettings.yaml
include armi/tests/ThRZloading.yaml
include armi/tests/armiRun-SHUFFLES.txt
include armi/tests/armiRun.yaml
include armi/tests/cartesian-geom.xml
include armi/tests/COMPXS.ascii
include armi/tests/detailedAxialExpansion/armiRun.yaml
include armi/tests/detailedAxialExpansion/refSmallReactor.yaml
include armi/tests/detailedAxialExpansion/refSmallReactorBase.yaml
include armi/tests/geom.xml
include armi/tests/geom1Assem.xml
include armi/tests/geomSmall.xml
include armi/tests/ISOAA
include armi/tests/refOneBlockReactor.yaml
include armi/tests/refSmallCartesian.yaml
include armi/tests/refSmallCoreGrid.yaml
include armi/tests/refSmallReactor.yaml
include armi/tests/refSmallReactorBase.yaml
include armi/tests/refSmallCoreGrid.yaml
include armi/tests/refSmallSfpGrid.yaml
include armi/tests/refTestCartesian.yaml
include armi/tests/sfpGeom.yaml
include armi/tests/testEq.yaml
include armi/tests/testEqMulti-geom.xml
include armi/tests/testEqSingle-geom.xml
include armi/tests/test_batch.cinder.dump
include armi/tests/ThRZGeom.xml
include armi/tests/ThRZloading.yaml
include armi/tests/ThRZSettings.yaml
include armi/tests/trz_geom.xml
include armi/tests/tutorials
include armi/tests/tutorials/anl-afci-177-blueprints.yaml
Expand Down
7 changes: 4 additions & 3 deletions armi/bookkeeping/mainInterface.py
Expand Up @@ -23,6 +23,7 @@
import re
import itertools

from armi import context
from armi import interfaces
from armi import runLog
from armi import utils
Expand Down Expand Up @@ -173,16 +174,16 @@ def cleanARMIFiles(self):
cycle = int(snapText[0:3])
node = int(snapText[3:])
newFolder = "snapShot{0}_{1}".format(cycle, node)
utils.pathTools.cleanPath(newFolder)
utils.pathTools.cleanPath(newFolder, context.MPI_RANK)

# delete database if it's SQLlite
# no need to delete because the database won't have copied it back if using fastpath.

# clean temp directories.
if os.path.exists("shuffleBranches"):
utils.pathTools.cleanPath("shuffleBranches")
utils.pathTools.cleanPath("shuffleBranches", context.MPI_RANK)
if os.path.exists("failedRuns"):
utils.pathTools.cleanPath("failedRuns")
utils.pathTools.cleanPath("failedRuns", context.MPI_RANK)

# pylint: disable=no-self-use
def cleanLastCycleFiles(self):
Expand Down
4 changes: 2 additions & 2 deletions armi/context.py
Expand Up @@ -238,7 +238,7 @@ def cleanTempDirs(olderThanDays=None):
file=sys.stdout,
)
try:
cleanPath(_FAST_PATH)
cleanPath(_FAST_PATH, MPI_RANK)
except Exception as error: # pylint: disable=broad-except
for outputStream in (sys.stderr, sys.stdout):
if printMsg:
Expand Down Expand Up @@ -279,7 +279,7 @@ def cleanAllArmiTempDirs(olderThanDays: int) -> None:
runIsOldAndLikleyComplete = (now - dateOfFolder) > gracePeriod
if runIsOldAndLikleyComplete or fromThisRun:
# Delete old files
cleanPath(dirPath)
cleanPath(dirPath, MPI_RANK)
except: # pylint: disable=bare-except
pass

Expand Down
8 changes: 2 additions & 6 deletions armi/interfaces.py
Expand Up @@ -159,9 +159,7 @@ def __repr__(self):
return "<Interface {0}>".format(self.name)

def _checkSettings(self):
"""
Raises an exception if interface settings requirements are not met
"""
"""Raises an exception if interface settings requirements are not met"""
pass

def nameContains(self, name):
Expand Down Expand Up @@ -190,9 +188,7 @@ def preDistributeState(self): # pylint: disable=no-self-use
return {}

def postDistributeState(self, toRestore): # pylint: disable=no-self-use
"""
Restore non-distributable attributes after a distributeState
"""
"""Restore non-distributable attributes after a distributeState"""
pass

def attachReactor(self, o, r):
Expand Down
2 changes: 1 addition & 1 deletion armi/operators/operator.py
Expand Up @@ -1009,7 +1009,7 @@ def snapshotRequest(self, cycle, node):
newFolder = "snapShot{0}_{1}".format(cycle, node)
if os.path.exists(newFolder):
runLog.important("Deleting existing snapshot data in {0}".format(newFolder))
pathTools.cleanPath(newFolder) # careful with cleanPath!
pathTools.cleanPath(newFolder, context.MPI_RANK) # careful with cleanPath!
# give it a minute.
time.sleep(1)

Expand Down
8 changes: 8 additions & 0 deletions armi/physics/fuelCycle/tests/test_fuelHandlers.py
Expand Up @@ -573,6 +573,14 @@ def test_buildEqRingSchedule(self):
locSchedule = fh.buildEqRingSchedule([2, 1])
self.assertEqual(locSchedule, ["002-001", "002-002", "001-001"])

fh.cs["circularRingOrder"] = "distanceSmart"
locSchedule = fh.buildEqRingSchedule([2, 1])
self.assertEqual(locSchedule, ["002-001", "002-002", "001-001"])

fh.cs["circularRingOrder"] = "somethingCrazy"
locSchedule = fh.buildEqRingSchedule([2, 1])
self.assertEqual(locSchedule, ["002-001", "002-002", "001-001"])

def test_swapFluxParamSameLength(self):
"""
Test the _swapFluxParams method for the usual case,
Expand Down
1 change: 1 addition & 0 deletions armi/runLog.py
Expand Up @@ -53,6 +53,7 @@
import operator
import os
import sys
import time

from armi import context

Expand Down
6 changes: 2 additions & 4 deletions armi/utils/directoryChangers.py
Expand Up @@ -260,7 +260,7 @@ def __enter__(self):
def __exit__(self, exc_type, exc_value, traceback):
DirectoryChanger.__exit__(self, exc_type, exc_value, traceback)
try:
pathTools.cleanPath(self.destination)
pathTools.cleanPath(self.destination, context.MPI_RANK)
except PermissionError:
if os.name == "nt":
runLog.warning(
Expand All @@ -271,9 +271,7 @@ def __exit__(self, exc_type, exc_value, traceback):


class ForcedCreationDirectoryChanger(DirectoryChanger):
"""
Creates the directory tree necessary to reach your desired destination
"""
"""Creates the directory tree necessary to reach your desired destination"""

def __init__(
self,
Expand Down
7 changes: 4 additions & 3 deletions armi/utils/outputCache.py
Expand Up @@ -40,12 +40,13 @@
different ways.
"""

import os
import shutil
import hashlib
import json
import os
import shutil
import subprocess

from armi import context
from armi import runLog
from armi.utils.pathTools import cleanPath

Expand Down Expand Up @@ -166,7 +167,7 @@ def deleteCache(cachedFolder):
"""
if "Output_Cache" not in cachedFolder:
raise RuntimeError("Cache location must contain safeword: `Output_Cache`.")
cleanPath(cachedFolder)
cleanPath(cachedFolder, context.MPI_RANK)


def cacheCall(
Expand Down
8 changes: 7 additions & 1 deletion pylintrc
Expand Up @@ -20,6 +20,9 @@
# useless-object-inheritance: New-style classes in python 2
# no-else-return: multiple return statements are not considered bad practice
# duplicate-code: The duplicate code pylint founds is just not interesting.
# invalid-name: frequently, scientifically-meaningful names do not apply to these rules
# line-too-long: we rely on black to handle this
# logging-format-interpolation: this rule seems arbitrary and useless
disable =
bad-whitespace,
trailing-whitespace,
Expand All @@ -41,7 +44,10 @@ disable =
too-few-public-methods,
useless-object-inheritance,
no-else-return,
duplicate-code
duplicate-code,
invalid-name,
line-too-long,
logging-format-interpolation

[BASIC]
dummy-variables-rgx=_[a-zA-Z_]*
Expand Down

0 comments on commit d3889e0

Please sign in to comment.