Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pre-commit and fix test suite #712

Merged
merged 11 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 91 additions & 20 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ on:
- main
pull_request:
branches:
- '*'
- "*"
workflow_dispatch:
inputs:
target:
description: "How much of the test suite to run"
type: choice
default: default
options:
- default
- full
- downstream
cache:
description: "Use cache"
type: boolean
default: true
schedule:
- cron: '0 18 * * SUN'
- cron: "0 18 * * SUN"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -29,67 +42,124 @@ defaults:
jobs:
pre_commit:
name: Run pre-commit
runs-on: 'ubuntu-latest'
runs-on: "ubuntu-latest"
steps:
- uses: holoviz-dev/holoviz_tasks/pre-commit@v0.1a19
setup:
name: Setup workflow
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
code_change: ${{ steps.filter.outputs.code }}
matrix: ${{ env.MATRIX }}
steps:
- uses: actions/checkout@v3
if: github.event_name != 'pull_request'
- name: Check for code changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- 'geoviews/**'
- 'examples/**'
- 'setup.py'
- 'pyproject.toml'
- '.github/workflows/test.yaml'
- name: Set matrix option
run: |
if [[ '${{ github.event_name }}' == 'workflow_dispatch' ]]; then
OPTION=${{ github.event.inputs.target }}
elif [[ '${{ github.event_name }}' == 'schedule' ]]; then
OPTION="full"
elif [[ '${{ github.event_name }}' == 'push' && '${{ github.ref_type }}' == 'tag' ]]; then
OPTION="full"
else
OPTION="default"
fi
echo "MATRIX_OPTION=$OPTION" >> $GITHUB_ENV
- name: Set test matrix with 'default' option
if: env.MATRIX_OPTION == 'default'
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest", "macos-latest", "windows-latest"],
"python-version": ["3.9", "3.11"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
- name: Set test matrix with 'full' option
if: env.MATRIX_OPTION == 'full'
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest", "macos-latest", "windows-latest"],
"python-version": ["3.9", "3.10", "3.11"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
- name: Set test matrix with 'downstream' option
if: env.MATRIX_OPTION == 'downstream'
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest"],
"python-version": ["3.11"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV

unit_test_suite:
name: Unit tests on Python ${{ matrix.python-version }}, ${{ matrix.os }}
needs: [pre_commit]
needs: [pre_commit, setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ["3.9", "3.11"]
include:
- os: 'ubuntu-latest'
python-version: '3.10'
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
timeout-minutes: 60
steps:
- uses: holoviz-dev/holoviz_tasks/install@v0.1a19
if: needs.setup.outputs.code_change == 'true'
with:
name: unit_test_suite
python-version: ${{ matrix.python-version }}
channel-priority: strict
channels: pyviz/label/dev,bokeh,conda-forge,nodefaults
envs: "-o tests -o examples_extra -o recommended -o tests_ci"
cache: true
cache: ${{ github.event.inputs.cache || github.event.inputs.cache == '' }}
conda-update: true
nodejs: true
id: install
- name: download data
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
bash scripts/download_data.sh
- name: git describe
if: needs.setup.outputs.code_change == 'true'
run: |
git describe
- name: doit test_unit
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
doit test_unit
- name: test examples
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
doit test_examples
- name: codecov
if: github.event_name == 'push'
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
codecov

core_test_suite:
name: Core tests on Python ${{ matrix.python-version }}, ${{ matrix.os }}
needs: [pre_commit]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
python-version: ['3.12']
os: ["ubuntu-latest"]
python-version: ["3.12"]
timeout-minutes: 120
env:
DESC: "Python ${{ matrix.python-version }}, ${{ matrix.os }} core tests"
PYTHON_VERSION: ${{ matrix.python-version }}
steps:
# Add back when this works on Python 3.12
# - uses: holoviz-dev/holoviz_tasks/install@v0.1a19
Expand All @@ -99,7 +169,7 @@ jobs:
# # channel-priority: strict
# channels: pyviz/label/dev,conda-forge,nodefaults
# envs: "-o tests_core -o tests_ci"
# cache: true
# cache: ${{ github.event.inputs.cache || github.event.inputs.cache == '' }}
# conda-update: true
# id: install
- uses: actions/checkout@v3
Expand All @@ -109,11 +179,12 @@ jobs:
run: git fetch --prune --tags --unshallow -f
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- run: |
- name: install
run: |
python -m pip install -ve '.[tests_core, tests_ci]'
- name: download data
run: |
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: check-json
- id: detect-private-key
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.3.3
hooks:
- id: ruff
files: geoviews/
Expand All @@ -41,6 +41,6 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
rev: v0.10.0.1
hooks:
- id: shellcheck
14 changes: 8 additions & 6 deletions geoviews/operation/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,14 @@ def _process_element(self, element):
new_data[mdim.name] = mag[mask]

if len(new_data[xdim.name]) == 0:
self.param.warning('While projecting a {} element from a {} coordinate '
'reference system (crs) to a {} projection none of '
'the projected paths were contained within the bounds '
'specified by the projection. Ensure you have specified '
'the correct coordinate system for your data.'.format(type(element).__name__, type(element.crs).__name__,
type(self.p.projection).__name__))
self.param.warning(
f'While projecting a {type(element).__name__} element from '
f'a {type(element.crs).__name__} coordinate reference system (crs) '
f'to a {type(self.p.projection).__name__} projection none of '
'the projected paths were contained within the bounds '
'specified by the projection. Ensure you have specified '
'the correct coordinate system for your data.'
)

return element.clone(tuple(new_data[d.name] for d in element.dimensions()),
crs=self.p.projection, datatype=datatype)
Expand Down
6 changes: 0 additions & 6 deletions geoviews/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
try:
# Standardize backend due to random inconsistencies
import matplotlib.pyplot as plt
plt.switch_backend('agg')
except ImportError:
pass
14 changes: 14 additions & 0 deletions geoviews/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import contextlib


with contextlib.suppress(ImportError):
import matplotlib.pyplot as plt

plt.switch_backend("agg")

with contextlib.suppress(Exception):
# From Dask 2024.3.0 they now use `dask_expr` by default
# https://github.com/dask/dask/issues/10995
import dask

dask.config.set({"dataframe.query-planning": False})
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ filterwarnings = [
"ignore:datetime.datetime.utcfromtimestamp():DeprecationWarning:dateutil.tz.tz", # https://github.com/dateutil/dateutil/pull/1285
# 2024-02
"ignore:The current Dask DataFrame implementation is deprecated:DeprecationWarning", # https://github.com/dask/dask/issues/10917
# 2024-03
"ignore:\\s*Dask dataframe query planning is disabled because dask-expr is not installed:FutureWarning",
"ignore:numpy.ndarray size changed, may indicate binary incompatibility:RuntimeWarning", # https://github.com/pydata/xarray/issues/7259
]
4 changes: 2 additions & 2 deletions scripts/download_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -euxo pipefail

bokeh sampledata
python -m bokeh sampledata

HERE=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
geoviews fetch-data --path="$HERE/../examples"
python -m geoviews fetch-data --path="$HERE/../examples" || echo "geoviews fetch-data failed"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, it is not ideal with the exception || echo, but I don't know why it raised an exception on core tests.


python -c "
try:
Expand Down
Loading