def test_mf6model(): # determine if running on Travis or GitHub actions is_CI = running_on_CI() r_exe = None if not is_CI: if replace_exe is not None: r_exe = replace_exe # initialize testing framework test = testing_framework() # build the models build_models() # run the test models for idx, dir in enumerate(exdirs): if is_CI and not continuous_integration[idx]: continue yield test.run_mf6, Simulation(dir, exfunc=eval_comp, exe_dict=r_exe, htol=htol[idx], idxsim=idx) return
def test_mf6model(): # determine if running on Travis or GitHub actions is_CI = running_on_CI() r_exe = None if not is_CI: if replace_exe is not None: r_exe = replace_exe # initialize testing framework test = testing_framework() # build the models build_models() # run the test models for idx, dir in enumerate(exdirs): yield test.run_mf6, Simulation( dir, exfunc=eval_comp, htol=htol[idx], idxsim=idx, mf6_regression=True, ) return
def test_mf6model(idx, dir): # determine if running on CI infrastructure is_CI = running_on_CI() r_exe = None if not is_CI: if replace_exe is not None: r_exe = replace_exe # initialize testing framework test = testing_framework() # build the models test.build_mf6_models(build_model, idx, dir) # run the test model if is_CI and not continuous_integration[idx]: return test.run_mf6( Simulation( dir, exe_dict=r_exe, exfunc=eval_comp, htol=htol[idx], mf6_regression=True, ))
def test_mf6model(idx, dir): # determine if running on CI infrastructure is_CI = running_on_CI() # initialize testing framework test = testing_framework() # build the models test.build_mf6_models_legacy(build_model, idx, dir) # run the test model if is_CI and not continuous_integration[idx]: return test.run_mf6(Simulation(dir, require_failure=require_failure[idx]))
def test_mf6model(idx, dir): # determine if running on CI infrastructure is_CI = running_on_CI() # initialize testing framework test = testing_framework() # build the models test.build_mf6_models(build_model, idx, dir) if is_CI and not continuous_integration[idx]: return # run the test model test.run_mf6(Simulation(dir, mf6_regression=True))
def test_mf6model(): # determine if running on Travis or GitHub actions is_CI = running_on_CI() # initialize testing framework test = testing_framework() # build the models build_models() # run the test models for idx, dir in enumerate(exdirs): if is_CI and not continuous_integration[idx]: continue yield test.run_mf6, Simulation(dir, require_failure=require_failure[idx]) return
def test_mf6model(idx, dir): # determine if running on CI infrastructure is_CI = running_on_CI() r_exe = None if not is_CI: if replace_exe is not None: r_exe = replace_exe # initialize testing framework test = testing_framework() # build the models test.build_mf6_models(build_model, idx, dir) # run the test model if is_CI and not continuous_integration[idx]: return test.run_mf6(Simulation(dir, idxsim=idx))
def test_mf6model(idx, dir): # determine if running on CI infrastructure is_CI = running_on_CI() r_exe = None if not is_CI: if replace_exe is not None: r_exe = replace_exe # initialize testing framework test = testing_framework() # build the model test.build_mf6_models(build_model, idx, dir) # run the test model test.run_mf6( Simulation(dir, exfunc=eval_comp, exe_dict=r_exe, htol=htol, idxsim=idx))
# Get executables and build targets # can compile mf6 direcetly using this command: # python -c "import test000_setup; test000_setup.test_build_modflow6()" import os import sys import shutil import pymake from framework import running_on_CI if running_on_CI(): print('running on CI environment') os.environ['PYMAKE_DOUBLE'] = '1' # paths to executables for previous versions of MODFLOW ebindir = os.path.abspath( os.path.join(os.path.expanduser('~'), '.local', 'bin')) if not os.path.exists(ebindir): os.makedirs(ebindir) # make sure exe extension is used on windows eext = '' soext = '.so' if sys.platform.lower() == 'win32': eext = '.exe' soext = '.dll' mfexe_pth = 'temp/mfexes' # some flags to check for errors in the code
def __init__( self, name, exfunc=None, exe_dict=None, htol=None, pdtol=None, rclose=None, idxsim=None, cmp_verbose=True, require_failure=None, api_func=None, mf6_regression=False, make_comparison=True, ): delFiles = True for idx, arg in enumerate(sys.argv): if arg.lower() == "--keep": delFiles = False elif arg[2:].lower() in list(targets.target_dict.keys()): key = arg[2:].lower() exe0 = targets.target_dict[key] exe = os.path.join(os.path.dirname(exe0), sys.argv[idx + 1]) msg = ( "replacing {} executable ".format(key) + '"{}" with '.format(targets.target_dict[key]) + '"{}".'.format(exe) ) print(msg) targets.target_dict[key] = exe if exe_dict is not None: if not isinstance(exe_dict, dict): msg = "exe_dict must be a dictionary" assert False, msg keys = list(targets.target_dict.keys()) for key, value in exe_dict.items(): if key in keys: exe0 = targets.target_dict[key] exe = os.path.join(os.path.dirname(exe0), value) msg = ( "replacing {} executable ".format(key) + '"{}" with '.format(targets.target_dict[key]) + '"{}".'.format(exe) ) print(msg) targets.target_dict[key] = exe msg = sfmt.format("Initializing test", name) print(msg) self.name = name self.exfunc = exfunc self.simpath = None self.inpt = None self.outp = None self.coutp = None self.api_func = api_func self.mf6_regression = mf6_regression self.make_comparison = make_comparison self.action = None # set htol for comparisons if htol is None: htol = 0.001 else: msg = sfmt.format("User specified comparison htol", htol) print(msg) self.htol = htol # set pdtol for comparisons if pdtol is None: pdtol = 0.001 else: msg = sfmt.format( "User specified percent difference comparison pdtol", pdtol ) print(msg) self.pdtol = pdtol # set rclose for comparisons if rclose is None: rclose = 0.001 else: msg = sfmt.format( "User specified percent difference comparison rclose", rclose ) print(msg) self.rclose = rclose # set index for multi-simulation comparisons self.idxsim = idxsim # set compare verbosity self.cmp_verbose = cmp_verbose # set allow failure self.require_failure = require_failure self.delFiles = delFiles self.success = False # set is_ci self.is_CI = running_on_CI() return