diff --git a/README.rst b/README.rst index 37e750d56020b8db74829855e5a657a06fd60e7d..676b1e18a25d1777ab9f2d513d06baa899e754ca 100644 --- a/README.rst +++ b/README.rst @@ -136,11 +136,12 @@ A Flask based website that runs the Finesse test suites is included in PyKat. Th Prerequistes: Flask Numpy + CodernityDB Command to start server: .. code:: bash - python -m pykat.test.web_server --path=[path to create website] --port=[HTTP port] --git-bin=[path to git binary] + python -m pykat.testing.web_server --path=[path to create website] --port=[HTTP port] --git-bin=[path to git binary] The website can then be accessed in a web browser at the address: localhost:[port] \ No newline at end of file diff --git a/pykat/testing/test.py b/pykat/testing/test.py index ead6ca71f4a9ccdda89c337ac95ebd552ac015dd..75db325b6c6d5969aa538395c654d71e6acc18a9 100755 --- a/pykat/testing/test.py +++ b/pykat/testing/test.py @@ -47,7 +47,7 @@ def run_kat_file(item): #try: start = time.time() - out,err = utils.runcmd(["nice", "--18", FINESSE_EXE, "--noheader", kat], cwd=SUITE_PATH) + out,err = utils.runcmd([FINESSE_EXE, "--noheader", kat], cwd=SUITE_PATH) runtime = time.time()-start OUT_FILE = os.path.join(SUITE_PATH,basename + ".out") @@ -321,7 +321,7 @@ class FinesseTestProcess(Thread): self.pool = Pool(initializer=initProcess,initargs=(self.done_kats,) ,processes = self.pool_size) results = self.pool.imap_unordered(run_kat_file, runs, 1) - print "DONE POOL!!!!" + print "Finsihed running pool of kats" self.pool.close() for result in results: @@ -338,7 +338,7 @@ class FinesseTestProcess(Thread): if len(self.kat_run_exceptions[suite].keys()) > 0: print "Could not run the following kats:\n" + "\n".join(self.kat_run_exceptions[suite].keys()) + " in " + suite else: - print "No errors whilst running" + suite + print "No exceptions whilst running: " + suite self.diffing = True @@ -348,14 +348,14 @@ class FinesseTestProcess(Thread): print "Diffing suite: " + suite + "..." outs = [] - SUITE_PATH = os.path.join(OUTPUTS_DIR,suite) - + SUITE_PATH = os.path.join(OUTPUTS_DIR, suite) + for files in os.listdir(SUITE_PATH): if files.endswith(".out"): outs.append(files) REF_DIR = os.path.join(self.TEST_DIR,"kat_test",suite,"reference") - + if not os.path.exists(REF_DIR): raise Exception("Suite reference directory doesn't exist: " + REF_DIR) @@ -371,7 +371,7 @@ class FinesseTestProcess(Thread): ref_arr = np.loadtxt(ref_file, dtype=np.float64) out_arr = np.loadtxt(out_file, dtype=np.float64) - + if ref_arr.shape != out_arr.shape: raise DiffException("Reference and output are different shapes", out) @@ -398,8 +398,7 @@ class FinesseTestProcess(Thread): else: max = np.max(rel_diff) - self.output_differences[suite][out] = (False, - max) + self.output_differences[suite][out] = (False, max) @@ -410,10 +409,13 @@ class FinesseTestProcess(Thread): f_out.close() f_in.close() + print "removing out file ", out_file os.remove(out_file) self.done_kats.value += 1 - + + print "Finished diffing..." + REPORT_PATH = os.path.join(self.BASE_DIR,"reports") if not os.path.exists(REPORT_PATH): diff --git a/pykat/testing/web/templates/finesse_test.html b/pykat/testing/web/templates/finesse_test.html index f2ada1300cf022a7f138d77b0efcb44d0dda35d9..3f9a7b6420d531c57148b6ec49de88db6b709b0f 100644 --- a/pykat/testing/web/templates/finesse_test.html +++ b/pykat/testing/web/templates/finesse_test.html @@ -290,7 +290,8 @@ $(nTd).empty(); $(nTd).append(a); - $(nTd).append(b); + // removed ability to rerun, doesn't quite work + //$(nTd).append(b); }, "mDataProp": "test_id", "bSearchable": false, "sTitle": "", "bSortable": false }, { "mDataProp": "test_id", "sTitle": "Test ID","bSearchable": true, "bVisible": true, "sClass": "center" }, @@ -443,6 +444,8 @@ }); } + + function updateBranches(){ $("#btnStartTest").attr("disabled", true); blist = $("#branch_list"); diff --git a/pykat/testing/web/web_interface.py b/pykat/testing/web/web_interface.py index 086e8858fea542a273852008ae23f0ce6c768513..7ead48160c3d19ee9c334d2887efea5dcbbea68a 100644 --- a/pykat/testing/web/web_interface.py +++ b/pykat/testing/web/web_interface.py @@ -19,6 +19,7 @@ import numpy as np from pykat.testing.web.database_indices import TestIDIndex, SrcCommitIndex, KatTestIndex import re, gzip import os, sys, traceback +from multiprocessing import cpu_count global current_test, scheduled_tests, schedule_lock,enabled_suites @@ -200,9 +201,11 @@ class FinesseProcessWatcher(Thread): EXE = "" KAT_EXE = os.path.join(app.instance_path,"tests",str(self.process_to_watch.test_id),"build","kat" + EXE) + KAT_INI = os.path.join(app.instance_path,"tests",str(self.process_to_watch.test_id),"build","kat.ini") KAT_STORE_PATH = os.path.join(app.instance_path,"kat_store") KAT_STORE_EXE = os.path.join(KAT_STORE_PATH,"kat_" + str(self.process_to_watch.get_version()) + EXE) - + KAT_STORE_INI = os.path.join(KAT_STORE_PATH,"kat.ini_" + str(self.process_to_watch.get_version())) + if not os.path.exists(KAT_STORE_PATH): os.mkdir(KAT_STORE_PATH) @@ -211,13 +214,19 @@ class FinesseProcessWatcher(Thread): os.remove(KAT_STORE_EXE) shutil.copyfile(KAT_EXE, KAT_STORE_EXE) - + + if os.path.exists(KAT_INI): + if os.path.exists(KAT_STORE_INI): + os.remove(KAT_STORE_INI) + + shutil.copyfile(KAT_INI, KAT_STORE_INI) + # Remove the src and lib directories from the build as they are not needed # and take up a fair bit of space BUILD_PATH = os.path.join(self.process_to_watch.BASE_DIR, "build") - utils.runcmd(["rm","src","-rf"],cwd=BUILD_PATH) - utils.runcmd(["rm","lib","-rf"],cwd=BUILD_PATH) + utils.runcmd(["rm","-rf","src"],cwd=BUILD_PATH) + utils.runcmd(["rm","-rf","lib"],cwd=BUILD_PATH) except RecordNotFound: print "Could not find database records for test id " + str(self.process_to_watch.test_id) @@ -393,14 +402,20 @@ def __finesse_start_test(git_commit, kats, nobuild=False): else: EXE = "" - TEST_BUILD_PATH = os.path.join(TEST_RUN_PATH,"build") + TEST_BUILD_PATH = os.path.join(TEST_RUN_PATH, "build") + KAT_EXE = os.path.join(app.instance_path, "kat_store", "kat_" + str(git_commit) + EXE) + KAT_INI = os.path.join(app.instance_path, "kat_store", "kat.ini_" + str(git_commit)) if os.path.exists(KAT_EXE): print "using existing kat file " + KAT_EXE - utils.git(["clone","git://gitmaster.atlas.aei.uni-hannover.de/finesse/base.git",TEST_BUILD_PATH]) + os.mkdir(TEST_BUILD_PATH) + KAT_NEW_EXE = os.path.join(TEST_BUILD_PATH,"kat" + EXE) + KAT_NEW_INI = os.path.join(TEST_BUILD_PATH,"kat.ini") + shutil.copyfile(KAT_EXE, KAT_NEW_EXE) + shutil.copyfile(KAT_INI, KAT_NEW_INI) else: nobuild = False @@ -461,6 +476,7 @@ def finesse_get_test_progress(): finally: schedule_lock.release() + @app.route('/finesse/get_branches', methods=["POST"]) def finesse_get_branches(): SRC_PATH = os.path.join(app.instance_path,"finesse_src") diff --git a/pykat/testing/web_server.py b/pykat/testing/web_server.py index 74c02a43e78b6997fcfa2b7a279c86c3c45f30b5..165897c69bcc6ce3fdd397f5a84e3a379518d47a 100644 --- a/pykat/testing/web_server.py +++ b/pykat/testing/web_server.py @@ -25,7 +25,7 @@ def start(instance_path,port=5000, debug=True, ip="0.0.0.0", git_bin="/usr/bin/g if(app.instance_path!=instance_path): print app.instance_path, instance_path - raise Exception("Instance path of Flask app didn't match the requested value") + raise Exception("Instance path of Flask app (%s) didn't match the requested value (%s)" %(app.instance_path, instance_path)) os.chdir(instance_path) diff --git a/pykat/utilities/maps.py b/pykat/utilities/maps.py index a9e190cadc048a3ca50187814dc2fed6dd14b642..6b52951046a06ef6a6022679c7bad06bf2ac2fad 100644 --- a/pykat/utilities/maps.py +++ b/pykat/utilities/maps.py @@ -182,29 +182,54 @@ class surfacemap(object): return self.ROMWeights, EI - def plot(self, show=True, clabel=None): + def plot(self, show=True, clabel=None, xlim=None, ylim=None): import pylab + if xlim != None: + _x = np.logical_and(self.x<=max(xlim)/100.0, self.x>=min(xlim)/100.0) + xmin = np.min(np.where(_x == True)) + xmax = np.max(np.where(_x == True)) + else: + xmin = 0 + xmax = len(self.x)-1 + xlim = [self.x.min()*100, self.x.max()*100] + + if ylim != None: + _y = np.logical_and(self.y<=max(ylim)/100.0, self.y>=min(ylim)/100.0) + ymin = np.min(np.where(_y == True)) + ymax = np.max(np.where(_y == True)) + else: + ymin = 0 + ymax = len(self.y)-1 + ylim = [self.y.min()*100, self.y.max()*100] + + zmin = self.data[xmin:xmax,ymin:ymax].min() + zmax = self.data[xmin:xmax,ymin:ymax].max() + # 100 factor for scaling to cm xrange = 100*self.x yrange = 100*self.y - + fig = pylab.figure() - axes = pylab.imshow(self.data, extent=[min(xrange),max(xrange),min(yrange),max(yrange)]) + axes = pylab.pcolormesh(xrange, yrange, self.data, vmin=zmin, vmax=zmax) pylab.xlabel('x [cm]') pylab.ylabel('y [cm]') + if xlim != None: pylab.xlim(xlim) + if ylim != None: pylab.ylim(ylim) + pylab.title('Surface map {0}, type {1}'.format(self.name, self.type)) - + cbar = fig.colorbar(axes) + cbar.set_clim(zmin, zmax) if clabel != None: cbar.set_label(clabel) - + if show: pylab.show() - + return fig class aperturemap(surfacemap):