Skip to content

Commit

Permalink
Add explicit testing of all supported Python versions (#403)
Browse files Browse the repository at this point in the history
* Add testing of all supported Pythons

* Run examples on Linux and all supported python versions

* Use pyvista/setup-headless-display

* Make the job Run Examples Lunix-compliant

* Remove constraint of vtk<9.1.0 and Python<3.10

* Add core.settings.bypass_pv_opengl_osmesa_crash to fix issue with vtk>=9.1.0 on Windows GitHub runners using OpenGL from OSMesa

* Doctest skip plot calls for now

* Revert "Doctest skip plot calls for now"

This reverts commit a57bc81.

* Instead of skipping all plot doctests, add fix to doctest conftest

* Skip doctest step for failing configs for now

* Fix conditional

* Fix conditional

* Revert changes to matrix for gatebin tests

* Revert changes to matrix for retro tests

* Switching retro to 3.7, skipping test_shutting_down_when_deleted_legacy on Windows in addition to Linux.

* Switching back to 3.8 testing by default.
More will be tested in the PR about reorganizing tests.

* Revert "Switching back to 3.8 testing by default."

This reverts commit 651624c.

* Skip test_python_plugins.py if on Linux with Python 3.7.

* Skip test_create_on_other_server_and_connect_workflow for 3.10 on Windows

* Skip test_create_on_other_server_and_connect_workflow for 3.10 on Ubuntu and not Windows

* Skip test_python_plugins.py for 3.7

* Skip test_shutting_down_when_deleted_legacy.py for 3.7 on Linux
  • Loading branch information
PProfizi authored Aug 22, 2022
1 parent 084386c commit cbce8f9
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 70 deletions.
81 changes: 29 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8"]
python-version: ["3.7", "3.8", "3.9", "3.10"]
os: ["windows-latest", "ubuntu-18.04"]

steps:
Expand All @@ -53,6 +53,7 @@ jobs:

- name: "Test Docstrings"
uses: pyansys/pydpf-actions/test_docstrings@v2.2
if: matrix.python-version != '3.10' && matrix.python-version != '3.7' && matrix.os != 'Linux'
with:
MODULE: ${{env.MODULE}}
PACKAGE_NAME: ${{env.PACKAGE_NAME}}
Expand Down Expand Up @@ -96,7 +97,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.${{env.MODULE}} --cov-report=xml --cov-report=html --log-level=ERROR --junitxml=junit/test-results.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_launcher"
shell: bash
Expand All @@ -105,7 +106,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results2.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_server"
shell: bash
Expand All @@ -114,7 +115,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results4.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_local_server"
shell: bash
Expand All @@ -123,7 +124,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results5.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_multi_server"
shell: bash
Expand All @@ -132,7 +133,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results6.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_remote_workflow"
shell: bash
Expand All @@ -141,7 +142,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results7.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_remote_operator"
shell: bash
Expand All @@ -150,21 +151,21 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results8.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API 3"
- name: "Test API test_workflow"
shell: bash
working-directory: test_workflow
run: |
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results3.xml --reruns 3 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Upload Test Results"
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}_pytest
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_pytest_${{ env.ANSYS_VERSION }}
path: tests/junit/test-results.xml

- name: "Upload coverage to Codecov"
Expand Down Expand Up @@ -206,39 +207,28 @@ jobs:
install_extras: plotting
wheelhouse: false

- name: Install OpenGL
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction']='Stop'
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
- name: "Setup headless display"
uses: pyvista/setup-headless-display-action@v1

- name: Install test offscreen rendering
run: |
.ci/setup_headless_display.sh
pip install -r .ci/requirements_test_xvfb.txt
python .ci/display_test.py
- name: Setup Graphviz
- name: "Setup Graphviz"
uses: ts-graphviz/setup-graphviz@v1

- name: Install documentation packages for Python
run: |
pip install -r requirements/requirements_docs.txt
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: Build Documentation
- name: "Build Documentation"
shell: cmd
run: |
cd .ci
build_doc.bat > ..\docs\log.txt && type ..\docs\log.txt 2>&1
timeout-minutes: 20

- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: Publish Documentation artifact
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -306,68 +296,55 @@ jobs:
install_extras: plotting
wheelhouse: false

- name: Install OpenGL
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction']='Stop'
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
- name: Install test offscreen rendering
run: |
.ci/setup_headless_display.sh
pip install -r .ci/requirements_test_xvfb.txt
python .ci/display_test.py
- name: "Setup headless display"
uses: pyvista/setup-headless-display-action@v1

- name: "Check examples with gatebin"
shell: cmd
shell: bash
run: |
echo on
cd .ci
dir .
ls .
python run_examples.py
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Uninstall gatebin"
shell: bash
run: |
pip uninstall -y ansys-dpf-gatebin
- name: "Check sanity without gatebin INPROCESS"
shell: cmd
shell: bash
run: |
cd .ci
python run_non_regression_examples.py
env:
DPF_SERVER_TYPE: INPROCESS

- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1


- name: "Check sanity without gatebin GRPC"
shell: cmd
shell: bash
run: |
cd .ci
python run_non_regression_examples.py
env:
DPF_SERVER_TYPE: GRPC

- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Check sanity without gatebin LEGACYGRPC"
shell: cmd
shell: bash
run: |
cd .ci
python run_non_regression_examples.py
env:
DPF_SERVER_TYPE: LEGACYGRPC

- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2


uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1
24 changes: 12 additions & 12 deletions .github/workflows/retro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8"]
python-version: ["3.7"]
os: ["windows-latest", "ubuntu-18.04"]
env:
ANSYS_VERSION: 221
Expand Down Expand Up @@ -84,10 +84,10 @@ jobs:
shell: bash
working-directory: tests
run: |
pytest $DEBUG --cov=ansys.dpf.${{env.MODULE}} --cov-report=xml --cov-report=html --log-level=ERROR --junitxml=junit/test-results.xml --reruns 2 .
pytest $DEBUG --cov=ansys.dpf.${{env.MODULE}} --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=junit/test-results.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_launcher"
shell: bash
Expand All @@ -96,7 +96,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results2.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_server"
shell: bash
Expand All @@ -105,7 +105,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results4.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_local_server"
shell: bash
Expand All @@ -114,7 +114,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results5.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_multi_server"
shell: bash
Expand All @@ -123,7 +123,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results6.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_remote_workflow"
shell: bash
Expand All @@ -132,7 +132,7 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results7.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API test_remote_operator"
shell: bash
Expand All @@ -141,21 +141,21 @@ jobs:
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results8.xml --reruns 2 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Test API 3"
- name: "Test API test_workflow"
shell: bash
working-directory: test_workflow
run: |
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results3.xml --reruns 3 .
- name: "Kill all servers"
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2
uses: pyansys/pydpf-actions/kill-dpf-servers@v2.2.dev1

- name: "Upload Test Results"
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}_pytest
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_pytest_${{ env.ANSYS_VERSION }}
path: tests/junit/test-results.xml

- name: "Upload coverage to Codecov"
Expand Down
26 changes: 26 additions & 0 deletions ansys/dpf/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
========
Customize the behavior of the module.
"""
import os
import re

from ansys.dpf.core.misc import module_exists
from ansys.dpf.core import misc
Expand Down Expand Up @@ -38,6 +40,30 @@ def set_default_pyvista_config():
pv.rcParams["title"] = "DPF"


def bypass_pv_opengl_osmesa_crash():
if module_exists("pyvista"):
import pyvista as pv

def get_lighting():
"""Get lighting configuration.
Disable lighting when using OSMesa on Windows. See:
https://github.com/pyvista/pyvista/issues/3185
"""
pl = pv.Plotter(notebook=False, off_screen=True)
pl.add_mesh(pv.Sphere())
pl.show(auto_close=False)
gpu_info = pl.ren_win.ReportCapabilities()
pl.close()

regex = re.compile("OpenGL version string:(.+)\n")
version = regex.findall(gpu_info)[0]
return not(os.name == 'nt' and 'Mesa' in version)

pv.global_theme.lighting = get_lighting()


def disable_interpreter_properties_evaluation() -> bool:
"""If ``jedi`` module is installed (autocompletion module for most of IDEs), disables the
property evaluation when tab key is pressed.
Expand Down
3 changes: 2 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This runs at the init of the pytest session
"""This runs at the init of the doctest pytest session
Launch or connect to a persistent local DPF service to be shared in
pytest as a session fixture
Expand All @@ -16,3 +16,4 @@

# enable off_screen plotting to avoid test interruption
core.settings.disable_off_screen_rendering()
core.settings.bypass_pv_opengl_osmesa_crash()
1 change: 0 additions & 1 deletion requirements/requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pypandoc==1.8.1
vtk<9.1.0
pyvista==0.36.1
ansys_sphinx_theme==0.5.1
nbsphinx==0.8.9
Expand Down
1 change: 0 additions & 1 deletion requirements/requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pytest==7.1.2
pytest-cov==3.0.0
pytest-rerunfailures==10.2
vtk==9.0.3
pyvista==0.36.1
ansys-platform-instancemanagement==1.0.2
coverage==6.4.3
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
package_data={
"ansys.dpf.core.examples": [
Expand Down Expand Up @@ -81,7 +82,7 @@
author='ANSYS',
author_email='ramdane.lagha@ansys.com',
maintainer_email="pyansys.maintainers@ansys.com",
python_requires=">=3.7.*",
python_requires=">=3.7.*,<4.0",
install_requires=install_requires,
extras_require={
"plotting": ["pyvista>=0.32.0", "matplotlib>=3.2"],
Expand Down
Loading

0 comments on commit cbce8f9

Please sign in to comment.