Changeset 27337


Ignore:
Timestamp:
10/26/22 10:30:12 (2 years ago)
Author:
jdquinn
Message:

CHG: Run with Python 3; better pattern matching for test<integer>.py

File:
1 edited

Legend:

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

    r27209 r27337  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22#
    33# NOTE: Switch to,
     
    88#
    99import argparse
    10 from glob import glob
    1110import os
    12 from re import search, split
     11import re
    1312from sys import float_info
    1413from traceback import format_exc
     
    9089    exception'; see also jenkins/jenkins.sh). These should be counted as
    9190    failures.
     91    - Figure out why the following changes allow for correct partitioning of
     92    test set, but cause an error with ADOL-C build (some test logs are parsed
     93    twice).
    9294    """
    9395
     
    116118    # }}}
    117119    #GET ids  {{{
    118     flist = glob('test*.py')  #File name must start with 'test' and must end by '.py' and must be different than 'test.py'
    119     list_ids = [int(search(r'\d+',file.split('.')[0]).group()) for file in flist if not file == 'test.py'] # Keep test id only (skip 'test' and '.py')
    120 
    121     i1, i2 = parallelrange(rank, numprocs, len(list_ids))  #Get tests for this cpu only
     120    flist = [f for f in os.listdir('.') if re.match('test[0-9]+.py', f)] # File name must follow the format "test<integer>.py"
     121    list_ids = [int(re.search(r'\d+',f.split('.')[0]).group()) for f in flist] # Retrieve test IDs
     122    i1, i2 = parallelrange(rank, numprocs, len(list_ids))  # Get tests for this CPU only
    122123    list_ids = list_ids[i1:i2 + 1]
    123124    if np.size(id) > 0 and id is not None:
     
    172173    test_ids = list(test_ids)
    173174    test_ids.sort()
     175    print(test_ids)
     176    exit()
    174177    # }}}
    175178
     
    213216                for key in mdl.results.__dict__.keys():
    214217                    if 'Solution' in key:
    215                         solvetype = split('Solution', key)[0]
     218                        solvetype = re.split('Solution', key)[0]
    216219
    217220                #we save the results, scrap them and solve.
     
    224227                    try:
    225228                        #first look for indexing
    226                         if search(r'\d+$', fieldname):
    227                             index = int(search(r'\d+$', fieldname).group()) - 1
    228                             fieldname = fieldname[:search(r'\d+$', fieldname).start()]
     229                        if re.search(r'\d+$', fieldname):
     230                            index = int(re.search(r'\d+$', fieldname).group()) - 1
     231                            fieldname = fieldname[:re.search(r'\d+$', fieldname).start()]
    229232                        elif 'FirstStep' in fieldname:
    230233                            index = 0
    231                             fieldname = fieldname[:search('FirstStep', fieldname).start()]
     234                            fieldname = fieldname[:re.search('FirstStep', fieldname).start()]
    232235                        elif 'SecondStep' in fieldname:
    233236                            index = 1
    234                             fieldname = fieldname[:search('SecondStep', fieldname).start()]
     237                            fieldname = fieldname[:re.search('SecondStep', fieldname).start()]
    235238                        elif 'ThirdStep' in fieldname:
    236239                            index = 2
    237                             fieldname = fieldname[:search('ThirdStep', fieldname).start()]
     240                            fieldname = fieldname[:re.search('ThirdStep', fieldname).start()]
    238241                        else:
    239242                            index = 0
     
    270273                                    #probably severalmatches, we take the last one which should be the good one (Needs to be controled in the list above)
    271274                                    sufix = sufixes[np.squeeze(np.where([suf in fieldname for suf in sufixes]))[-1]]
    272                                 fieldname = fieldname[:search(sufix, fieldname).start()]
     275                                fieldname = fieldname[:re.search(sufix, fieldname).start()]
    273276                            elif fieldname.endswith("P") and index == 1:
    274277                                #we are looking for P2 but 2 as been considered as an index and so shifted by -1
Note: See TracChangeset for help on using the changeset viewer.