From cd3ea65aa6aa25d3dd273fb5da6f8e23c1b72eb0 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Thu, 24 Aug 2017 11:22:58 -0700 Subject: [PATCH 1/3] test to demonstrate issue mesalib --- Share/test_data_files.txt | 1 + tests/test_vcs_mesa_leak.py | 116 ++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 tests/test_vcs_mesa_leak.py diff --git a/Share/test_data_files.txt b/Share/test_data_files.txt index 4b9491455..e3be69ccb 100644 --- a/Share/test_data_files.txt +++ b/Share/test_data_files.txt @@ -4,3 +4,4 @@ aa51aa896ead44019335cebec68e7955 clt.nc 6af2b2e8f8fe468c49d0324d69d83942 ta_ncep_87-6-88-4.nc 4e4648ad9855cb71259926c9d4a1d361 tas_ccsr-95a_1979.01-1979.12.nc f05fd9a1a8026537d733dcea5b140f33 BlueMarble.ppm +814242dd4dbba4126b455160abd13d73 test_mesa_leak.nc diff --git a/tests/test_vcs_mesa_leak.py b/tests/test_vcs_mesa_leak.py new file mode 100644 index 000000000..9097b4c5e --- /dev/null +++ b/tests/test_vcs_mesa_leak.py @@ -0,0 +1,116 @@ +#!/bin/env python +import basevcstest +import EzTemplate +import gc +import time +import resource +import vcs +import cdms2 +import numpy +import vcs +import os + + +def initVCS(x, levs1, levs2, split): + gtype = "isofill" + if gtype == "isofill": + crt = vcs.createisofill + else: + crt = vcs.createboxfill + x.setcolormap("bl_to_darkred") + gm1 = crt() + #iso = x.createboxfill() + if gtype == "boxfill": gm1.boxfill_type="custom" + gm1.levels = levs1 + gm1.ext_1 = True + gm1.ext_2 = True + cols = vcs.getcolors(gm1.levels, split=split) + gm1.fillareacolors = cols + + gm2 = crt() + if gtype == "boxfill": gm2.boxfill_type="custom" + levs = levs2 + gm2.levels = levs + gm2.ext_1 = True + gm2.ext_2 = True + cols = vcs.getcolors(gm2.levels, split=1) + gm2.fillareacolors = cols + + leg = x.createtextorientation() + leg.halign = "left" + leg.height = 8 + + tmpl = x.createtemplate() + tmpl.blank() + tmpl.scalefont(.9) + + tmpl.legend.textorientation = leg + for a in ["data", "legend", "box1", + "xlabel1", "xtic1", "ylabel1", "ytic1"]: + setattr(getattr(tmpl, a), "priority", 1) + + Ez = EzTemplate.Multi(rows=3, columns=1, x=x, template=tmpl) + Ez.legend.direction = 'vertical' + Ez.margins.left = .05 + Ez.margins.right = .05 + Ez.margins.top = .05 + Ez.margins.bottom = .05 + + title = x.createtext() + title.height = 14 + title.halign = "center" + title.x = [.5] + title.y = [.975] + + t1 = Ez.get(legend="local") + t2 = Ez.get(legend="local") + t3 = Ez.get(legend="local") + + del(Ez) + + return gm1, gm2, title, t1, t2, t3, tmpl + + +class VCSTestMesaLeak(basevcstest.VCSBaseTest): + def testMesaLeak(self): + counter = 1 + levs1 = list(numpy.arange(-5, 115, 10)) # SIC + levs2 = list(numpy.arange(-5, 5.5, .5)) + split = 0 + + fout = cdms2.open(os.path.join(vcs.sample_data,"test_mesa_leak.nc")) + NITER = 10 + mems = [] + for i in range(NITER): + startTime = time.time() + printStr = 'processing: %i' % (i) + s1s = fout("sic") + s2 = fout("variable_4") + diff = s2 - s1s + iso1, iso2, title, t1, t2, t3, tmpl = initVCS(self.x, levs1, levs2, split) + title.string = '%i' % (i) + self.x.plot(title) + self.x.plot(s1s, t1, iso1) + self.x.plot(diff, t2, iso2) + self.x.plot(s2, t3, iso1) + self.x.clear() + vcs.removeobject(iso1) + vcs.removeobject(iso2) + vcs.removeobject(title) + vcs.removeobject(t1) + vcs.removeobject(t2) + vcs.removeobject(t3) + vcs.removeobject(tmpl) + endTime = time.time() + timeStr = 'Time: %06.3f secs;' % (endTime - startTime) + mem = float(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) / 1.e6 + mems.append(mem) + memStr = 'Max mem: %05.3f GB' % ( mem ) + counterStr = '%05d' % counter + pyObj = 'PyObj#: %07d;' % (len(gc.get_objects())) + print counterStr, printStr, timeStr, memStr, pyObj + counter = counter + 1 + gc.collect() # Attempt to force a memory flush + a, b = numpy.polyfit(numpy.arange(NITER),numpy.array(mems),1) + print a,b + self.assertTrue(abs(a)<1.e-3) From 68138df35f41b4d1dc5660c7d2393b7b1ba9decc Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Thu, 14 Dec 2017 18:31:46 -0800 Subject: [PATCH 2/3] py3ed --- tests/test_vcs_mesa_leak.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_vcs_mesa_leak.py b/tests/test_vcs_mesa_leak.py index 9097b4c5e..8e45af465 100644 --- a/tests/test_vcs_mesa_leak.py +++ b/tests/test_vcs_mesa_leak.py @@ -108,9 +108,9 @@ def testMesaLeak(self): memStr = 'Max mem: %05.3f GB' % ( mem ) counterStr = '%05d' % counter pyObj = 'PyObj#: %07d;' % (len(gc.get_objects())) - print counterStr, printStr, timeStr, memStr, pyObj + print(counterStr, printStr, timeStr, memStr, pyObj) counter = counter + 1 gc.collect() # Attempt to force a memory flush a, b = numpy.polyfit(numpy.arange(NITER),numpy.array(mems),1) - print a,b + print(a,b) self.assertTrue(abs(a)<1.e-3) From 879272dcfba0cd4fdf130cdb55ae9aef89e0665e Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Wed, 31 Oct 2018 08:06:44 -0700 Subject: [PATCH 3/3] bring in vcsaddons --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 97b3b7bd4..c1eee5243 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,7 +22,7 @@ aliases: name: create_conda_env environment: CHANNELS: "-c cdat/label/nightly -c conda-forge -c cdat" - PKGS: "cdms2 cdat_info udunits2 testsrunner mesalib matplotlib image-compare genutil dv3d cdutil cdtime nbformat 'proj4<5' 'numpy>1.14' " + PKGS: "cdms2 cdat_info udunits2 testsrunner mesalib matplotlib image-compare genutil dv3d cdutil cdtime nbformat 'proj4<5' 'numpy>1.14' vcsaddons" command: | export PATH=$WORKDIR/miniconda/bin:$PATH conda config --set always_yes yes --set changeps1 no