From 7b0dd7a1aef3c1a512aa9443cc7b2f6e4ccf6598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Tue, 25 Apr 2023 12:56:04 +0200 Subject: [PATCH 01/11] Deprecate Wikipedia tile --- geoviews/__init__.py | 1 + geoviews/_warnings.py | 96 ++++++++++++++++++++++++++++++++++ geoviews/operation/__init__.py | 4 +- geoviews/tile_sources.py | 8 ++- tox.ini | 4 ++ 5 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 geoviews/_warnings.py diff --git a/geoviews/__init__.py b/geoviews/__init__.py index 3cb49dce..98f77895 100644 --- a/geoviews/__init__.py +++ b/geoviews/__init__.py @@ -19,6 +19,7 @@ ) from .util import load_tiff, from_xarray # noqa (API import) from .operation import project # noqa (API import) +from ._warnings import GeoviewsDeprecationWarning, GeoviewsUserWarning # noqa: F401 from . import data # noqa (API import) from . import operation # noqa (API import) from . import plotting # noqa (API import) diff --git a/geoviews/_warnings.py b/geoviews/_warnings.py new file mode 100644 index 00000000..732c6e20 --- /dev/null +++ b/geoviews/_warnings.py @@ -0,0 +1,96 @@ +import inspect +import os +import warnings + +import holoviews as hv +import param + +from packaging.version import Version + +__all__ = ( + "deprecated", + "find_stack_level", + "GeoviewsDeprecationWarning", + "GeoviewsUserWarning", + "warn", +) + + +def warn(message, category=None, stacklevel=None): + if stacklevel is None: + stacklevel = find_stack_level() + + warnings.warn(message, category, stacklevel=stacklevel) + + +def find_stack_level(): + """ + Find the first place in the stack that is not inside + Geoviews, Holoviews, or Param. + + Inspired by: pandas.util._exceptions.find_stack_level + """ + import geoviews as gv + + pkg_dir = os.path.dirname(gv.__file__) + test_dir = os.path.join(pkg_dir, "tests") + param_dir = os.path.dirname(param.__file__) + hv_dir = os.path.dirname(hv.__file__) + + frame = inspect.currentframe() + stacklevel = 0 + while frame: + fname = inspect.getfile(frame) + if ( + fname.startswith(pkg_dir) + or fname.startswith(param_dir) + or fname.startswith(hv_dir) + ) and not fname.startswith(test_dir): + frame = frame.f_back + stacklevel += 1 + else: + break + + return stacklevel + + +def deprecated(remove_version, old, new=None, extra=None): + import geoviews as gv + + current_version = Version(Version(gv.__version__).base_version) + + if isinstance(remove_version, str): + remove_version = Version(remove_version) + + if remove_version < current_version: + # This error is mainly for developers to remove the deprecated. + raise ValueError( + f"{old!r} should have been removed in {remove_version}" + f", current version {current_version}." + ) + + message = f"{old!r} is deprecated and will be removed in version {remove_version}." + + if new: + message = f"{message[:-1]}, use {new!r} instead." + + if extra: + message += " " + extra.strip() + + warn(message, GeoviewsDeprecationWarning) + + +class GeoviewsDeprecationWarning(DeprecationWarning): + """A Geoviews-specific ``DeprecationWarning`` subclass. + Used to selectively filter Geoviews deprecations for unconditional display. + """ + + +class GeoviewsUserWarning(UserWarning): + """A Geoviews-specific ``UserWarning`` subclass. + Used to selectively filter Geoviews warnings for unconditional display. + """ + + +warnings.simplefilter("always", GeoviewsDeprecationWarning) +warnings.simplefilter("always", GeoviewsUserWarning) diff --git a/geoviews/operation/__init__.py b/geoviews/operation/__init__.py index cd517277..1a3b6af7 100644 --- a/geoviews/operation/__init__.py +++ b/geoviews/operation/__init__.py @@ -12,8 +12,8 @@ geo_ops = [contours, bivariate_kde] try: from holoviews.operation.datashader import ( - ResamplingOperation, shade, stack, dynspread) - geo_ops += [ResamplingOperation, shade, stack, dynspread] + ResamplingOperation2D, shade, stack, dynspread) + geo_ops += [ResamplingOperation2D, shade, stack, dynspread] except: pass diff --git a/geoviews/tile_sources.py b/geoviews/tile_sources.py index d59dd04a..dbfec5a6 100644 --- a/geoviews/tile_sources.py +++ b/geoviews/tile_sources.py @@ -86,7 +86,13 @@ # Miscellaneous OSM = WMTS('https://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png', name="OSM") OpenTopoMap = WMTS('https://a.tile.opentopomap.org/{Z}/{X}/{Y}.png', name="OpenTopoMap") -Wikipedia = WMTS('https://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png', name="Wikipedia") + +def __getattr__(name): + if name == "Wikipedia": + from ._warnings import deprecated + deprecated("1.11", "Wikipedia", "OSM") + return WMTS('https://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png', name="Wikipedia") + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") tile_sources = {k: v for k, v in locals().items() if isinstance(v, WMTS) and k != 'ESRI'} diff --git a/tox.ini b/tox.ini index 6f8e896f..9b1b2818 100644 --- a/tox.ini +++ b/tox.ini @@ -81,6 +81,10 @@ filterwarnings = ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:cupy ; 2023-01: https://github.com/SciTools/cartopy/issues/2113 ignore:The 'geom_factory' function is deprecated in Shapely 2:DeprecationWarning:cartopy.crs + error::holoviews.HoloviewsDeprecationWarning + error::holoviews.HoloviewsUserWarning + error::geoviews.GeoviewsDeprecationWarning + error::geoviews.GeoviewsUserWarning [flake8] include = *.py From e37c3c7cc4f681b3c58da1c1969f8a7d73ceb6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 10:15:38 +0200 Subject: [PATCH 02/11] ResamplingOperation2D -> ResampleOperation2D --- geoviews/operation/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/geoviews/operation/__init__.py b/geoviews/operation/__init__.py index 735dc27a..2ff2bb32 100644 --- a/geoviews/operation/__init__.py +++ b/geoviews/operation/__init__.py @@ -11,9 +11,9 @@ geo_ops = [contours, bivariate_kde] try: - from holoviews.operation.datashader import ( - ResamplingOperation2D, shade, stack, dynspread) - geo_ops += [ResamplingOperation2D, shade, stack, dynspread] + from holoviews.operation.datashader import shade, stack, dynspread + from holoviews.operation.resample import ResampleOperation2D + geo_ops += [ResampleOperation2D, shade, stack, dynspread] except ImportError: pass From 40f6a917e52cdd97e33cefe72dad78520b9a8e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 10:21:01 +0200 Subject: [PATCH 03/11] Update dependencies --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8d28f007..e6fe8468 100644 --- a/setup.py +++ b/setup.py @@ -96,12 +96,12 @@ def run(self): _required = [ 'bokeh >=3.1.0,<3.2.0', 'cartopy >=0.18.0', - 'holoviews >=1.16.0a5', + 'holoviews >=1.16.0', 'packaging', 'numpy', 'shapely', 'param', - 'panel >=1.0.0rc1', + 'panel >=1.0.0rc7', 'pyproj', ] From 9b04d38e9250f92a79d3d179ff7e55f4c44e53a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 10:29:40 +0200 Subject: [PATCH 04/11] Add bokeh to channels --- .github/workflows/build.yaml | 2 +- .github/workflows/docs.yaml | 2 +- .github/workflows/test.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cce07b85..0b95a595 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,7 +19,7 @@ jobs: run: shell: bash -l {0} env: - CHANS_DEV: "-c pyviz/label/dev -c conda-forge" + CHANS_DEV: "-c pyviz/label/dev -c bokeh -c conda-forge" PKG_TEST_PYTHON: "--test-python=py38" PYTHON_VERSION: "3.8" MPLBACKEND: "Agg" diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 531dcf56..c058b334 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -50,7 +50,7 @@ jobs: run: | conda create -n test-environment conda activate test-environment - conda config --env --append channels pyviz/label/dev --append channels conda-forge + conda config --env --append channels pyviz/label/dev --append channels bokeh --append channels conda-forge conda config --env --remove channels defaults conda config --env --set channel_priority strict conda config --env --show-sources diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6c198b9..57dab0f7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -55,7 +55,7 @@ jobs: name: unit_test_suite python-version: ${{ matrix.python-version }} channel-priority: strict - channels: pyviz/label/dev,conda-forge,nodefaults + channels: pyviz/label/dev,bokeh,conda-forge,nodefaults envs: "-o tests -o examples -o recommended" cache: true conda-update: true From ecd61edb73d0f323718cb47f44e31b451661851b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 10:53:30 +0200 Subject: [PATCH 05/11] Change Wikipedia to OSM in airport_graph.ipynb --- examples/gallery/bokeh/airport_graph.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/bokeh/airport_graph.ipynb b/examples/gallery/bokeh/airport_graph.ipynb index b7f3da83..5a8fbba4 100644 --- a/examples/gallery/bokeh/airport_graph.ipynb +++ b/examples/gallery/bokeh/airport_graph.ipynb @@ -39,7 +39,7 @@ "nodes = gv.Nodes(airport_points, ['Longitude', 'Latitude', 'AirportID'],\n", " ['Name', 'City', 'Connections'])\n", "graph = gv.Graph((routes, nodes), ['SourceID', 'DestinationID'], ['Source', 'Destination'])\n", - "tiles = gv.tile_sources.Wikipedia\n", + "tiles = gv.tile_sources.OSM\n", "\n", "# Select 50 busiest airports\n", "busiest = list(routes.groupby('SourceID').count().sort_values('Stops').iloc[-50:].index.values)\n", From 9fbf2c5ef95685766dbd88419c132ebba9b23c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 11:56:00 +0200 Subject: [PATCH 06/11] Update package build --- .github/workflows/build.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0b95a595..88cf4ff8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,11 +19,12 @@ jobs: run: shell: bash -l {0} env: - CHANS_DEV: "-c pyviz/label/dev -c bokeh -c conda-forge" + CHANS_DEV: "-c pyviz/label/dev -c bokeh -c conda-forge -c nodefaults" PKG_TEST_PYTHON: "--test-python=py38" PYTHON_VERSION: "3.8" MPLBACKEND: "Agg" CONDA_UPLOAD_TOKEN: ${{ secrets.CONDA_UPLOAD_TOKEN }} + SETUPTOOLS_ENABLE_FEATURES: "legacy-editable" steps: - name: remove nodejs run: | @@ -53,8 +54,8 @@ jobs: doit ecosystem_setup - name: conda build run: | - doit package_build --recipe=core $CHANS_DEV $PKG_TEST_PYTHON --test-group=unit - doit package_build --recipe=recommended $CHANS_DEV $PKG_TEST_PYTHON --test-group=unit + doit package_build --recipe=core $CHANS_DEV $PKG_TEST_PYTHON --test-group=simple + doit package_build --recipe=recommended $CHANS_DEV $PKG_TEST_PYTHON --test-group=simple - name: npm setup run: | echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_API_TOKEN }}" > $HOME/.npmrc @@ -104,6 +105,7 @@ jobs: PPU: ${{ secrets.PPU }} PPP: ${{ secrets.PPP }} PYPI: "https://upload.pypi.org/legacy/" + SETUPTOOLS_ENABLE_FEATURES: "legacy-editable" steps: - name: remove nodejs run: | From ea2044b1bc715e5b2128271dd337f7f362f4bfc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 12:24:33 +0200 Subject: [PATCH 07/11] Add numba channel to build conda --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 88cf4ff8..e29c5893 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,7 +19,7 @@ jobs: run: shell: bash -l {0} env: - CHANS_DEV: "-c pyviz/label/dev -c bokeh -c conda-forge -c nodefaults" + CHANS_DEV: "-c pyviz/label/dev -c bokeh -c numba -c conda-forge -c nodefaults" PKG_TEST_PYTHON: "--test-python=py38" PYTHON_VERSION: "3.8" MPLBACKEND: "Agg" From d89b237f65ed20b01ac51ade00d2ffef8395d1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 12:34:09 +0200 Subject: [PATCH 08/11] Add simple to tox.ini --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 56d3d13a..8271e6d6 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ [tox] # python version test group extra envs extra commands -envlist = {py38,py39,py310,py311}-{flakes,unit,examples,all_recommended,examples_extra}-{default}-{dev,pkg} +envlist = {py38,py39,py310,py311}-{flakes,unit,examples,all_recommended,examples_extra,simple}-{default}-{dev,pkg} [_simple] description = Install geoviews without any optional dependencies From 69a641374947c466f95f680c81b70bf2ee269048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 12:34:54 +0200 Subject: [PATCH 09/11] Remove numba again --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e29c5893..88cf4ff8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,7 +19,7 @@ jobs: run: shell: bash -l {0} env: - CHANS_DEV: "-c pyviz/label/dev -c bokeh -c numba -c conda-forge -c nodefaults" + CHANS_DEV: "-c pyviz/label/dev -c bokeh -c conda-forge -c nodefaults" PKG_TEST_PYTHON: "--test-python=py38" PYTHON_VERSION: "3.8" MPLBACKEND: "Agg" From fec9f29f0aa9e9558bcaf3f0be3ff90542f1442a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 12:44:06 +0200 Subject: [PATCH 10/11] Handle missing UDUNITS2_XML_PATH environment variable --- .github/workflows/docs.yaml | 1 + geoviews/element/geo.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index c058b334..f821b06c 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -63,6 +63,7 @@ jobs: run: | conda activate test-environment doit env_capture + echo "UDUNITS2_XML_PATH="$UDUNITS2_XML_PATH - name: sampledata run: | conda activate test-environment diff --git a/geoviews/element/geo.py b/geoviews/element/geo.py index a8cb51c5..07f6277d 100644 --- a/geoviews/element/geo.py +++ b/geoviews/element/geo.py @@ -27,7 +27,10 @@ try: from iris.cube import Cube -except ImportError: +except (ImportError, OSError): + # OSError because environment variable $UDUNITS2_XML_PATH + # is sometimes not set. Should be done automatically + # when installing the package. Cube = None From c9a54e17eca984d145e1cdd1b8e84db48bc8df04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 10 May 2023 14:00:40 +0200 Subject: [PATCH 11/11] Pin nbsite --- .github/workflows/docs.yaml | 1 - setup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index f821b06c..c058b334 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -63,7 +63,6 @@ jobs: run: | conda activate test-environment doit env_capture - echo "UDUNITS2_XML_PATH="$UDUNITS2_XML_PATH - name: sampledata run: | conda activate test-environment diff --git a/setup.py b/setup.py index e6fe8468..afd5ed5b 100644 --- a/setup.py +++ b/setup.py @@ -135,7 +135,7 @@ def run(self): 'recommended': _recommended, 'examples_extra': _examples_extra, 'doc': _examples_extra + [ - 'nbsite >=0.7.2rc10', + 'nbsite ==0.8.0rc15', # Broken for newer versions 'cartopy >=0.20.0', 'graphviz', 'lxml',