From 848bea508c9a7c94c62382a23bdbd58c7ae7a65f Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 25 Jan 2021 09:47:03 -0500 Subject: [PATCH] Reduce warnings. This reduces warnings on - celery backend - pytest strict mode - pyproj transform This also hardens test order to some degree. Ideally, we could run tests in a random order, but when that is done, sometimes java doesn't stop and restart as cleanly as it should. Also, stop writing GDAL PAM (aux.xml) files when running tox. --- girder/test_girder/conftest.py | 7 +++++-- setup.cfg | 2 +- .../gdal/large_image_source_gdal/__init__.py | 20 +++++++++---------- test/test_source_bioformats.py | 3 --- test/test_source_pil.py | 5 +++++ tox.ini | 1 + 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/girder/test_girder/conftest.py b/girder/test_girder/conftest.py index 1038719b2..813b46ebf 100644 --- a/girder/test_girder/conftest.py +++ b/girder/test_girder/conftest.py @@ -29,10 +29,12 @@ def unavailableWorker(db): @pytest.fixture(scope='session') def girderWorkerProcess(): broker = 'amqp://guest@127.0.0.1' + backend = 'rpc://guest@127.0.0.1' env = os.environ.copy() env['C_FORCE_ROOT'] = 'true' proc = subprocess.Popen([ - 'celery', '-A', 'girder_worker.app', 'worker', '--broker', broker, '--concurrency=1'], + 'celery', '-A', 'girder_worker.app', 'worker', '--broker', broker, + '--result-backend', backend, '--concurrency=1'], close_fds=True, env=env) yield True proc.terminate() @@ -46,8 +48,9 @@ def girderWorker(db, girderWorkerProcess): service must be running. """ broker = 'amqp://guest@127.0.0.1' + backend = 'rpc://guest@127.0.0.1' Setting().set(WorkerSettings.BROKER, broker) - Setting().set(WorkerSettings.BACKEND, broker) + Setting().set(WorkerSettings.BACKEND, backend) yield True Setting().unset(WorkerSettings.BROKER) Setting().unset(WorkerSettings.BACKEND) diff --git a/setup.cfg b/setup.cfg index 30504fd52..a1e80bf66 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ exclude = ignore = D100,D101,D102,D103,D104,D105,D106,D107,D200,D205,D400,D401,E741,W504 [tool:pytest] -addopts = --verbose --strict --showlocals --cov-report="term" --cov-report="xml" --cov +addopts = --verbose --strict-markers --showlocals --cov-report="term" --cov-report="xml" --cov cache_dir = build/pytest_cache testpaths = test girder/test_girder girder_annotation/test_annotation diff --git a/sources/gdal/large_image_source_gdal/__init__.py b/sources/gdal/large_image_source_gdal/__init__.py index b76074a6a..61474ee53 100644 --- a/sources/gdal/large_image_source_gdal/__init__.py +++ b/sources/gdal/large_image_source_gdal/__init__.py @@ -302,7 +302,8 @@ def _initWithProjection(self, unitsPerPixel=None): # between -180,0 and +180,0 is used. Some projections (such as # stereographic) will fail in this case; they must have a # unitsPerPixel specified. - equator = pyproj.transform(inProj, outProj, [-180, 180], [0, 0], always_xy=True) + equator = pyproj.Transformer.from_proj(inProj, outProj, always_xy=True).transform( + [-180, 180], [0, 0]) self.unitsAcrossLevel0 = abs(equator[0][1] - equator[0][0]) if not self.unitsAcrossLevel0: raise TileSourceException( @@ -443,8 +444,8 @@ def getBounds(self, srs=None): inProj = self._proj4Proj(nativeSrs) outProj = self._proj4Proj(srs) keys = ('ll', 'ul', 'lr', 'ur') - pts = pyproj.itransform(inProj, outProj, [ - (bounds[key]['x'], bounds[key]['y']) for key in keys], always_xy=True) + pts = pyproj.Transformer.from_proj(inProj, outProj, always_xy=True).itransform([ + (bounds[key]['x'], bounds[key]['y']) for key in keys]) for idx, pt in enumerate(pts): key = keys[idx] bounds[key]['x'] = pt[0] @@ -766,14 +767,13 @@ def _convertProjectionUnits(self, left, top, right, bottom, width, height, else: inProj = self._proj4Proj(units) outProj = self._proj4Proj(self.projection) - pleft, ptop = pyproj.transform( - inProj, outProj, + transformer = pyproj.Transformer.from_proj(inProj, outProj, always_xy=True) + pleft, ptop = transformer.transform( right if left is None else left, - bottom if top is None else top, always_xy=True) - pright, pbottom = pyproj.transform( - inProj, outProj, + bottom if top is None else top) + pright, pbottom = transformer.transform( left if right is None else right, - top if bottom is None else bottom, always_xy=True) + top if bottom is None else bottom) units = 'projection' left = pleft if left is not None else None top = ptop if top is not None else None @@ -893,7 +893,7 @@ def toNativePixelCoordinates(self, x, y, proj=None, roundResults=True): # convert to the native projection inProj = self._proj4Proj(proj) outProj = self._proj4Proj(self.getProj4String()) - px, py = pyproj.transform(inProj, outProj, x, y, always_xy=True) + px, py = pyproj.Transformer.from_proj(inProj, outProj, always_xy=True).transform(x, y) # convert to native pixel coordinates with self._getDatasetLock: gt = self.dataset.GetGeoTransform() diff --git a/test/test_source_bioformats.py b/test/test_source_bioformats.py index bd1c09af3..3bda65631 100644 --- a/test/test_source_bioformats.py +++ b/test/test_source_bioformats.py @@ -1,14 +1,12 @@ # -*- coding: utf-8 -*- import pytest -import sys from large_image.cache_util import cachesClear from . import utilities -@pytest.mark.skipif(sys.version_info < (3, 5), reason='only python >=3.5') def testTilesFromBioformats(): import large_image_source_bioformats @@ -28,7 +26,6 @@ def testTilesFromBioformats(): cachesClear() -@pytest.mark.skipif(sys.version_info < (3, 5), reason='only python >=3.5') def testInternalMetadata(): import large_image_source_bioformats diff --git a/test/test_source_pil.py b/test/test_source_pil.py index ba5718b20..04356e23f 100644 --- a/test/test_source_pil.py +++ b/test/test_source_pil.py @@ -6,10 +6,15 @@ from large_image import config import large_image_source_pil +from large_image.cache_util import cachesClear + from . import utilities def testTilesFromPIL(): + # Ensure this test can run in any order + cachesClear() + imagePath = utilities.externaldata('data/sample_Easy1.png.sha512') # Test with different max size options. config.setConfig('max_small_image_size', 100) diff --git a/tox.ini b/tox.ini index 8ec6299a3..72b95aa26 100644 --- a/tox.ini +++ b/tox.ini @@ -40,6 +40,7 @@ setenv = NPM_CONFIG_LOGLEVEL=warn NPM_CONFIG_PROGRESS=false NPM_CONFIG_PREFER_OFFLINE=true + GDAL_PAM_ENABLED=no [testenv:flake8] skipsdist = true