def __init__(self): super(MantidStressTest, self).__init__() # A list of things not to check when validating self.disableChecking = [] # Whether or not to strip off whitespace when doing simple ascii diff self.stripWhitespace = True # Tolerance self.tolerance = 0.00000001 # Store the resident memory of the system (in MB) before starting the test FrameworkManager.clear() self.memory = MemoryStats().residentMem()/1024
def runTest(self): """Main entry point for the test suite""" files = self.__getDataFileList__() # run the tests failed = [] for filename in files: try: if not self.__loadAndTest__(filename): print("FAILED TO LOAD '%s'" % filename) failed.append(filename) except Exception as e: print("FAILED TO LOAD '%s' WITH ERROR:" % filename) print(e) failed.append(filename) finally: # Clear everything for the next test FrameworkManager.Instance().clear() # final say on whether or not it 'worked' print("----------------------------------------") if len(failed) != 0: print("SUMMARY OF FAILED FILES") for filename in failed: print(filename) raise RuntimeError("Failed to load %d of %d files" % (len(failed), len(files))) else: print("Successfully loaded %d files" % len(files))
def runTest(self): """Main entry point for the test suite""" files = self.__getDataFileList__() # run the tests failed = [] for filename in files: try: if not self.__loadSaveAndTest__(filename): print("FAILED TO LOAD AND SAVE '%s'" % filename) failed.append(filename) #pylint: disable=broad-except except ValueError as e: print("FAILED TO LOAD AND SAVE '%s' WITH ERROR:" % filename) print(e) failed.append(filename) finally: # Clear everything for the next test FrameworkManager.Instance().clear() # final say on whether or not it 'worked' print("----------------------------------------") if set(failed) != set(known_error_files): newfound_errors = list(set(failed) - set(known_error_files)) for file in newfound_errors: print("Failed: '%s'" % file) raise RuntimeError("System test failed.") else: print("Successfully loaded and saved %d files" % len(files))
def returnValidationCode(self, code): """ Calls doValidation() and returns 0 in success and code if failed. This will be used as return code from the calling python subprocess """ if self.doValidation(): retcode = 0 else: retcode = code if retcode == 0: self._success = True else: self._success = False # Now the validation is complete we can clear out all the stored data and check memory usage FrameworkManager.clear() # Get the resident memory again and work out how much it's gone up by (in MB) memorySwallowed = MemoryStats().residentMem()/1024 - self.memory # Store the result self.reportResult('memory footprint increase', memorySwallowed) return retcode
def setup(app): """ Setup the directives when the extension is activated Args: app: The main Sphinx application object """ from mantid.api import FrameworkManager app.add_directive('algorithm', AlgorithmDirective) # connect event html collection to handler app.connect("html-collect-pages", html_collect_pages) # start framework manager to load plugins once FrameworkManager.Instance()
def _check_file_path(filename, mantid_alg): from mantid.api import AlgorithmManager, FrameworkManager, FileProperty FrameworkManager.Instance() alg = AlgorithmManager.createUnmanaged(mantid_alg) filename_property = [ prop for prop in alg.getProperties() if isinstance(prop, FileProperty) ] # Only with FileProperty can Mantid take fuzzy matches to filenames and run numbers # If the top level Load algorithm is requested (has no properties of its own) # we know that it's child algorithm uses FileProperty. If the child algorithm # is called directly we attempt to find FileProperty. Otherwise paths should be # absolute if filename_property or mantid_alg == 'Load': if not _is_mantid_loadable(filename): raise ValueError( f"Mantid cannot find {filename} and therefore will not load it." ) from None else: if not os.path.isfile(filename): raise ValueError( f"Cannot find file {filename} and therefore will not load it.")
def setUpClass(cls): FrameworkManager.Instance()
def clear_all_memory(self): """ Wrapper for call to FrameworkManager to clear all memory """ FrameworkManager.Instance().clear()
def runTest(self): """Main entry point for the test suite""" files = self.__getDataFileList__() # run the tests failed = [] for filename in files: try: if not self.__loadAndTest__(filename): print "FAILED TO LOAD '%s'" % filename failed.append(filename) except Exception, e: print "FAILED TO LOAD '%s' WITH ERROR:" % filename print e failed.append(filename) finally: # Clear everything for the next test FrameworkManager.Instance().clear() # final say on whether or not it 'worked' print "----------------------------------------" if len(failed) != 0: print "SUMMARY OF FAILED FILES" for filename in failed: print filename raise RuntimeError("Failed to load %d of %d files" % (len(failed), len(files))) else: print "Successfully loaded %d files" % len(files)
def PyExec(self): alg = FrameworkManager.createAlgorithm("Rebin") self._test_obj.assertTrue(alg.isInitialized()) self._test_obj.assertFalse(isinstance(alg, AlgorithmProxy))
def test_create_algorithm_with_version_produces_managed_alg_outside_PyExec_with_async_and_is_true(self): alg = FrameworkManager.createAlgorithm("LoadRaw", 2) self._is_managed_test(alg, 2)
def test_create_algorithm_produces_managed_alg_outside_PyExec_with_async_attr_and_is_true(self): alg = FrameworkManager.createAlgorithm("Rebin") self._is_managed_test(alg, 1)