Commit efd0e29d authored by Kendrick, Coleman's avatar Kendrick, Coleman Committed by Peterson, Peter
Browse files

Updated SHA prefix workspaces to not use runnumber

parent 426e5d98
......@@ -111,7 +111,7 @@ def _getCacheName(wkspname, wksp_prefix, cache_dir, abs_method):
return cache_path, signature
def _getCachedData(absName, abs_method, sha1, cache_file_name, wksp_prefix=""):
def _getCachedData(absName, abs_method, sha1, cache_file_name):
"""
Check both memory and disk to locate cache data. Returns ("", "")
if no cache can be found.
......@@ -284,7 +284,12 @@ def calculate_absorption_correction(
# - load from cache nxs file
# - if cache is not found, wsn_as and wsn_ac will both be None
# - standard calculation will be kicked off as before
wsn_as, wsn_ac = _getCachedData(absName, abs_method, sha1, cache_filename, cache_prefix)
# Update absName with the cache prefix to find workspaces in memory
if prefix == "SHA":
absName = cache_prefix + "_" + sha1 + "_abs_correction"
else:
absName = cache_prefix + "_abs_correction"
wsn_as, wsn_ac = _getCachedData(absName, abs_method, sha1, cache_filename)
# NOTE:
# -- one algorithm with three very different behavior, why not split them to
......
......@@ -105,6 +105,53 @@ class AbsorptionCorrUtilsTest(unittest.TestCase):
prefix="FILENAME")
self.assertIsNotNone(abs_s)
def test_cache_sha_prefix(self):
fname = "PG3_46577.nxs.h5"
charfile = "PG3_char_2020_01_04_PAC_limit_1.4MW.txt"
charTable = PDLoadCharacterizations(Filename=charfile)
char = charTable[0]
data = Load(Filename=fname, MetaDataOnly=True)
PDDetermineCharacterizations(InputWorkspace=data,
Characterizations=char,
ReductionProperties="props")
props = PropertyManagerDataService.retrieve("props")
cachedir = tempfile.gettempdir()
abs_s, abs_c = absorptioncorrutils.calculate_absorption_correction(fname,
"SampleOnly",
props,
"Si",
1.165,
element_size=2,
cache_dir=cachedir,
prefix="SHA")
self.assertIsNotNone(abs_s)
# Get what the cache SHA should be - verify the donor WS exists since that is used to make cache SHA
donorws = "__{}_abs".format(absorptioncorrutils._getBasename(fname))
self.assertEqual(mtd.doesExist(donorws), True)
cache_prefix = absorptioncorrutils._getInstrName(fname, mtd[donorws])
cachefile, sha = absorptioncorrutils._getCacheName(donorws, cache_prefix, cachedir,
"SampleOnly")
# Compare against expected name using SHA prefix
cached_wsname = cache_prefix + "_" + sha + "_abs_correction_ass"
self.assertEqual(mtd.doesExist(cached_wsname), True)
# Remove the workspace from ADS and verify it can be found from disk
DeleteWorkspaces(cached_wsname)
abs_s, abs_c = absorptioncorrutils.calculate_absorption_correction(fname,
"SampleOnly",
props,
"Si",
1.165,
element_size=2,
cache_dir=cachedir,
prefix="SHA")
self.assertIsNotNone(abs_s)
if __name__ == '__main__':
unittest.main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment