From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QcgEk-0003rB-1T for garchives@archives.gentoo.org; Fri, 01 Jul 2011 16:06:36 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BDC9C1C064; Fri, 1 Jul 2011 16:06:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 7FB9D1C064 for ; Fri, 1 Jul 2011 16:06:25 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D3D2666A46 for ; Fri, 1 Jul 2011 16:06:24 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 1FACA8003D for ; Fri, 1 Jul 2011 16:06:24 +0000 (UTC) From: "Andrea Arteaga" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrea Arteaga" Message-ID: Subject: [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/ X-VCS-Repository: proj/auto-numerical-bench X-VCS-Files: app-benchmarks/autobench/files/python/PortageUtils.py app-benchmarks/autobench/files/python/btlbase.py app-benchmarks/autobench/files/python/main.py X-VCS-Directories: app-benchmarks/autobench/files/python/ X-VCS-Committer: spiros X-VCS-Committer-Name: Andrea Arteaga X-VCS-Revision: ec1374ad483c4d7a71df5fdc4e2a983c7471bb0b Date: Fri, 1 Jul 2011 16:06:24 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 8cd87eb185bf947cfbcdac82805fa8b8 commit: ec1374ad483c4d7a71df5fdc4e2a983c7471bb0b Author: spiros gmail com> AuthorDate: Fri Jul 1 16:05:49 2011 +0000 Commit: Andrea Arteaga gmail com> CommitDate: Fri Jul 1 16:05:49 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/auto-numerica= l-bench.git;a=3Dcommit;h=3Dec1374ad More logging (almost everything), bugs solved (multiple execution for figures, wrong packages with no revision). --- .../autobench/files/python/PortageUtils.py | 16 +++-- app-benchmarks/autobench/files/python/btlbase.py | 12 ++-- app-benchmarks/autobench/files/python/main.py | 66 ++++++++++++--= ----- 3 files changed, 59 insertions(+), 35 deletions(-) diff --git a/app-benchmarks/autobench/files/python/PortageUtils.py b/app-= benchmarks/autobench/files/python/PortageUtils.py index c162e1d..66d0b80 100644 --- a/app-benchmarks/autobench/files/python/PortageUtils.py +++ b/app-benchmarks/autobench/files/python/PortageUtils.py @@ -4,8 +4,9 @@ import portage import os =20 class InstallException(Exception): - def __init__(self, command): + def __init__(self, command, logfile): self.command =3D command + self.logfile =3D logfile =20 def available_packages(pattern): """Returns a list of packages matching the given pattern. @@ -16,6 +17,12 @@ def available_packages(pattern): """ return [portage.catpkgsplit(l) \ for l in cmd.getoutput('equery -q list -po ' + pattern).split()] + =20 +def normalize_cpv(cpv): + if cpv[-1] !=3D 'r0': + return '%s/%s-%s-%s' % cpv + else: + return '%s/%s-%s' % cpv[:-1] =20 =20 def install_package(package, env=3D{}, root=3D'/', pkgdir=3D'usr/portage= /packages', @@ -40,10 +47,7 @@ def install_package(package, env=3D{}, root=3D'/', pkg= dir=3D'usr/portage/packages', """ =20 =20 # Retrieve package string - if package[-1] !=3D 'r0': - pkg =3D '%s/%s-%s-%s' % package - else: - pkg =3D '%s/%s-%s' % package[:-1] + pkg =3D normalize_cpv(package) =20 # Setup command line env['PKGDIR'] =3D pkgdir @@ -69,7 +73,7 @@ def install_package(package, env=3D{}, root=3D'/', pkgd= ir=3D'usr/portage/packages', fout.close() if p.returncode !=3D 0: # In case of error, print the whole emerge command - raise InstallException(cl) + raise InstallException(cl, logfile) =20 if __name__ =3D=3D '__main__': # Just a test diff --git a/app-benchmarks/autobench/files/python/btlbase.py b/app-bench= marks/autobench/files/python/btlbase.py index a8dc3f4..d9a911a 100644 --- a/app-benchmarks/autobench/files/python/btlbase.py +++ b/app-benchmarks/autobench/files/python/btlbase.py @@ -1,6 +1,7 @@ import sys, os, shlex import commands as cmd import subprocess as sp +from os.path import join as pjoin =20 try: import matplotlib.pyplot as plt @@ -44,7 +45,8 @@ class BTLBase: Print =3D self.Print libdir =3D self.libdir name =3D self.libname - files =3D ['%s/bench_%s_%s.dat' %(testdir, op, name) for op in s= elf.tests] + files =3D [pjoin(testdir, 'bench_%s_%s.dat' % (op, name)) \ + for op in self.tests] =20 # Create dir. If all results already exist use them and do not p= erform # the tests, otherwise remove every old results. @@ -58,8 +60,8 @@ class BTLBase: if not runtests: Print("Not testing: results exist") results =3D {} - for i in self.tests: - results[i] =3D '%s/bench_%s_%s.dat' %(testdir, i, name) + for op in self.tests: + results[op] =3D pjoin(testdir, 'bench_%s_%s.dat'%(op,nam= e)) return results =20 for i in files: @@ -125,7 +127,7 @@ class BTLBase: break resfile =3D errline.split()[-1] testname =3D resfile[6:-5-len(name)] - results[testname] =3D resfile + results[testname] =3D pjoin(testdir, resfile) Print(resfile) Print.down() for i in xrange(100): @@ -190,7 +192,7 @@ class BTLBase: plt.semilogx(x,y, label=3Dimpl, hold=3DTrue) plt.legend(loc=3D'best') plt.grid(True) - fname =3D figdir + '/' + test + '.png' + fname =3D os.path.join(figdir, test+".png") plt.savefig(fname, format=3D'png') self.Print('Figure ' + fname + ' saved') =20 diff --git a/app-benchmarks/autobench/files/python/main.py b/app-benchmar= ks/autobench/files/python/main.py index 21e3c34..991d735 100644 --- a/app-benchmarks/autobench/files/python/main.py +++ b/app-benchmarks/autobench/files/python/main.py @@ -1,6 +1,7 @@ #! /usr/bin/env python2 =20 import os, sys, shlex +from os.path import join as pjoin from PortageUtils import * import subprocess as sp import time @@ -8,18 +9,34 @@ import time # Retrieve relevant files/directories curdir =3D os.path.abspath('.') scriptdir =3D os.path.dirname(os.path.realpath(__file__)) +rootsdir =3D "/var/tmp/benchmarks/roots/" +testsdir =3D "/var/tmp/benchmarks/tests/" if os.getuid() =3D=3D 0: pkgsdir =3D "/var/cache/benchmarks/packages/" - figdir =3D "/var/cache/benchmarks/results/" + figdirb =3D "/var/cache/benchmarks/results/" else: pkgsdir =3D os.environ['HOME'] + "/.benchmarks/packages/" - figdir =3D os.environ['HOME'] + "/.benchmarks/results/" -figdir +=3D time.strftime('%Y%m%d-%H%M') + '/' -rootsdir =3D "/var/tmp/benchmarks/roots/" -testsdir =3D "/var/tmp/benchmarks/tests/" + figdirb =3D os.environ['HOME'] + "/.benchmarks/results/" + =20 +# Library directory (lib32 vs. lib64) libdir =3D sp.Popen \ ('ABI=3D$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI= `/', \ stdout=3Dsp.PIPE, shell=3DTrue).communicate()[0].strip() + =20 +# Figures directory +figdir =3D figdirb + time.strftime('%Y-%m-%d') +if os.path.exists(figdir): + n =3D 1 + while True: + figdir =3D figdirb + time.strftime('%Y-%m-%d') + "_%i"%n + if not os.path.exists(figdir): + os.makedirs(figdir) + break + n +=3D 1 +else: + os.makedirs(figdir) + =20 +# Logs directory logdir =3D "/var/log/benchmarks/" + time.strftime('%Y-%m-%d') if os.path.exists(logdir): n =3D 1 @@ -145,51 +162,54 @@ input =3D file(testsfname).read() tests =3D tests_from_input(input) =20 # Write summary -print 60*'=3D' +print 80*'=3D' print "The following tests will be run:" for tname, ttest in tests.items(): print "Test: " + tname - print " - Package: " + "%s/%s-%s-%s" % ttest['package'] + print " - Package: " + normalize_cpv(ttest['package']) print " - Environment: " + \ ' '.join([n+'=3D"'+v+'"' for n,v in ttest['env'].items()]) print -print 60*'=3D' +print 80*'=3D' print =20 for tn,(name,test) in enumerate(tests.items(),1): Print("BEGIN TEST %i - %s" % (tn, name)) =20 - pkgdir =3D "%s/%s/" % (pkgsdir, name) - root =3D "%s/%s/" % (rootsdir, name) - tlogdir =3D os.path.join(logdir, name) + pkgdir =3D pjoin(pkgsdir, name) + root =3D pjoin(rootsdir, name) + tlogdir =3D pjoin(logdir, name) os.path.exists(tlogdir) or os.makedirs(tlogdir) =20 # Emerge package Print.down() - package =3D "%s/%s-%s-%s" % test['package'] - archive =3D pkgdir+package+".tbz2" + package =3D normalize_cpv(test['package']) + archive =3D pjoin(pkgdir, package+".tbz2") Print("Emerging package %s" % package) if os.path.exists(archive): Print("Package already emerged - skipping") else: try: - logfile =3D os.path.join(tlogdir, 'emerge.log') + logfile =3D pjoin(tlogdir, 'emerge.log') + Print("(Run 'tail -f " + logfile + " | less' on another term= inal" \ + + " to see the progress)") install_package( \ test['package'], env=3Dtest['env'], root=3Droot, pkgdir=3D= pkgdir, \ logfile=3Dlogfile ) # Unpack the archive onto the given root directory - archive =3D pkgdir + package + '.tbz2' os.path.exists(root) or os.makedirs(root) - tarcmd =3D "tar xjf " + archive + " -C " + root - tarp =3D sp.Popen(tarcmd, stdout=3Dsp.PIPE, stderr=3Dsp.PIPE= , shell=3DTrue) - tarp.communicate() + tarcmd =3D ['tar', 'xjf', archive, '-C', root] + logfile =3D file(pjoin(tlogdir, 'tar.log'), 'w') + tarp =3D sp.Popen(tarcmd, stdout=3Dlogfile, stderr=3Dsp.STDO= UT) + tarp.wait() + logfile.close() if tarp.returncode !=3D 0: - raise InstallException(tarcmd) + raise InstallException(tarcmd, logfile.name) =20 except InstallException as e: Print("Package %s failed to emerge" % package) - Print("See emerge log: " + logfile) + Print("Error log: " + e.logfile) Print.up() print continue @@ -206,7 +226,7 @@ for tn,(name,test) in enumerate(tests.items(),1): Print.down() =20 # Run the test suite - testdir =3D "%s/%s/%s" % (testsdir, name, impl) + testdir =3D os.path.join(testsdir, name, impl) test['results'][impl] =3D \ mod.run_test(root, impl, testdir, env=3Dtest['env'], logdir=3D= tlogdir) Print.up() @@ -216,9 +236,7 @@ for tn,(name,test) in enumerate(tests.items(),1): =20 =20 # Reports will be saved in figdir -if not os.path.exists(figdir): - os.makedirs(figdir) - =20 +os.path.exists(figdir) or os.makedirs(figdir) =20 results =3D {} for (name,test) in tests.items(): if test.has_key('implementations'):