Skip to content

Commit

Permalink
add image test caching (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle authored Jun 12, 2024
1 parent b52ec46 commit ef4dc5a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/geovista/cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
BASE_URL: str = "https://github.com/bjlittle/geovista-data/raw/{version}/assets/"
"""Base URL for :mod:`geovista` resources."""

DATA_VERSION: str = "2024.06.0"
DATA_VERSION: str = "2024.06.1"
"""The ``geovista-data`` repository version for :mod:`geovista` resources."""

GEOVISTA_CACHEDIR: str = "GEOVISTA_CACHEDIR"
Expand Down
78 changes: 39 additions & 39 deletions src/geovista/cache/registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,45 @@ pantry/textures/world.topo.bathy.200412.3x5400x2700.jpg a9f0088972dee0254610af85
rasters/bahamas_rgb.tif.bz2 b4798063e478ad25398a2bf8a464f68f9890c5295ba70ad28b4238f1d8205c66
rasters/fuji_dem.tif.bz2 2e51a278e62304d671e15be8f6cdbea0cb7d477643b97b95c4d4706fa58b4f0a
rasters/japan_map.png.bz2 7b39023b5d26e79475d2dba92269593d5ce46c14ed5859079c79d1fa0ec0987f
tests/images/clouds.png a650d7717324453f86e9f03b55009a79d23ff124fee58791bfe0d558fdfc1f98
tests/images/clouds_robin.png 73a0f6d6267f7f248643bc733e3b2699af47b711286e449171310e9fb2024f90
tests/images/curvilinear__from_2d__orca_moll.png 39e693dccfbefe67f1ed438341342f1c6b5fa11f24b3d46c4706d8514c043d45
tests/images/curvilinear__from_2d__orca.png 492868315f090aad25278660ffd97df31e7158f5c142962e8e23e16773199ade
tests/images/examples.test__clouds.png a650d7717324453f86e9f03b55009a79d23ff124fee58791bfe0d558fdfc1f98
tests/images/examples.test__clouds_robin.png 73a0f6d6267f7f248643bc733e3b2699af47b711286e449171310e9fb2024f90
tests/images/examples.test__curvilinear.from_2d__orca_moll.png 39e693dccfbefe67f1ed438341342f1c6b5fa11f24b3d46c4706d8514c043d45
tests/images/examples.test__curvilinear.from_2d__orca.png 492868315f090aad25278660ffd97df31e7158f5c142962e8e23e16773199ade
tests/images/examples.test__point_cloud.from_points__orca_cloud_eqc.png e41921a712d335061b7507b9fa0880d93a52d7391cb4c586f163d911b54e8362
tests/images/examples.test__point_cloud.from_points__orca_cloud.png 8f723740ca12bfc9c02a29806a777e985d2a3a64a187e39e8a78c1d5ad1a29ff
tests/images/examples.test__rectilinear.from_1d__oisst_eqc.png b4e1d6b0984dbde1b7123b62eb8643206b83a399df90d32d877bf42089863350
tests/images/examples.test__rectilinear.from_1d__oisst.png ae8a7838f65ab5bfc3b0aac29c7cee123bd9563bc55c5420179330a1dff2f2ec
tests/images/examples.test__rectilinear.from_1d__synthetic_face_m1_n1.png 6c8528f8a8b23a303f29e0dc172f7681344081a0f45ac24812880a96c4b3b9a0
tests/images/examples.test__rectilinear.from_1d__synthetic_face_m1_n1_robin.png 872c5d22953737493d09961385431b633ba0a708688f5aa78e0a1e58c98712af
tests/images/examples.test__rectilinear.from_1d__synthetic_node_m1_n1_moll.png 7416dfbc9a93c45dbb2a5f8ffd15baca1edb313597e9a06c2e5926366929afdf
tests/images/examples.test__rectilinear.from_1d__synthetic_node_m1_n1.png 69153b8d5ee074042e98b61825dfd282b5f902ae31e5e1df58f6d74362a4ca58
tests/images/examples.test__rectilinear.from_2d__synthetic_face_m1n1.png 9bda71e20b7ce2b45d8747555459188bcc7829913f6e3f39b7b2cf514be0f942
tests/images/examples.test__rectilinear.from_2d__synthetic_face_m1n1_robin.png b3f9042c1cb23ab9d2d0ba733d49808d53c84d4c7a72922b251c2b45226e530c
tests/images/examples.test__rectilinear.from_2d__synthetic_node_m1n1_moll.png e320bc84c43ba40a42b71fe9779d6740b46a76628edc58787d30940f0a3e1d50
tests/images/examples.test__rectilinear.from_2d__synthetic_node_m1n1.png 928a2bdd664885fa635d287722201ccacaab8f951711f86fbb6ad9fa315e5fa9
tests/images/examples.test__scalar_data.earthquakes.png 7915601a9eee38e18c629a3514a21c8ec90e0fc39a6eea3bc781bd1660315dc1
tests/images/examples.test__scalar_data.earthquakes_wink1.png 8e0136f394c093cd18927932d84f057d6ef8d2edd10d9afc43a534ab25b1961f
tests/images/examples.test__scalar_data.from_tiff__dem.png d2281f70888b9d4dad2612a885f66a8bebbd5ef888273dd7b08d5cd8c94718e5
tests/images/examples.test__scalar_data.from_tiff__rgb.png 0404c758d39106370128a1c5856b15aacd88c2c596a577b4643892ab5a51508c
tests/images/examples.test__spatial_index.uber_h3.png 325fdf3337c37b76a30977ab202876c07bbdacc3d495c253b2000b39b45ef0fd
tests/images/examples.test__unstructured.dynamico.png 480a739c7170f3161173a7f61e52244ff5f7496979a0cbea5210697321879310
tests/images/examples.test__unstructured.dynamico_poly.png 77a5a49d6fcbf67351ee517261195ef05f7cd32e01af82ff7483cb5183992b5e
tests/images/examples.test__unstructured.fesom_fouc.png e567cbfa3477707200cc59ea6f5108171f76257c61f742ba13a418ef25f7dfec
tests/images/examples.test__unstructured.fesom.png 7f67eeeee7fe3b554f97102e7bead54b55ee85a9226e8d5558ade45eabe78bc9
tests/images/examples.test__unstructured.icon_eqc.png c7baf5284f3d07582561df20464529b509b4736b8f1f6bde4377ff568c349017
tests/images/examples.test__unstructured.icon.png a7f83aa784bcfbcbfb498d29dc5665c1fd88dc4a937b5f2aa611d6e57991304d
tests/images/examples.test__unstructured.lam_pacific_moll.png 0695d66528973c7fb377a541a7fae31dd64bbbeb4bd41ae27f041a30209fac9a
tests/images/examples.test__unstructured.lam_pacific.png 7c148352557de1034bc327f350597eb55483685db500f40d895dc7e50171ce4e
tests/images/examples.test__unstructured.lfric_sst_bonne.png d46c3dcc72d9f9f0f11db6bb183aaf100bd07fcbfcdd29f83b25c668d8ab96cd
tests/images/examples.test__unstructured.lfric_sst.png 82f735ea0e30cfc824788b03006ab020f81dcc71c3f7fd582e22344fc8e955cf
tests/images/examples.test__unstructured.smc.png a8857fd85ec80cb1646dc837f06b377b8fed5bd7baf9a3cbac4bcd272bcd61f1
tests/images/examples.test__unstructured.smc_sinu.png 25c73dc33172bfdb76d615c4edaea420b833ce097ee40e573541648282f4cdab
tests/images/examples.test__unstructured.tri_hammer.png 55a063f42722665ae3575d703e5992e5c448a3b496f37292c8dc2497390f14d6
tests/images/examples.test__unstructured.tri.png 17706b23041a027bd52be9950a86703a59b8f1282a82790ee7686832d0bc4196
tests/images/examples.test__vector_data.vectors.png 72f1a30dd57b8c6cc635e866aa1ffd79bdfc10dd75cbf5ea8588f74781f0c490
tests/images/examples.test__warp.from_unstructured__fvcom.png b31dba987a706601c60df6ab9c39cf03e83ed6d07acf84d2d10a798702762f08
tests/images/examples.test__warp.from_unstructured__lfric_orog_eqc.png 1374d2be77a2e6b5208d05be57ce0c215df8fb06b3d96d3ceb07afb8766ffd37
tests/images/examples.test__warp.from_unstructured__lfric_orog.png 327862863d6a7f7d9c5e5f1f8869db4904474157ad7f6cf9ccfb8eafd2e04a73
tests/images/geoplotter.test_view_poi.test_lam_polar__eqc.png 602bba11b641ac202308adf9d0833152af6ccc370123dc8d618424172119a092
tests/images/geoplotter.test_view_poi.test_lam_polar__moll.png 429b2a7fa80aba2b712f49341ccb0daa6f70a0a5141da014618ac5cad17e50c9
tests/images/geoplotter.test_view_poi.test_lam_polar__None.png 5f2ec2b36c900946cdfab0b52615e7c955692573f788691f0de2bfd6753ddf16
Expand All @@ -58,39 +93,4 @@ tests/images/geoplotter.test_view_poi.test_lam_uk_post__eqc.png 5ae9250b5371384f
tests/images/geoplotter.test_view_poi.test_lam_uk_post__moll.png 7bdaf3962b23dcf2a3eb9077f262ccf8c21d1dddccd3ba1e1a6b3e9033cffd2d
tests/images/geoplotter.test_view_poi.test_lam_uk_post__None.png 76e32f2ac7683faf4e047bcf19f017a3e566e5c697267d9122e381613024ae1f
tests/images/geoplotter.test_view_poi.test_lam_uk_post__poly.png 578374c6405396e831e107615bec4b9e83d4fc56b69b973482d5b47249cca369
tests/images/point_cloud__from_points__orca_cloud_eqc.png e41921a712d335061b7507b9fa0880d93a52d7391cb4c586f163d911b54e8362
tests/images/point_cloud__from_points__orca_cloud.png 8f723740ca12bfc9c02a29806a777e985d2a3a64a187e39e8a78c1d5ad1a29ff
tests/images/rectilinear__from_1d__oisst_eqc.png b4e1d6b0984dbde1b7123b62eb8643206b83a399df90d32d877bf42089863350
tests/images/rectilinear__from_1d__oisst.png ae8a7838f65ab5bfc3b0aac29c7cee123bd9563bc55c5420179330a1dff2f2ec
tests/images/rectilinear__from_1d__synthetic_face_m1_n1.png 6c8528f8a8b23a303f29e0dc172f7681344081a0f45ac24812880a96c4b3b9a0
tests/images/rectilinear__from_1d__synthetic_face_m1_n1_robin.png 872c5d22953737493d09961385431b633ba0a708688f5aa78e0a1e58c98712af
tests/images/rectilinear__from_1d__synthetic_node_m1_n1_moll.png 7416dfbc9a93c45dbb2a5f8ffd15baca1edb313597e9a06c2e5926366929afdf
tests/images/rectilinear__from_1d__synthetic_node_m1_n1.png 69153b8d5ee074042e98b61825dfd282b5f902ae31e5e1df58f6d74362a4ca58
tests/images/rectilinear__from_2d__synthetic_face_m1n1.png 9bda71e20b7ce2b45d8747555459188bcc7829913f6e3f39b7b2cf514be0f942
tests/images/rectilinear__from_2d__synthetic_face_m1n1_robin.png b3f9042c1cb23ab9d2d0ba733d49808d53c84d4c7a72922b251c2b45226e530c
tests/images/rectilinear__from_2d__synthetic_node_m1n1_moll.png e320bc84c43ba40a42b71fe9779d6740b46a76628edc58787d30940f0a3e1d50
tests/images/rectilinear__from_2d__synthetic_node_m1n1.png 928a2bdd664885fa635d287722201ccacaab8f951711f86fbb6ad9fa315e5fa9
tests/images/scalar_data__earthquakes.png 7915601a9eee38e18c629a3514a21c8ec90e0fc39a6eea3bc781bd1660315dc1
tests/images/scalar_data__earthquakes_wink1.png 8e0136f394c093cd18927932d84f057d6ef8d2edd10d9afc43a534ab25b1961f
tests/images/scalar_data__from_tiff__dem.png d2281f70888b9d4dad2612a885f66a8bebbd5ef888273dd7b08d5cd8c94718e5
tests/images/scalar_data__from_tiff__rgb.png 0404c758d39106370128a1c5856b15aacd88c2c596a577b4643892ab5a51508c
tests/images/spatial_index__uber_h3.png 325fdf3337c37b76a30977ab202876c07bbdacc3d495c253b2000b39b45ef0fd
tests/images/unstructured__dynamico.png 480a739c7170f3161173a7f61e52244ff5f7496979a0cbea5210697321879310
tests/images/unstructured__dynamico_poly.png 77a5a49d6fcbf67351ee517261195ef05f7cd32e01af82ff7483cb5183992b5e
tests/images/unstructured__fesom_fouc.png e567cbfa3477707200cc59ea6f5108171f76257c61f742ba13a418ef25f7dfec
tests/images/unstructured__fesom.png 7f67eeeee7fe3b554f97102e7bead54b55ee85a9226e8d5558ade45eabe78bc9
tests/images/unstructured__icon_eqc.png c7baf5284f3d07582561df20464529b509b4736b8f1f6bde4377ff568c349017
tests/images/unstructured__icon.png a7f83aa784bcfbcbfb498d29dc5665c1fd88dc4a937b5f2aa611d6e57991304d
tests/images/unstructured__lam_pacific_moll.png 0695d66528973c7fb377a541a7fae31dd64bbbeb4bd41ae27f041a30209fac9a
tests/images/unstructured__lam_pacific.png 7c148352557de1034bc327f350597eb55483685db500f40d895dc7e50171ce4e
tests/images/unstructured__lfric_sst_bonne.png d46c3dcc72d9f9f0f11db6bb183aaf100bd07fcbfcdd29f83b25c668d8ab96cd
tests/images/unstructured__lfric_sst.png 82f735ea0e30cfc824788b03006ab020f81dcc71c3f7fd582e22344fc8e955cf
tests/images/unstructured__smc.png a8857fd85ec80cb1646dc837f06b377b8fed5bd7baf9a3cbac4bcd272bcd61f1
tests/images/unstructured__smc_sinu.png 25c73dc33172bfdb76d615c4edaea420b833ce097ee40e573541648282f4cdab
tests/images/unstructured__tri_hammer.png 55a063f42722665ae3575d703e5992e5c448a3b496f37292c8dc2497390f14d6
tests/images/unstructured__tri.png 17706b23041a027bd52be9950a86703a59b8f1282a82790ee7686832d0bc4196
tests/images/vector_data__vectors.png 72f1a30dd57b8c6cc635e866aa1ffd79bdfc10dd75cbf5ea8588f74781f0c490
tests/images/warp__from_unstructured__fvcom.png b31dba987a706601c60df6ab9c39cf03e83ed6d07acf84d2d10a798702762f08
tests/images/warp__from_unstructured__lfric_orog_eqc.png 1374d2be77a2e6b5208d05be57ce0c215df8fb06b3d96d3ceb07afb8766ffd37
tests/images/warp__from_unstructured__lfric_orog.png 327862863d6a7f7d9c5e5f1f8869db4904474157ad7f6cf9ccfb8eafd2e04a73
tos_Omon_AWI-ESM-1-1-LR_historical_r1i1p1f1_gn_185001-185012.nc 28a8f7b8f3d8edded39a7b9c93afe54aeefbf271086927c7f684207327acc882
19 changes: 17 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@

from __future__ import annotations

from contextlib import suppress

import numpy as np
import pytest
import pyvista as pv

from geovista.bridge import Transform
from geovista.cache import CACHE
from geovista.crs import WGS84
from geovista.geometry import coastlines as geometry_coastlines
from geovista.pantry.data import lam_uk as pantry_lam_uk
Expand All @@ -27,13 +30,25 @@ def plot_nodeid(request):
names = request.node.listnames()
index = names.index("plotting")
names = names[index + 1 :]

# remove ".py" extension
names[-2] = names[-2].split(".")[0]
# reformat parametrization

# reformat pytest parametrization syntax
names[-1] = names[-1].replace("]", "")
names[-1] = names[-1].replace("[", "__")
name = ".".join(names)
return f"test_{name}"

if not name.startswith("test_"):
name = f"test_{name}"

# ensure cache is populated with *existing* baseline image
with suppress(ValueError):
# pyvista-pytest removes the "test_" prefix from baseline image
baseline = f"tests/images/{name.removeprefix('test_')}.png"
_ = CACHE.fetch(baseline)

return name


@pytest.fixture()
Expand Down
7 changes: 3 additions & 4 deletions tests/plotting/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@
@pytest.mark.example()
@pytest.mark.image()
@pytest.mark.parametrize("example", EXAMPLES)
def test(example, verify_image_cache):
def test(plot_nodeid, example, verify_image_cache):
"""Image test the example scripts."""
verify_image_cache.test_name = plot_nodeid

# apply individual test case image tolerance exceptions only when
# executing within a remote GHA runner environment
if CI and example in thresholds:
for attr, value in thresholds[example].items():
setattr(verify_image_cache, attr, value)

# replace dot notation with double underscores
safe = example.replace(".", "__")
verify_image_cache.test_name = f"test_{safe}"
# import the example module
module = importlib.import_module(f"geovista.examples.{example}")
# execute the example module for image testing
Expand Down

0 comments on commit ef4dc5a

Please sign in to comment.