[23186] | 1 | Index: ../trunk-jpl/test/NightlyRun/runme.py
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/test/NightlyRun/runme.py (revision 23175)
|
---|
| 4 | +++ ../trunk-jpl/test/NightlyRun/runme.py (revision 23176)
|
---|
| 5 | @@ -5,7 +5,7 @@
|
---|
| 6 | from sys import float_info
|
---|
| 7 | from glob import glob
|
---|
| 8 | from socket import gethostname
|
---|
| 9 | -from IdFromString import *
|
---|
| 10 | +from GetIds import *
|
---|
| 11 |
|
---|
| 12 | def runme(id=None,exclude=None,benchmark='nightly',procedure='check',output='none',rank=1,numprocs=1):
|
---|
| 13 | """
|
---|
| 14 | @@ -19,8 +19,12 @@
|
---|
| 15 | etc...
|
---|
| 16 |
|
---|
| 17 | Available options:
|
---|
| 18 | - 'id' followed by the list of ids requested
|
---|
| 19 | - 'exclude' ids or (parts of) test names to be excluded from the test
|
---|
| 20 | + 'id' followed by the list of ids or (parts of) test names requested
|
---|
| 21 | + Note: runs all tests by default
|
---|
| 22 | +
|
---|
| 23 | + 'exclude' ids or (parts of) test names to be excluded (same format as id)
|
---|
| 24 | + Note: exclude does nothing if 'id' is specified with different values
|
---|
| 25 | +
|
---|
| 26 | 'benchmark' 'all' (all of the tests)
|
---|
| 27 | 'nightly' (nightly run/ daily run)
|
---|
| 28 | 'ismip' : validation of ismip-hom tests
|
---|
| 29 | @@ -28,7 +32,7 @@
|
---|
| 30 | 'thermal': validation of thermal tests
|
---|
| 31 | 'mesh' : validation of mesh tests
|
---|
| 32 | 'adolc' : validation of adolc tests
|
---|
| 33 | - 'slr' : validation of slr tests
|
---|
| 34 | + 'slr' : validation of slr tests
|
---|
| 35 |
|
---|
| 36 | 'procedure' 'check' : run the test (default)
|
---|
| 37 | 'update': update the archive
|
---|
| 38 | @@ -38,10 +42,11 @@
|
---|
| 39 |
|
---|
| 40 | Examples:
|
---|
| 41 | runme()
|
---|
| 42 | - runme(exclude=101)
|
---|
| 43 | - runme(exclude='Dakota')
|
---|
| 44 | - runme(exclude=[[101,102],['Dakota','Slr']])
|
---|
| 45 | - runme(id=102,procedure='update')
|
---|
| 46 | + runme(101)
|
---|
| 47 | + runme('SquareShelf')
|
---|
| 48 | + runme(exclude=2001)
|
---|
| 49 | + runme(exclude='Dakota',benchmark='all')
|
---|
| 50 | + runme(id=[[101,102],['Dakota','Slr']])
|
---|
| 51 | """
|
---|
| 52 |
|
---|
| 53 | from parallelrange import parallelrange
|
---|
| 54 | @@ -83,54 +88,19 @@
|
---|
| 55 | #print 'list_ids after parallelrange =',list_ids
|
---|
| 56 |
|
---|
| 57 | if id:
|
---|
| 58 | - if isinstance(id,list):
|
---|
| 59 | - test_ids=id
|
---|
| 60 | - else:
|
---|
| 61 | - test_ids=[id]
|
---|
| 62 | - test_ids=set(test_ids).intersection(set(list_ids))
|
---|
| 63 | + test_ids = set(GetIds(id)).intersection(set(list_ids))
|
---|
| 64 | else:
|
---|
| 65 | - test_ids=set(list_ids)
|
---|
| 66 | + # if no tests are specifically provided, do them all
|
---|
| 67 | + test_ids = set(list_ids)
|
---|
| 68 |
|
---|
| 69 | - #print 'test_ids after list =',test_ids
|
---|
| 70 | + #print 'test_ids after list =',test_ids
|
---|
| 71 | # }}}
|
---|
| 72 | #GET exclude {{{
|
---|
| 73 | - exclude_ids = []
|
---|
| 74 | - if exclude != None and np.size(exclude) > 0:
|
---|
| 75 | - # 1 exclusion, either an id or a test name
|
---|
| 76 | - if type(exclude) == str:
|
---|
| 77 | - exclude_ids = IdFromString(exclude)
|
---|
| 78 | - if type(exclude) == int:
|
---|
| 79 | - exclude_ids = [exclude]
|
---|
| 80 | + exclude_ids = GetIds(exclude)
|
---|
| 81 |
|
---|
| 82 | - # many exclusions of either ids or test names
|
---|
| 83 | - if type(exclude) == list and len(exclude) > 0:
|
---|
| 84 | - # is everything a string or int?
|
---|
| 85 | - if np.array([type(i) == int for i in exclude]).all():
|
---|
| 86 | - exclude_ids = exclude
|
---|
| 87 | - elif np.array([type(i) == str for i in exclude]).all():
|
---|
| 88 | - exclude_ids = np.concatenate([IdFromString(i) for i in exclude])
|
---|
| 89 | -
|
---|
| 90 | - # many exclusions of both ids and test names
|
---|
| 91 | - # exclude[0] -> exclude by id
|
---|
| 92 | - # exclude[1] -> exclude by test name
|
---|
| 93 | - if type(exclude) == list and len(exclude) == 2:
|
---|
| 94 | - if type(exclude[0]) == list and len(exclude[0]) > 0 and type(exclude[0][0]) == int:
|
---|
| 95 | - exclude_ids = np.concatenate([exclude_ids,exclude[0]])
|
---|
| 96 | - if type(exclude[1]) == list and len(exclude[1]) > 0 and type(exclude[1][0]) == str:
|
---|
| 97 | - exclude_ids = np.concatenate([exclude_ids,np.concatenate([IdFromString(i) for i in exclude[1]])])
|
---|
| 98 | -
|
---|
| 99 | - # no recognizable exclusion
|
---|
| 100 | - if np.size(exclude_ids) == 0:
|
---|
| 101 | - raise RuntimeError('''runme.py: exclude (-e/-exclude) and exclude-name (-en/-exclude_name) options must appear as one of the following:
|
---|
| 102 | -
|
---|
| 103 | -exclude=101 OR -e 101
|
---|
| 104 | -exclude=\'Dakota\' OR -en 'Dakota'
|
---|
| 105 | -exclude=[101,102...] OR -e 101 102 ...
|
---|
| 106 | -exclude=[\'Dakota\',\'Slr\'...] OR -en 'Dakota' 'Slr' ...
|
---|
| 107 | -exclude=[[101,102...],[\'Dakota\',\'Slr\'...]] OR -e 101 102 ... -en 'Dakota' 'Slr' ...
|
---|
| 108 | -''')
|
---|
| 109 | - test_ids=test_ids.difference(exclude_ids)
|
---|
| 110 | + test_ids=test_ids.difference(exclude_ids)
|
---|
| 111 | #print 'test_ids after exclude =',sorted(test_ids)
|
---|
| 112 | + #return
|
---|
| 113 | # }}}
|
---|
| 114 | #Process Ids according to benchmarks {{{
|
---|
| 115 | if benchmark=='nightly':
|
---|
| 116 | @@ -279,6 +249,7 @@
|
---|
| 117 |
|
---|
| 118 | parser = argparse.ArgumentParser(description='RUNME - test deck for ISSM nightly runs')
|
---|
| 119 | parser.add_argument('-i','--id', nargs='*', type=int, help='followed by the list of ids requested', default=[])
|
---|
| 120 | + parser.add_argument('-in','--include_name', nargs='*', type=str, help='followed by the list of test names requested', default=[])
|
---|
| 121 | parser.add_argument('-e','--exclude', nargs='+', type=int, help='ids to be excluded from the test', default=[])
|
---|
| 122 | parser.add_argument('-en','--exclude_name', nargs='+', type=str, help='test names to be excluded from the test', default=[])
|
---|
| 123 | parser.add_argument('-b','--benchmark', help='nightly/ismip/eismint/thermal/mesh/...', default='nightly')
|
---|
| 124 | @@ -288,7 +259,7 @@
|
---|
| 125 | parser.add_argument('-n','--numprocs', type=int, help='numprocs', default=1)
|
---|
| 126 | args = parser.parse_args()
|
---|
| 127 |
|
---|
| 128 | - md = runme(args.id, [args.exclude,args.exclude_name], args.benchmark, args.procedure, args.output, args.rank, args.numprocs)
|
---|
| 129 | + md = runme([args.id,args.include_name], [args.exclude,args.exclude_name], args.benchmark, args.procedure, args.output, args.rank, args.numprocs)
|
---|
| 130 |
|
---|
| 131 | if args.output=='nightly':
|
---|
| 132 | print "PYTHONEXITEDCORRECTLY"
|
---|
| 133 | Index: ../trunk-jpl/test/NightlyRun/GetIds.py
|
---|
| 134 | ===================================================================
|
---|
| 135 | --- ../trunk-jpl/test/NightlyRun/GetIds.py (nonexistent)
|
---|
| 136 | +++ ../trunk-jpl/test/NightlyRun/GetIds.py (revision 23176)
|
---|
| 137 | @@ -0,0 +1,66 @@
|
---|
| 138 | +#! /usr/bin/env python
|
---|
| 139 | +from IdToName import *
|
---|
| 140 | +from IdFromString import *
|
---|
| 141 | +import numpy as np
|
---|
| 142 | +
|
---|
| 143 | +def GetIds(ids_names):
|
---|
| 144 | + """
|
---|
| 145 | + GetIds - output ids from a given array of IDs and test names
|
---|
| 146 | +
|
---|
| 147 | + the test names can be any string or sub-string present
|
---|
| 148 | + in the test's name (first line of corresponding file)
|
---|
| 149 | +
|
---|
| 150 | + test names are case sensitive
|
---|
| 151 | +
|
---|
| 152 | + Usage:
|
---|
| 153 | + ids=GetIds(101)
|
---|
| 154 | + ids=GetIds('Dakota')
|
---|
| 155 | + ids=GetIds([101,102...])
|
---|
| 156 | + ids=GetIds([\'Dakota\',\'Slr\'...])
|
---|
| 157 | + ids=GetIds([[101,102...],[\'Dakota\',\'Slr\'...]])
|
---|
| 158 | + """
|
---|
| 159 | +
|
---|
| 160 | + ids = []
|
---|
| 161 | +
|
---|
| 162 | + # 1 input, either an id or a test name
|
---|
| 163 | + if type(ids_names) == str:
|
---|
| 164 | + ids = IdFromString(ids_names)
|
---|
| 165 | + if len(ids) == 0:
|
---|
| 166 | + # fail silently
|
---|
| 167 | + return []
|
---|
| 168 | + #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"')
|
---|
| 169 | +
|
---|
| 170 | + if type(ids_names) == int:
|
---|
| 171 | + ids = [ids_names]
|
---|
| 172 | + if len(ids) == 0:
|
---|
| 173 | + # fail silently
|
---|
| 174 | + return []
|
---|
| 175 | + #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"')
|
---|
| 176 | +
|
---|
| 177 | + # many inputs of either ids or test names
|
---|
| 178 | + if type(ids_names) == list and len(ids_names) > 0:
|
---|
| 179 | + # is everything a string or int?
|
---|
| 180 | + if np.array([type(i) == int for i in ids_names]).all():
|
---|
| 181 | + ids = ids_names
|
---|
| 182 | + elif np.array([type(i) == str for i in ids_names]).all():
|
---|
| 183 | + ids = np.concatenate([IdFromString(i) for i in ids_names])
|
---|
| 184 | + if len(ids) == 0:
|
---|
| 185 | + raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive.')
|
---|
| 186 | +
|
---|
| 187 | + # many inputs of both ids and test names
|
---|
| 188 | + # ids_names[0] -> ids_names by id
|
---|
| 189 | + # ids_names[1] -> ids_names by test name
|
---|
| 190 | + if type(ids_names) == list and len(ids_names) == 2:
|
---|
| 191 | + if type(ids_names[0]) == list and len(ids_names[0]) > 0 and type(ids_names[0][0]) == int:
|
---|
| 192 | + ids = np.concatenate([ids,ids_names[0]])
|
---|
| 193 | + if type(ids_names[1]) == list and len(ids_names[1]) > 0 and type(ids_names[1][0]) == str:
|
---|
| 194 | + ids = np.concatenate([ids,np.concatenate([IdFromString(i) for i in ids_names[1]])])
|
---|
| 195 | + if len(ids) == 0:
|
---|
| 196 | + raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive.')
|
---|
| 197 | +
|
---|
| 198 | + # no recognizable ids or id formats
|
---|
| 199 | + if np.size(ids) == 0 and not np.all(np.equal(ids_names,None)):
|
---|
| 200 | + 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__)
|
---|
| 201 | +
|
---|
| 202 | + return np.array(ids).astype(int)
|
---|
| 203 | +
|
---|