source:
issm/oecreview/Archive/22819-23185/ISSM-23175-23176.diff
Last change on this file was 23186, checked in by , 7 years ago | |
---|---|
File size: 8.4 KB |
-
../trunk-jpl/test/NightlyRun/runme.py
5 5 from sys import float_info 6 6 from glob import glob 7 7 from socket import gethostname 8 from IdFromStringimport *8 from GetIds import * 9 9 10 10 def runme(id=None,exclude=None,benchmark='nightly',procedure='check',output='none',rank=1,numprocs=1): 11 11 """ … … 19 19 etc... 20 20 21 21 Available options: 22 'id' followed by the list of ids requested 23 'exclude' ids or (parts of) test names to be excluded from the test 22 'id' followed by the list of ids or (parts of) test names requested 23 Note: runs all tests by default 24 25 'exclude' ids or (parts of) test names to be excluded (same format as id) 26 Note: exclude does nothing if 'id' is specified with different values 27 24 28 'benchmark' 'all' (all of the tests) 25 29 'nightly' (nightly run/ daily run) 26 30 'ismip' : validation of ismip-hom tests … … 28 32 'thermal': validation of thermal tests 29 33 'mesh' : validation of mesh tests 30 34 'adolc' : validation of adolc tests 31 'slr' : validation of slr tests35 'slr' : validation of slr tests 32 36 33 37 'procedure' 'check' : run the test (default) 34 38 'update': update the archive … … 38 42 39 43 Examples: 40 44 runme() 41 runme(exclude=101) 42 runme(exclude='Dakota') 43 runme(exclude=[[101,102],['Dakota','Slr']]) 44 runme(id=102,procedure='update') 45 runme(101) 46 runme('SquareShelf') 47 runme(exclude=2001) 48 runme(exclude='Dakota',benchmark='all') 49 runme(id=[[101,102],['Dakota','Slr']]) 45 50 """ 46 51 47 52 from parallelrange import parallelrange … … 83 88 #print 'list_ids after parallelrange =',list_ids 84 89 85 90 if id: 86 if isinstance(id,list): 87 test_ids=id 88 else: 89 test_ids=[id] 90 test_ids=set(test_ids).intersection(set(list_ids)) 91 test_ids = set(GetIds(id)).intersection(set(list_ids)) 91 92 else: 92 test_ids=set(list_ids) 93 # if no tests are specifically provided, do them all 94 test_ids = set(list_ids) 93 95 94 96 #print 'test_ids after list =',test_ids 95 97 # }}} 96 98 #GET exclude {{{ 97 exclude_ids = [] 98 if exclude != None and np.size(exclude) > 0: 99 # 1 exclusion, either an id or a test name 100 if type(exclude) == str: 101 exclude_ids = IdFromString(exclude) 102 if type(exclude) == int: 103 exclude_ids = [exclude] 99 exclude_ids = GetIds(exclude) 104 100 105 # many exclusions of either ids or test names 106 if type(exclude) == list and len(exclude) > 0: 107 # is everything a string or int? 108 if np.array([type(i) == int for i in exclude]).all(): 109 exclude_ids = exclude 110 elif np.array([type(i) == str for i in exclude]).all(): 111 exclude_ids = np.concatenate([IdFromString(i) for i in exclude]) 112 113 # many exclusions of both ids and test names 114 # exclude[0] -> exclude by id 115 # exclude[1] -> exclude by test name 116 if type(exclude) == list and len(exclude) == 2: 117 if type(exclude[0]) == list and len(exclude[0]) > 0 and type(exclude[0][0]) == int: 118 exclude_ids = np.concatenate([exclude_ids,exclude[0]]) 119 if type(exclude[1]) == list and len(exclude[1]) > 0 and type(exclude[1][0]) == str: 120 exclude_ids = np.concatenate([exclude_ids,np.concatenate([IdFromString(i) for i in exclude[1]])]) 121 122 # no recognizable exclusion 123 if np.size(exclude_ids) == 0: 124 raise RuntimeError('''runme.py: exclude (-e/-exclude) and exclude-name (-en/-exclude_name) options must appear as one of the following: 125 126 exclude=101 OR -e 101 127 exclude=\'Dakota\' OR -en 'Dakota' 128 exclude=[101,102...] OR -e 101 102 ... 129 exclude=[\'Dakota\',\'Slr\'...] OR -en 'Dakota' 'Slr' ... 130 exclude=[[101,102...],[\'Dakota\',\'Slr\'...]] OR -e 101 102 ... -en 'Dakota' 'Slr' ... 131 ''') 132 test_ids=test_ids.difference(exclude_ids) 101 test_ids=test_ids.difference(exclude_ids) 133 102 #print 'test_ids after exclude =',sorted(test_ids) 103 #return 134 104 # }}} 135 105 #Process Ids according to benchmarks {{{ 136 106 if benchmark=='nightly': … … 279 249 280 250 parser = argparse.ArgumentParser(description='RUNME - test deck for ISSM nightly runs') 281 251 parser.add_argument('-i','--id', nargs='*', type=int, help='followed by the list of ids requested', default=[]) 252 parser.add_argument('-in','--include_name', nargs='*', type=str, help='followed by the list of test names requested', default=[]) 282 253 parser.add_argument('-e','--exclude', nargs='+', type=int, help='ids to be excluded from the test', default=[]) 283 254 parser.add_argument('-en','--exclude_name', nargs='+', type=str, help='test names to be excluded from the test', default=[]) 284 255 parser.add_argument('-b','--benchmark', help='nightly/ismip/eismint/thermal/mesh/...', default='nightly') … … 288 259 parser.add_argument('-n','--numprocs', type=int, help='numprocs', default=1) 289 260 args = parser.parse_args() 290 261 291 md = runme( args.id, [args.exclude,args.exclude_name], args.benchmark, args.procedure, args.output, args.rank, args.numprocs)262 md = runme([args.id,args.include_name], [args.exclude,args.exclude_name], args.benchmark, args.procedure, args.output, args.rank, args.numprocs) 292 263 293 264 if args.output=='nightly': 294 265 print "PYTHONEXITEDCORRECTLY" -
../trunk-jpl/test/NightlyRun/GetIds.py
1 #! /usr/bin/env python 2 from IdToName import * 3 from IdFromString import * 4 import numpy as np 5 6 def GetIds(ids_names): 7 """ 8 GetIds - output ids from a given array of IDs and test names 9 10 the test names can be any string or sub-string present 11 in the test's name (first line of corresponding file) 12 13 test names are case sensitive 14 15 Usage: 16 ids=GetIds(101) 17 ids=GetIds('Dakota') 18 ids=GetIds([101,102...]) 19 ids=GetIds([\'Dakota\',\'Slr\'...]) 20 ids=GetIds([[101,102...],[\'Dakota\',\'Slr\'...]]) 21 """ 22 23 ids = [] 24 25 # 1 input, either an id or a test name 26 if type(ids_names) == str: 27 ids = IdFromString(ids_names) 28 if len(ids) == 0: 29 # fail silently 30 return [] 31 #raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive. Test names are in the first line of a given test eg: "Square" would include test101.py: "SquareShelfConstrainedStressSSA2d"') 32 33 if type(ids_names) == int: 34 ids = [ids_names] 35 if len(ids) == 0: 36 # fail silently 37 return [] 38 #raise RuntimeError('runme.py: GetIds.py: No tests with ids matching "'+ids_names+'" were found. Check that there is a test file named "test'+str(ids_names)+'.py"') 39 40 # many inputs of either ids or test names 41 if type(ids_names) == list and len(ids_names) > 0: 42 # is everything a string or int? 43 if np.array([type(i) == int for i in ids_names]).all(): 44 ids = ids_names 45 elif np.array([type(i) == str for i in ids_names]).all(): 46 ids = np.concatenate([IdFromString(i) for i in ids_names]) 47 if len(ids) == 0: 48 raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive.') 49 50 # many inputs of both ids and test names 51 # ids_names[0] -> ids_names by id 52 # ids_names[1] -> ids_names by test name 53 if type(ids_names) == list and len(ids_names) == 2: 54 if type(ids_names[0]) == list and len(ids_names[0]) > 0 and type(ids_names[0][0]) == int: 55 ids = np.concatenate([ids,ids_names[0]]) 56 if type(ids_names[1]) == list and len(ids_names[1]) > 0 and type(ids_names[1][0]) == str: 57 ids = np.concatenate([ids,np.concatenate([IdFromString(i) for i in ids_names[1]])]) 58 if len(ids) == 0: 59 raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive.') 60 61 # no recognizable ids or id formats 62 if np.size(ids) == 0 and not np.all(np.equal(ids_names,None)): 63 raise RuntimeError('runme.py: GetIds.py: include and exclude options (-i/--id; -in/--include_name; -e/--exclude; -en/--exclude_name) options must follow GetIds usage format:\n'+GetIds.__doc__) 64 65 return np.array(ids).astype(int) 66
Note:
See TracBrowser
for help on using the repository browser.