Index: ../trunk-jpl/test/NightlyRun/runme.py =================================================================== --- ../trunk-jpl/test/NightlyRun/runme.py (revision 23175) +++ ../trunk-jpl/test/NightlyRun/runme.py (revision 23176) @@ -5,7 +5,7 @@ from sys import float_info from glob import glob from socket import gethostname -from IdFromString import * +from GetIds import * def runme(id=None,exclude=None,benchmark='nightly',procedure='check',output='none',rank=1,numprocs=1): """ @@ -19,8 +19,12 @@ etc... Available options: - 'id' followed by the list of ids requested - 'exclude' ids or (parts of) test names to be excluded from the test + 'id' followed by the list of ids or (parts of) test names requested + Note: runs all tests by default + + 'exclude' ids or (parts of) test names to be excluded (same format as id) + Note: exclude does nothing if 'id' is specified with different values + 'benchmark' 'all' (all of the tests) 'nightly' (nightly run/ daily run) 'ismip' : validation of ismip-hom tests @@ -28,7 +32,7 @@ 'thermal': validation of thermal tests 'mesh' : validation of mesh tests 'adolc' : validation of adolc tests - 'slr' : validation of slr tests + 'slr' : validation of slr tests 'procedure' 'check' : run the test (default) 'update': update the archive @@ -38,10 +42,11 @@ Examples: runme() - runme(exclude=101) - runme(exclude='Dakota') - runme(exclude=[[101,102],['Dakota','Slr']]) - runme(id=102,procedure='update') + runme(101) + runme('SquareShelf') + runme(exclude=2001) + runme(exclude='Dakota',benchmark='all') + runme(id=[[101,102],['Dakota','Slr']]) """ from parallelrange import parallelrange @@ -83,54 +88,19 @@ #print 'list_ids after parallelrange =',list_ids if id: - if isinstance(id,list): - test_ids=id - else: - test_ids=[id] - test_ids=set(test_ids).intersection(set(list_ids)) + test_ids = set(GetIds(id)).intersection(set(list_ids)) else: - test_ids=set(list_ids) + # if no tests are specifically provided, do them all + test_ids = set(list_ids) - #print 'test_ids after list =',test_ids + #print 'test_ids after list =',test_ids # }}} #GET exclude {{{ - exclude_ids = [] - if exclude != None and np.size(exclude) > 0: - # 1 exclusion, either an id or a test name - if type(exclude) == str: - exclude_ids = IdFromString(exclude) - if type(exclude) == int: - exclude_ids = [exclude] + exclude_ids = GetIds(exclude) - # many exclusions of either ids or test names - if type(exclude) == list and len(exclude) > 0: - # is everything a string or int? - if np.array([type(i) == int for i in exclude]).all(): - exclude_ids = exclude - elif np.array([type(i) == str for i in exclude]).all(): - exclude_ids = np.concatenate([IdFromString(i) for i in exclude]) - - # many exclusions of both ids and test names - # exclude[0] -> exclude by id - # exclude[1] -> exclude by test name - if type(exclude) == list and len(exclude) == 2: - if type(exclude[0]) == list and len(exclude[0]) > 0 and type(exclude[0][0]) == int: - exclude_ids = np.concatenate([exclude_ids,exclude[0]]) - if type(exclude[1]) == list and len(exclude[1]) > 0 and type(exclude[1][0]) == str: - exclude_ids = np.concatenate([exclude_ids,np.concatenate([IdFromString(i) for i in exclude[1]])]) - - # no recognizable exclusion - if np.size(exclude_ids) == 0: - raise RuntimeError('''runme.py: exclude (-e/-exclude) and exclude-name (-en/-exclude_name) options must appear as one of the following: - -exclude=101 OR -e 101 -exclude=\'Dakota\' OR -en 'Dakota' -exclude=[101,102...] OR -e 101 102 ... -exclude=[\'Dakota\',\'Slr\'...] OR -en 'Dakota' 'Slr' ... -exclude=[[101,102...],[\'Dakota\',\'Slr\'...]] OR -e 101 102 ... -en 'Dakota' 'Slr' ... -''') - test_ids=test_ids.difference(exclude_ids) + test_ids=test_ids.difference(exclude_ids) #print 'test_ids after exclude =',sorted(test_ids) + #return # }}} #Process Ids according to benchmarks {{{ if benchmark=='nightly': @@ -279,6 +249,7 @@ parser = argparse.ArgumentParser(description='RUNME - test deck for ISSM nightly runs') parser.add_argument('-i','--id', nargs='*', type=int, help='followed by the list of ids requested', default=[]) + parser.add_argument('-in','--include_name', nargs='*', type=str, help='followed by the list of test names requested', default=[]) parser.add_argument('-e','--exclude', nargs='+', type=int, help='ids to be excluded from the test', default=[]) parser.add_argument('-en','--exclude_name', nargs='+', type=str, help='test names to be excluded from the test', default=[]) parser.add_argument('-b','--benchmark', help='nightly/ismip/eismint/thermal/mesh/...', default='nightly') @@ -288,7 +259,7 @@ parser.add_argument('-n','--numprocs', type=int, help='numprocs', default=1) args = parser.parse_args() - md = runme(args.id, [args.exclude,args.exclude_name], args.benchmark, args.procedure, args.output, args.rank, args.numprocs) + md = runme([args.id,args.include_name], [args.exclude,args.exclude_name], args.benchmark, args.procedure, args.output, args.rank, args.numprocs) if args.output=='nightly': print "PYTHONEXITEDCORRECTLY" Index: ../trunk-jpl/test/NightlyRun/GetIds.py =================================================================== --- ../trunk-jpl/test/NightlyRun/GetIds.py (nonexistent) +++ ../trunk-jpl/test/NightlyRun/GetIds.py (revision 23176) @@ -0,0 +1,66 @@ +#! /usr/bin/env python +from IdToName import * +from IdFromString import * +import numpy as np + +def GetIds(ids_names): + """ + GetIds - output ids from a given array of IDs and test names + + the test names can be any string or sub-string present + in the test's name (first line of corresponding file) + + test names are case sensitive + + Usage: + ids=GetIds(101) + ids=GetIds('Dakota') + ids=GetIds([101,102...]) + ids=GetIds([\'Dakota\',\'Slr\'...]) + ids=GetIds([[101,102...],[\'Dakota\',\'Slr\'...]]) + """ + + ids = [] + + # 1 input, either an id or a test name + if type(ids_names) == str: + ids = IdFromString(ids_names) + if len(ids) == 0: + # fail silently + return [] + #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"') + + if type(ids_names) == int: + ids = [ids_names] + if len(ids) == 0: + # fail silently + return [] + #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"') + + # many inputs of either ids or test names + if type(ids_names) == list and len(ids_names) > 0: + # is everything a string or int? + if np.array([type(i) == int for i in ids_names]).all(): + ids = ids_names + elif np.array([type(i) == str for i in ids_names]).all(): + ids = np.concatenate([IdFromString(i) for i in ids_names]) + if len(ids) == 0: + raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive.') + + # many inputs of both ids and test names + # ids_names[0] -> ids_names by id + # ids_names[1] -> ids_names by test name + if type(ids_names) == list and len(ids_names) == 2: + if type(ids_names[0]) == list and len(ids_names[0]) > 0 and type(ids_names[0][0]) == int: + ids = np.concatenate([ids,ids_names[0]]) + if type(ids_names[1]) == list and len(ids_names[1]) > 0 and type(ids_names[1][0]) == str: + ids = np.concatenate([ids,np.concatenate([IdFromString(i) for i in ids_names[1]])]) + if len(ids) == 0: + raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive.') + + # no recognizable ids or id formats + if np.size(ids) == 0 and not np.all(np.equal(ids_names,None)): + 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__) + + return np.array(ids).astype(int) +