Changeset 23176


Ignore:
Timestamp:
08/24/18 11:00:59 (7 years ago)
Author:
kruegern
Message:

NEW: added explicit include and exclude options to runme including ability to use test names as well as ids. Works with Jenkins.

Location:
issm/trunk-jpl/test/NightlyRun
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/test/NightlyRun/runme.py

    r23160 r23176  
    66from glob import glob
    77from socket import gethostname
    8 from IdFromString import *
     8from GetIds import *
    99
    1010def runme(id=None,exclude=None,benchmark='nightly',procedure='check',output='none',rank=1,numprocs=1):
     
    2020 
    2121            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
    2428               'benchmark'     'all' (all of the tests)
    2529                          'nightly' (nightly run/ daily run)
     
    2933                          'mesh'   : validation of mesh tests
    3034                          'adolc'  : validation of adolc tests
    31                           'slr'   : validation of slr tests
     35                          'slr'    : validation of slr tests
    3236
    3337               'procedure'     'check' : run the test (default)
     
    3943            Examples:
    4044               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']])
    4550        """
    4651
     
    8489       
    8590        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))
    9192        else:
    92                 test_ids=set(list_ids)
     93                # if no tests are specifically provided, do them all
     94                test_ids = set(list_ids)
    9395               
    94                 #print 'test_ids after list =',test_ids
     96        #print 'test_ids after list =',test_ids
    9597        # }}}
    9698        #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]
    104 
    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)
     99        exclude_ids = GetIds(exclude)
     100
     101        test_ids=test_ids.difference(exclude_ids)
    133102        #print 'test_ids after exclude =',sorted(test_ids)
     103        #return
    134104        # }}}
    135105        #Process Ids according to benchmarks {{{
     
    280250        parser = argparse.ArgumentParser(description='RUNME - test deck for ISSM nightly runs')
    281251        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=[])
    282253        parser.add_argument('-e','--exclude', nargs='+', type=int, help='ids to be excluded from the test', default=[])
    283254        parser.add_argument('-en','--exclude_name', nargs='+', type=str, help='test names to be excluded from the test', default=[])
     
    289260        args = parser.parse_args()
    290261
    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)
    292263
    293264        if args.output=='nightly':
Note: See TracChangeset for help on using the changeset viewer.