Changeset 991df6a in flex_extract.git for python/testsuite.py


Ignore:
Timestamp:
May 14, 2018, 10:11:29 PM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
812283d
Parents:
efdb01a
Message:

finished documentation (except plot_retrieved)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/testsuite.py

    refdb01a r991df6a  
    11#!/usr/bin/env python
     2# -*- coding: utf-8 -*-
     3#************************************************************************
     4# TODO AP
     5#
     6# - provide more tests
     7# - provide more documentation
     8# -
     9#************************************************************************
    210
    3 # This software is licensed under the terms of the Apache Licence Version 2.0
    4 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
     11#*******************************************************************************
     12# @Author: Leopold Haimberger (University of Vienna)
    513#
    6 # Leopold Haimberger, Dec 2015
     14# @Date: December 2015
    715#
    8 # Functionality provided: This script triggers the ECMWFDATA test suite. Call with
    9 # testsuite.py [test group]
     16# @Change History:
    1017#
     18#    February 2018 - Anne Philipp (University of Vienna):
     19#        - applied PEP8 style guide
     20#        - added documentation
    1121#
    12 # Further documentation may be obtained from www.flexpart.eu
     22# @License:
     23#    (C) Copyright 2015-2018.
    1324#
    14 # Test groups are specified in testsuite.json
    15 # in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed
    16 # ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/
    17 # dateutils
    18 # matplotlib (optional, for debugging)
     25#    This software is licensed under the terms of the Apache Licence Version 2.0
     26#    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
     27#
     28# @Program Functionality:
     29#    This script triggers the ECMWFDATA test suite. Call with
     30#    testsuite.py [test group]
     31#
     32# @Program Content:
     33#
     34#*******************************************************************************
    1935
    20 import os,sys
     36# ------------------------------------------------------------------------------
     37# MODULES
     38# ------------------------------------------------------------------------------
     39import os
     40import sys
    2141import json
    2242import subprocess
    2343
     44# ------------------------------------------------------------------------------
     45# PROGRAM
     46# ------------------------------------------------------------------------------
    2447try:
    25     taskfile=open('testsuite.json')
     48    taskfile = open('testsuite.json')
    2649except:
    2750    print 'could not open suite definition file testsuite.json'
     
    3356    exit()
    3457
    35 fprs=os.getenv('FLEXPART_ROOT_SCRIPTS')
     58fprs = os.getenv('FLEXPART_ROOT_SCRIPTS')
    3659if fprs is None:
    3760    print 'FLEXPART_ROOT_SCRIPTS not set .. some test jobs may fail'
    3861
    39 tasks=json.load(taskfile,encoding='latin-1')
     62tasks = json.load(taskfile, encoding='latin-1')
    4063taskfile.close()
    4164if not os.path.exists('../test'):
    4265    os.makedirs('../test')
    43 if len(sys.argv)>1:
    44     groups=sys.argv[1:]
     66if len(sys.argv) > 1:
     67    groups = sys.argv[1:]
    4568else:
    46     groups=['xinstall','default','ops','work','cv','fc']#,'hires']
    47 jobcounter=0
    48 jobfailed=0
     69    groups = ['xinstall', 'default', 'ops', 'work', 'cv', 'fc']#,'hires']
     70jobcounter = 0
     71jobfailed = 0
    4972for g in groups:
    5073    try:
    51         tk,tv=g,tasks[g]
     74        tk, tv = g, tasks[g]
    5275    except:
    5376        continue
    54     garglist=[]
    55     for ttk,ttv in tv.iteritems():
    56         if isinstance(ttv,basestring):
    57             if ttk!='script':
    58                 garglist.append('--'+ttk)
    59                 if '$'==ttv[0]:
     77    garglist = []
     78    for ttk, ttv in tv.iteritems():
     79        if isinstance(ttv, basestring):
     80            if ttk != 'script':
     81                garglist.append('--' + ttk)
     82                if '$' == ttv[0]:
    6083                    garglist.append(os.path.expandvars(ttv))
    6184                else:
    6285                    garglist.append(ttv)
    63     for ttk,ttv in tv.iteritems():
    64         if isinstance(ttv,dict):
    65             arglist=[]
    66             for tttk,tttv in ttv.iteritems():
    67                 if isinstance(tttv,basestring):
    68                         arglist.append('--'+tttk)
     86    for ttk, ttv in tv.iteritems():
     87        if isinstance(ttv, dict):
     88            arglist = []
     89            for tttk, tttv in ttv.iteritems():
     90                if isinstance(tttv, basestring):
     91                        arglist.append('--' + tttk)
    6992                        if '$' in tttv[0]:
    7093                            arglist.append(os.path.expandvars(tttv))
    7194                        else:
    7295                            arglist.append(tttv)
    73             print 'Command: ',' '.join([tv['script']]+garglist+arglist)
    74             o='../test/'+tk+'_'+ttk+'_'+'_'.join(ttv.keys())
    75             print 'Output will be sent to ',o
    76             f=open(o,'w')
     96            print 'Command: ', ' '.join([tv['script']] + garglist + arglist)
     97            o = '../test/' + tk + '_' + ttk + '_' + '_'.join(ttv.keys())
     98            print 'Output will be sent to ', o
     99            f = open(o, 'w')
    77100            try:
    78                 p=subprocess.check_call([tv['script']]+garglist+arglist,stdout=f,stderr=f)
     101                p = subprocess.check_call([tv['script']] + garglist + arglist,
     102                                          stdout=f, stderr=f)
    79103            except:
    80104                f.write('\nFAILED\n')
    81105                print 'FAILED'
    82                 jobfailed+=1
    83             jobcounter+=1
     106                jobfailed += 1
     107            jobcounter += 1
    84108            f.close()
    85109
    86110print 'Test suite tasks completed'
    87 print str(jobcounter-jobfailed)+' successful, '+str(jobfailed)+' failed'
     111print str(jobcounter-jobfailed) + ' successful, ' + str(jobfailed) + ' failed'
    88112print 'If tasks have been submitted via ECACCESS please check emails'
    89113
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG