From f1d135cd56233edeff0c78822c9f46a4ab444580 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Mon, 2 Aug 2021 14:38:43 -0600 Subject: [PATCH 01/16] move macos ci/cd to github actions --- .ci/macos-install-python.sh | 46 -------------------------- .github/workflows/mac-build.yml | 57 +++++++++++++++++++++++++++++++++ azure-pipelines.yml | 22 ------------- 3 files changed, 57 insertions(+), 68 deletions(-) delete mode 100755 .ci/macos-install-python.sh create mode 100644 .github/workflows/mac-build.yml diff --git a/.ci/macos-install-python.sh b/.ci/macos-install-python.sh deleted file mode 100755 index 8e3eec08..00000000 --- a/.ci/macos-install-python.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -PYTHON_VERSION="$1" - -case $PYTHON_VERSION in -2.7) - FULL_VERSION=2.7.18 - ;; -3.6) - FULL_VERSION=3.6.8 - ;; -3.7) - FULL_VERSION=3.7.9 - ;; -3.8) - FULL_VERSION=3.8.9 - ;; -3.9) - FULL_VERSION=3.9.5 - ;; -esac - -INSTALLER_NAME=python-$FULL_VERSION-macosx10.9.pkg -URL=https://www.python.org/ftp/python/$FULL_VERSION/$INSTALLER_NAME - -PY_PREFIX=/Library/Frameworks/Python.framework/Versions - -set -e -x - -curl $URL > $INSTALLER_NAME - -sudo installer -pkg $INSTALLER_NAME -target / - -sudo rm /usr/local/bin/python -sudo ln -s /usr/local/bin/python$PYTHON_VERSION /usr/local/bin/python - -which python -python --version -python -m ensurepip -python -m pip install --upgrade pip -python -m pip install setuptools --upgrade -python -m pip install twine wheel - -# brew doesn't install correctly -# install openmp -# brew install libomp diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml new file mode 100644 index 00000000..c4ebe9c8 --- /dev/null +++ b/.github/workflows/mac-build.yml @@ -0,0 +1,57 @@ +name: Mac Unit Testing and Deployment + +on: + push: + branches: "*" + tags: "*" + pull_request: + branches: "**" + +jobs: + macOS: + runs-on: macos-latest + name: Mac OS Unit Testing + strategy: + matrix: + python-version: ['3.6', '3.7', '3.8', '3.9'] + + env: + SHELLOPTS: 'errexit:pipefail' + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Build package + run: | + pip install -r requirements_build.txt + python setup.py bdist_wheel + + - name: Install package + run: | + pip install dist/* + python -c "from ansys.mapdl import reader; print(reader.Report(gpu=False))" + + - name: Install test dependencies + run: | + pip install -r requirements_test.txt + + - name: Unit testing + run: | + pytest -v + + - name: Validate package + run: | + pip install twine + twine check dist/* + + - name: Upload to PyPi + if: startsWith(github.event.ref, 'refs/tags') + run: | + twine upload -u __token__ --skip-existing dist/* + env: + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 11d696af..ce1fc0b2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -75,25 +75,3 @@ jobs: - template: .ci/install_package.yml - template: .ci/unit_testing.yml - template: .ci/azure-publish-dist.yml - - -- job: macOS - strategy: - matrix: - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - Python38: - python.version: '3.8' - Python39: - python.version: '3.9' - pool: - vmImage: 'macOS-10.15' - steps: - - script: .ci/macos-install-python.sh '$(python.version)' - displayName: Install Python - - template: .ci/build_wheel.yml - - template: .ci/install_package.yml - - template: .ci/unit_testing_allow_error.yml - - template: .ci/azure-publish-dist.yml \ No newline at end of file From 9e80530fe2df84b2413a77c86df665f5657070de Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Mon, 2 Aug 2021 15:10:01 -0600 Subject: [PATCH 02/16] fix package test --- .github/workflows/mac-build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index c4ebe9c8..aeb5477c 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -34,14 +34,13 @@ jobs: - name: Install package run: | pip install dist/* + cd tests/ python -c "from ansys.mapdl import reader; print(reader.Report(gpu=False))" - - name: Install test dependencies - run: | - pip install -r requirements_test.txt - - name: Unit testing run: | + pip install -r requirements_test.txt + cd tests/ pytest -v - name: Validate package From 87d7edc052ffe4a4363d98754d4c88388dbdd498 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Mon, 2 Aug 2021 16:59:46 -0600 Subject: [PATCH 03/16] use macos 11 --- .github/workflows/mac-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index aeb5477c..04a0b69b 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -9,7 +9,7 @@ on: jobs: macOS: - runs-on: macos-latest + runs-on: macos-11 name: Mac OS Unit Testing strategy: matrix: From 839ce072a2eb3d5c9940896b1d167f24758e1d40 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Mon, 2 Aug 2021 17:00:21 -0600 Subject: [PATCH 04/16] update cython version --- requirements_build.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_build.txt b/requirements_build.txt index e9c13865..c79e6c8f 100644 --- a/requirements_build.txt +++ b/requirements_build.txt @@ -1,5 +1,5 @@ setuptools>=41.0.0 wheel>=0.33.0 numpy<1.20.0 -cython==0.29.21 +cython==0.29.24 matplotlib From 37c9301741e1e8c1416caedfd45122483749b902 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Mon, 2 Aug 2021 17:01:31 -0600 Subject: [PATCH 05/16] downgrade runs-on --- .github/workflows/mac-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 04a0b69b..aeb5477c 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -9,7 +9,7 @@ on: jobs: macOS: - runs-on: macos-11 + runs-on: macos-latest name: Mac OS Unit Testing strategy: matrix: From 59a0be37ff4a8dfe77dbf17a7ab24ba42834b7b0 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Mon, 2 Aug 2021 17:10:24 -0600 Subject: [PATCH 06/16] use cibuildwheel --- .github/workflows/mac-build.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index aeb5477c..0a5f46e1 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -26,10 +26,19 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Build package - run: | - pip install -r requirements_build.txt - python setup.py bdist_wheel + - name Build wheels + uses: joerick/cibuildwheel@v2.0.1 + env + CIBW_BEFORE_BUILD: pip install -r requirements_build.txt + + - name: Show files + run: ls -lh wheelhouse + shell: bash + + - name: Upload wheels + uses: actions/upload-artifact@v2 + with: + path: wheelhouse/*.whl - name: Install package run: | From a7ac468810d75799dea47fedb62344038128868d Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Mon, 2 Aug 2021 17:12:19 -0600 Subject: [PATCH 07/16] fix syntax --- .github/workflows/mac-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 0a5f46e1..e9179384 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -26,7 +26,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name Build wheels + - name: Build wheels uses: joerick/cibuildwheel@v2.0.1 env CIBW_BEFORE_BUILD: pip install -r requirements_build.txt From 0ca8a2436b7e6839859e8343517e7cafeb7aea08 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Mon, 2 Aug 2021 17:13:03 -0600 Subject: [PATCH 08/16] fix syntax again --- .github/workflows/mac-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index e9179384..0bd9f0d6 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -28,7 +28,7 @@ jobs: - name: Build wheels uses: joerick/cibuildwheel@v2.0.1 - env + env: CIBW_BEFORE_BUILD: pip install -r requirements_build.txt - name: Show files From 9bcd1df8ceda94e20469b3b0cc791aed52e6167b Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Wed, 4 Aug 2021 21:19:04 -0600 Subject: [PATCH 09/16] fix mac build --- setup.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/setup.py b/setup.py index e271ea2d..46c8a125 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,6 @@ """Installation file for ansys-mapdl-reader""" +import re +import subprocess import struct import os import sys @@ -13,6 +15,14 @@ raise Exception('Please install numpy first with "pip install numpy"') +# Facilities to install properly on Mac using clang +def is_clang(bin): + proc = subprocess.Popen([bin, '-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = proc.communicate() + output = str(b'\n'.join([stdout, stderr]).decode('ascii', 'ignore')) + return not re.search(r'clang', output) is None + + def check_cython(): """Check if binaries exist and if not check if Cython is installed""" has_binary_reader = False @@ -41,6 +51,28 @@ def finalize_options(self): import numpy self.include_dirs.append(numpy.get_include()) + def build_extensions(self): + binary = self.compiler.compiler[0] + if is_clang(binary): + for e in self.extensions: + e.extra_compile_args.append('-stdlib=libc++') + + if platform.system() == 'Darwin': + mac_version, _, _ = platform.mac_ver() + major, minor, patch = [int(n) for n in mac_version.split('.')] + + # libstdc++ is deprecated in recent versions of XCode + if minor >= 9: + e.extra_compile_args.append('-mmacosx-version-min=10.9') + e.extra_compile_args.append('-stdlib=libc++') + e.extra_link_args.append('-mmacosx-version-min=10.9') + e.extra_link_args.append('-stdlib=libc++') + else: + e.extra_compile_args.append('-mmacosx-version-min=10.7') + e.extra_link_args.append('-mmacosx-version-min=10.7') + + _build_ext.build_extensions(self) + def compilerName(): """ Check compiler and assign compile arguments accordingly """ From 757e135a3ffa68e89355fd3cb1a04838d520dcba Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Wed, 4 Aug 2021 21:37:15 -0600 Subject: [PATCH 10/16] install platform --- .github/workflows/mac-build.yml | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 0bd9f0d6..b55d786d 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -13,7 +13,7 @@ jobs: name: Mac OS Unit Testing strategy: matrix: - python-version: ['3.6', '3.7', '3.8', '3.9'] + python-version: ['3.8'] env: SHELLOPTS: 'errexit:pipefail' diff --git a/setup.py b/setup.py index 46c8a125..9af5f811 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """Installation file for ansys-mapdl-reader""" +import platform import re import subprocess import struct From c26af31e23144c4d59bb2d4443f17f4a75fcf520 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Wed, 4 Aug 2021 22:06:43 -0600 Subject: [PATCH 11/16] only build one wheel on macos --- .github/workflows/mac-build.yml | 31 ++++++++++++--------------- setup.py | 37 +++++++++++++++++---------------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index b55d786d..471e7000 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -30,6 +30,18 @@ jobs: uses: joerick/cibuildwheel@v2.0.1 env: CIBW_BEFORE_BUILD: pip install -r requirements_build.txt + CIBW_BUILD: cp38-macosx_x86_64 + CIBW_BEFORE_TEST: pip install -r requirements_test.txt + CIBW_TEST_COMMAND: pytest -v + + - name: Build wheels + if: startsWith(github.event.ref, 'refs/tags') + uses: joerick/cibuildwheel@v2.0.1 + env: + CIBW_BEFORE_BUILD: pip install -r requirements_build.txt + CIBW_SKIP: pp* cp38-macosx_x86_64 + CIBW_BEFORE_TEST: pip install -r requirements_test.txt + CIBW_TEST_COMMAND: pytest -v - name: Show files run: ls -lh wheelhouse @@ -40,26 +52,9 @@ jobs: with: path: wheelhouse/*.whl - - name: Install package - run: | - pip install dist/* - cd tests/ - python -c "from ansys.mapdl import reader; print(reader.Report(gpu=False))" - - - name: Unit testing - run: | - pip install -r requirements_test.txt - cd tests/ - pytest -v - - - name: Validate package - run: | - pip install twine - twine check dist/* - - name: Upload to PyPi if: startsWith(github.event.ref, 'refs/tags') run: | - twine upload -u __token__ --skip-existing dist/* + twine upload -u __token__ --skip-existing wheelhouse/* env: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} diff --git a/setup.py b/setup.py index 9af5f811..a7ce392c 100644 --- a/setup.py +++ b/setup.py @@ -53,24 +53,25 @@ def finalize_options(self): self.include_dirs.append(numpy.get_include()) def build_extensions(self): - binary = self.compiler.compiler[0] - if is_clang(binary): - for e in self.extensions: - e.extra_compile_args.append('-stdlib=libc++') - - if platform.system() == 'Darwin': - mac_version, _, _ = platform.mac_ver() - major, minor, patch = [int(n) for n in mac_version.split('.')] - - # libstdc++ is deprecated in recent versions of XCode - if minor >= 9: - e.extra_compile_args.append('-mmacosx-version-min=10.9') - e.extra_compile_args.append('-stdlib=libc++') - e.extra_link_args.append('-mmacosx-version-min=10.9') - e.extra_link_args.append('-stdlib=libc++') - else: - e.extra_compile_args.append('-mmacosx-version-min=10.7') - e.extra_link_args.append('-mmacosx-version-min=10.7') + if os.name != 'nt': + binary = self.compiler.compiler[0] + if is_clang(binary): + for e in self.extensions: + e.extra_compile_args.append('-stdlib=libc++') + + if platform.system() == 'Darwin': + mac_version, _, _ = platform.mac_ver() + major, minor, patch = [int(n) for n in mac_version.split('.')] + + # libstdc++ is deprecated in recent versions of XCode + if minor >= 9: + e.extra_compile_args.append('-mmacosx-version-min=10.9') + e.extra_compile_args.append('-stdlib=libc++') + e.extra_link_args.append('-mmacosx-version-min=10.9') + e.extra_link_args.append('-stdlib=libc++') + else: + e.extra_compile_args.append('-mmacosx-version-min=10.7') + e.extra_link_args.append('-mmacosx-version-min=10.7') _build_ext.build_extensions(self) From 3c33f9d3caa9ff3dc846133ca1ecfb8d3be03a08 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 5 Aug 2021 10:14:37 -0600 Subject: [PATCH 12/16] fix mac wheel build --- .github/workflows/mac-build.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 471e7000..62d8a967 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -40,8 +40,6 @@ jobs: env: CIBW_BEFORE_BUILD: pip install -r requirements_build.txt CIBW_SKIP: pp* cp38-macosx_x86_64 - CIBW_BEFORE_TEST: pip install -r requirements_test.txt - CIBW_TEST_COMMAND: pytest -v - name: Show files run: ls -lh wheelhouse @@ -52,6 +50,16 @@ jobs: with: path: wheelhouse/*.whl + - name: Install + run: | + pip install wheelhouse/*38* + + - name: Test + run: | + pip install -r requirements_test.txt + cd tests + pytest -v + - name: Upload to PyPi if: startsWith(github.event.ref, 'refs/tags') run: | From 8e2fcd4b4d171ebb0b6b36ed08e39542aaf94e7d Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 5 Aug 2021 10:28:32 -0600 Subject: [PATCH 13/16] fix 3.8 testing --- .github/workflows/mac-build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 62d8a967..3a65f388 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -31,8 +31,6 @@ jobs: env: CIBW_BEFORE_BUILD: pip install -r requirements_build.txt CIBW_BUILD: cp38-macosx_x86_64 - CIBW_BEFORE_TEST: pip install -r requirements_test.txt - CIBW_TEST_COMMAND: pytest -v - name: Build wheels if: startsWith(github.event.ref, 'refs/tags') @@ -50,7 +48,7 @@ jobs: with: path: wheelhouse/*.whl - - name: Install + - name: Install wheel run: | pip install wheelhouse/*38* From 362b4fafe5b031e4fe32c529d5c4c7aaadabaebf Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 5 Aug 2021 11:01:41 -0600 Subject: [PATCH 14/16] skip animation on mac --- tests/test_binary_reader.py | 6 +++++- tests/test_cyclic.py | 15 +++++++++++---- tests/test_dist_rst.py | 28 +++++++++++++++++++++------- tests/test_rst.py | 6 +++++- tests/text_examples.py | 3 +++ 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/tests/test_binary_reader.py b/tests/test_binary_reader.py index b9b9739a..b0b3bc04 100644 --- a/tests/test_binary_reader.py +++ b/tests/test_binary_reader.py @@ -1,3 +1,4 @@ +import platform import shutil import os @@ -36,6 +37,7 @@ skip_no_ansys = pytest.mark.skipif(not _HAS_ANSYS, reason="Requires ANSYS installed") skip_no_xserver = pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") RSETS = list(zip(range(1, 9), [1]*8)) @@ -413,6 +415,7 @@ def test_file_close(tmpdir): @skip_no_xserver @pytest.mark.skipif(not HAS_FFMPEG, reason="requires imageio_ffmpeg") +@skip_mac def test_animate_nodal_solution(tmpdir, result): temp_movie = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) result.animate_nodal_solution(0, nangles=20, movie_filename=temp_movie, @@ -455,7 +458,8 @@ def test_thermal_result(thermal_rst): def test_plot_temperature(thermal_rst): cpos = thermal_rst.plot_nodal_temperature(0, return_cpos=True) - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) def test_file_not_found(): diff --git a/tests/test_cyclic.py b/tests/test_cyclic.py index ee490b90..de8c1160 100644 --- a/tests/test_cyclic.py +++ b/tests/test_cyclic.py @@ -1,3 +1,4 @@ +import platform import os import numpy as np @@ -32,6 +33,7 @@ skip_with_no_xserver = pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") # static result x axis @@ -110,27 +112,31 @@ def test_non_cyclic(): def test_plot_sectors(tmpdir): filename = str(tmpdir.mkdir("tmpdir").join('tmp.png')) cpos = result_z.plot_sectors(screenshot=filename) - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) assert os.path.isfile(filename) @skip_with_no_xserver def test_plot_sectors_x(result_x): cpos = result_x.plot_sectors() - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) @skip_with_no_xserver @pytest.mark.skipif(result_z is None, reason="Requires result file") def test_plot_z_cyc(): cpos = result_z.plot() - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) @skip_with_no_xserver def test_plot_x_cyc(result_x): cpos = result_x.plot() - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) @skip_with_no_xserver @@ -342,6 +348,7 @@ def test_full_x_principal_nodal_stress(result_x): @skip_with_no_xserver @pytest.mark.skipif(not HAS_FFMPEG, reason="requires imageio_ffmpeg") @pytest.mark.skipif(result_z is None, reason="Requires result file") +@skip_mac def test_animate_nodal_solution(tmpdir): temp_movie = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) result_z.animate_nodal_solution(0, nangles=20, movie_filename=temp_movie, diff --git a/tests/test_dist_rst.py b/tests/test_dist_rst.py index 5070a067..4482c9bb 100644 --- a/tests/test_dist_rst.py +++ b/tests/test_dist_rst.py @@ -1,3 +1,4 @@ +import platform import shutil import os @@ -5,6 +6,7 @@ import numpy as np import pytest from pyvista.plotting.renderer import CameraPosition +from pyvista.plotting import system_supports_plotting from ansys.mapdl import reader as pymapdl_reader from ansys.mapdl.reader.dis_result import DistributedResult @@ -28,6 +30,9 @@ skip_no_ansys = pytest.mark.skipif(not _HAS_ANSYS, reason="Requires ANSYS installed") +skip_no_xserver = pytest.mark.skipif(not system_supports_plotting(), + reason="Requires active X Server") +skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") @pytest.fixture() @@ -120,7 +125,8 @@ def test_plot_temperature(thermal_solution, mapdl): return dist_rst = pymapdl_reader.read_binary(os.path.join(mapdl.directory, 'file0.rth')) - cpos = dist_rst.plot_nodal_temperature(0) + if cpos is not None: + cpos = dist_rst.plot_nodal_temperature(0) assert isinstance(cpos, CameraPosition) @@ -136,7 +142,8 @@ def test_blade_result(beam_blade): def test_plot_blade_result(beam_blade): cpos = beam_blade.plot_nodal_displacement(0) - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) def test_nodal_stress(static_dis, static_rst): @@ -148,7 +155,8 @@ def test_nodal_stress(static_dis, static_rst): def test_plot_nodal_stress(static_dis, static_rst): cpos = static_dis.plot_nodal_stress(0, 'x') - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) def test_nodal_reaction(static_dis, static_rst): @@ -167,7 +175,8 @@ def test_nodal_principal_stress(static_dis, static_rst): def test_plot_nodal_principal_stress(static_dis): cpos = static_dis.plot_principal_nodal_stress(0, 'SEQV') - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) rtypes = ['EMS', 'ENF', 'ENS', 'ENG', 'EEL', 'ETH', 'EUL', 'EMN'] @@ -235,7 +244,8 @@ def test_cylindrical_nodal_stress(static_dis): def test_plot_cylindrical_nodal_stress(static_dis): cpos = static_dis.plot_cylindrical_nodal_stress(0, 'Z') - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) def test_nodal_thermal_strain(static_dis): @@ -247,7 +257,8 @@ def test_nodal_thermal_strain(static_dis): def test_plot_nodal_thermal_strain(static_dis): cpos = static_dis.plot_nodal_thermal_strain(0, 'Z') - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) def test_nodal_elastic_strain(static_dis): @@ -259,7 +270,8 @@ def test_nodal_elastic_strain(static_dis): def test_plot_nodal_elastic_strain(static_dis): cpos = static_dis.plot_nodal_elastic_strain(0, 'Z') - assert isinstance(cpos, CameraPosition) + if cpos is not None: + assert isinstance(cpos, CameraPosition) def test_result_does_not_exist(static_dis): @@ -267,6 +279,8 @@ def test_result_does_not_exist(static_dis): static_dis.nodal_plastic_strain(0) +@skip_no_xserver +@skip_mac def test_animate_nodal_solution(static_dis): static_dis.animate_nodal_solution(0, loop=False) diff --git a/tests/test_rst.py b/tests/test_rst.py index b3ea986d..9388ccb6 100644 --- a/tests/test_rst.py +++ b/tests/test_rst.py @@ -32,6 +32,7 @@ mapdl.modal_analysis(nmode=1) """ +import platform import os from shutil import copy @@ -64,6 +65,7 @@ except: pontoon = None +skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") test_path = os.path.dirname(os.path.abspath(__file__)) testfiles_path = os.path.join(test_path, 'testfiles') @@ -199,6 +201,7 @@ def test_plot_nodal_thermal_strain(): vm33.plot_nodal_thermal_strain(0, 'X', off_screen=True) + @pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") @pytest.mark.skipif(vm33 is None, reason="Requires example files") def test_plot_nodal_thermal_strain(): @@ -345,7 +348,8 @@ def test_plot_cyl_stress(hex_pipe_corner): cpos = hex_pipe_corner.plot_cylindrical_nodal_stress(0, comp='X', off_screen=True) cpos = hex_pipe_corner.plot_cylindrical_nodal_stress(0, comp='R', off_screen=True) - assert cpos + if cpos is not None: + assert isinstance(cpos, CameraPosition) def test_reaction_forces(volume_rst): diff --git a/tests/text_examples.py b/tests/text_examples.py index 68ecf0da..36f44671 100644 --- a/tests/text_examples.py +++ b/tests/text_examples.py @@ -1,3 +1,4 @@ +import platform import os import warnings @@ -23,6 +24,7 @@ skip_plotting = pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") skip_no_shaft = pytest.mark.skipif(shaft is None, reason="Requires example file") +skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") def test_load_verif(): @@ -62,6 +64,7 @@ def test_show_cell_qual(): @skip_plotting @skip_no_shaft @pytest.mark.skipif(not HAS_IMAGEIO, reason='Requires imageio_ffmpeg') +@skip_mac def test_shaft_animate(tmpdir): filename = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) shaft.animate_nodal_solution(5, element_components='SHAFT_MESH', From 0a67f94c29daac7956c4a281e625f7f79eefa541 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 5 Aug 2021 11:25:46 -0600 Subject: [PATCH 15/16] skip all plotting on MacOS due to CIBuildWheel --- tests/test_binary_reader.py | 12 +++++------- tests/test_cyclic.py | 33 ++++++++++++++++----------------- tests/test_dist_rst.py | 10 ++++------ tests/test_rst.py | 21 +++++++++++---------- tests/text_examples.py | 5 ++--- 5 files changed, 38 insertions(+), 43 deletions(-) diff --git a/tests/test_binary_reader.py b/tests/test_binary_reader.py index b0b3bc04..df03ba0b 100644 --- a/tests/test_binary_reader.py +++ b/tests/test_binary_reader.py @@ -15,7 +15,6 @@ try: from ansys.mapdl.core import _HAS_ANSYS from ansys.mapdl.core.mapdl_grpc import MapdlGrpc - # from ansys.mapdl.core.mapdl_corba import MapdlCorba MapdlCorba = None from ansys.mapdl.core.mapdl_console import MapdlConsole except: @@ -34,10 +33,10 @@ test_path = os.path.dirname(os.path.abspath(__file__)) testfiles_path = os.path.join(test_path, 'testfiles') +IS_MAC = platform.system() == 'Darwin' skip_no_ansys = pytest.mark.skipif(not _HAS_ANSYS, reason="Requires ANSYS installed") -skip_no_xserver = pytest.mark.skipif(not system_supports_plotting(), - reason="Requires active X Server") -skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") +skip_plotting = pytest.mark.skipif(not system_supports_plotting() or IS_MAC, + reason="Requires active X Server") RSETS = list(zip(range(1, 9), [1]*8)) @@ -359,7 +358,7 @@ def test_save_as_vtk(tmpdir, result, result_type): assert np.allclose(arr, rst_arr, atol=1E-5, equal_nan=True) -@skip_no_xserver +@skip_plotting def test_plot_component(): """ # create example file for component plotting @@ -413,9 +412,8 @@ def test_file_close(tmpdir): os.remove(tmpfile) # tests file has been correctly closed -@skip_no_xserver +@skip_plotting @pytest.mark.skipif(not HAS_FFMPEG, reason="requires imageio_ffmpeg") -@skip_mac def test_animate_nodal_solution(tmpdir, result): temp_movie = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) result.animate_nodal_solution(0, nangles=20, movie_filename=temp_movie, diff --git a/tests/test_cyclic.py b/tests/test_cyclic.py index de8c1160..1e0c0b9f 100644 --- a/tests/test_cyclic.py +++ b/tests/test_cyclic.py @@ -31,9 +31,9 @@ except: result_z = None -skip_with_no_xserver = pytest.mark.skipif(not system_supports_plotting(), - reason="Requires active X Server") -skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") +IS_MAC = platform.system() == 'Darwin' +skip_plotting = pytest.mark.skipif(not system_supports_plotting() or IS_MAC, + reason="Requires active X Server") # static result x axis @@ -107,7 +107,7 @@ def test_non_cyclic(): rst = CyclicResult(examples.rstfile) -@skip_with_no_xserver +@skip_plotting @pytest.mark.skipif(result_z is None, reason="Requires result file") def test_plot_sectors(tmpdir): filename = str(tmpdir.mkdir("tmpdir").join('tmp.png')) @@ -117,14 +117,14 @@ def test_plot_sectors(tmpdir): assert os.path.isfile(filename) -@skip_with_no_xserver +@skip_plotting def test_plot_sectors_x(result_x): cpos = result_x.plot_sectors() if cpos is not None: assert isinstance(cpos, CameraPosition) -@skip_with_no_xserver +@skip_plotting @pytest.mark.skipif(result_z is None, reason="Requires result file") def test_plot_z_cyc(): cpos = result_z.plot() @@ -132,14 +132,14 @@ def test_plot_z_cyc(): assert isinstance(cpos, CameraPosition) -@skip_with_no_xserver +@skip_plotting def test_plot_x_cyc(result_x): cpos = result_x.plot() if cpos is not None: assert isinstance(cpos, CameraPosition) -@skip_with_no_xserver +@skip_plotting def test_plot_component_rotor(cyclic_v182_z_with_comp): cyclic_v182_z_with_comp.plot_nodal_solution(0, full_rotor=False, node_components='REFINE', @@ -276,7 +276,7 @@ def test_full_z_nodal_solution_phase(cyclic_v182_z): assert np.allclose(disp[:, mask], tmp) -@skip_with_no_xserver +@skip_plotting def test_full_x_nodal_solution_plot(result_x): result_x.plot_nodal_solution(0) @@ -345,10 +345,9 @@ def test_full_x_principal_nodal_stress(result_x): assert np.allclose(stress[:, mask], tmp, atol=4E-3) # too loose -@skip_with_no_xserver +@skip_plotting @pytest.mark.skipif(not HAS_FFMPEG, reason="requires imageio_ffmpeg") @pytest.mark.skipif(result_z is None, reason="Requires result file") -@skip_mac def test_animate_nodal_solution(tmpdir): temp_movie = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) result_z.animate_nodal_solution(0, nangles=20, movie_filename=temp_movie, @@ -375,17 +374,17 @@ def test_cyclic_z_harmonic_displacement(): assert np.allclose(disp[:, mask], tmp, atol=1E-5) -@skip_with_no_xserver +@skip_plotting def test_plot_nodal_stress(result_x): result_x.plot_nodal_stress(0, 'z') -@skip_with_no_xserver +@skip_plotting def test_plot_nodal_stress(result_x): result_x.plot_nodal_stress(0, 'z') -@skip_with_no_xserver +@skip_plotting def test_plot_principal_nodal_stress(result_x): result_x.plot_principal_nodal_stress(0, 'seqv') @@ -406,7 +405,7 @@ def test_nodal_elastic_strain_cyclic(result_x): assert np.allclose(stress, stress_ans) -@skip_with_no_xserver +@skip_plotting def test_plot_nodal_elastic_strain(result_x): result_x.plot_nodal_elastic_strain(0, 'X') @@ -427,7 +426,7 @@ def test_nodal_temperature(result_x): assert np.allclose(temp[mask], temp_ans[:, mask], equal_nan=True) -@skip_with_no_xserver +@skip_plotting def test_plot_nodal_nodal_temperature(result_x): result_x.plot_nodal_temperature(0) @@ -447,6 +446,6 @@ def test_nodal_thermal_strain_cyclic(result_x): assert np.allclose(strain, strain_ans) -@skip_with_no_xserver +@skip_plotting def test_plot_nodal_thermal_strain(result_x): result_x.plot_nodal_thermal_strain(0, 'X') diff --git a/tests/test_dist_rst.py b/tests/test_dist_rst.py index 4482c9bb..d4e3b14e 100644 --- a/tests/test_dist_rst.py +++ b/tests/test_dist_rst.py @@ -28,11 +28,10 @@ test_path = os.path.dirname(os.path.abspath(__file__)) testfiles_path = os.path.join(test_path, 'testfiles') - +IS_MAC = platform.system() == 'Darwin' skip_no_ansys = pytest.mark.skipif(not _HAS_ANSYS, reason="Requires ANSYS installed") -skip_no_xserver = pytest.mark.skipif(not system_supports_plotting(), - reason="Requires active X Server") -skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") +skip_plotting = pytest.mark.skipif(not system_supports_plotting() or IS_MAC, + reason="Requires active X Server") @pytest.fixture() @@ -279,8 +278,7 @@ def test_result_does_not_exist(static_dis): static_dis.nodal_plastic_strain(0) -@skip_no_xserver -@skip_mac +@skip_plotting def test_animate_nodal_solution(static_dis): static_dis.animate_nodal_solution(0, loop=False) diff --git a/tests/test_rst.py b/tests/test_rst.py index 9388ccb6..6b94ba47 100644 --- a/tests/test_rst.py +++ b/tests/test_rst.py @@ -65,7 +65,9 @@ except: pontoon = None -skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") +IS_MAC = platform.system() == 'Darwin' +skip_plotting = pytest.mark.skipif(not system_supports_plotting() or IS_MAC, + reason="Requires active X Server") test_path = os.path.dirname(os.path.abspath(__file__)) testfiles_path = os.path.join(test_path, 'testfiles') @@ -195,14 +197,13 @@ def test_nodal_thermal_strain(): assert tstrain.shape == (vm33.grid.n_points, 8) -@pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +@skip_plotting @pytest.mark.skipif(vm33 is None, reason="Requires example files") def test_plot_nodal_thermal_strain(): vm33.plot_nodal_thermal_strain(0, 'X', off_screen=True) - -@pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +@skip_plotting @pytest.mark.skipif(vm33 is None, reason="Requires example files") def test_plot_nodal_thermal_strain(): vm33._animate_time_solution('ENS', off_screen=True) @@ -215,26 +216,26 @@ def test_nodal_elastic_strain(): assert estrain.shape == (pontoon.grid.n_points, 7) -@pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +@skip_plotting @pytest.mark.skipif(pontoon is None, reason="Requires example files") def test_plot_nodal_elastic_strain(): pontoon.plot_nodal_elastic_strain(0, 'X', off_screen=True) -@pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +@skip_plotting @pytest.mark.skipif(pontoon is None, reason="Requires example files") def test_plot_pontoon(): pontoon.plot(off_screen=True) -@pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +@skip_plotting @pytest.mark.skipif(pontoon is None, reason="Requires example files") def test_plot_pontoon_nodal_displacement(): pontoon.plot_nodal_solution(0, show_displacement=True, overlay_wireframe=True, off_screen=True) -@pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +@skip_plotting @pytest.mark.skipif(pontoon is None, reason="Requires example files") def test_plot_pontoon_nodal_displacement(): pontoon.plot_nodal_displacement(0, show_displacement=True, @@ -294,7 +295,7 @@ def test_read_temperature(): assert np.allclose(temp, npz_rst['temp']) -@pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +@skip_plotting @pytest.mark.skipif(not os.path.isfile(temperature_rst), reason="Requires example files") def test_plot_nodal_temperature(): @@ -340,7 +341,7 @@ def test_cyl_stress(hex_pipe_corner): assert np.allclose(my_stress[-114:], ans_stress, atol=1E-7) -@pytest.mark.skipif(not system_supports_plotting(), reason="Requires active X Server") +@skip_plotting def test_plot_cyl_stress(hex_pipe_corner): with pytest.raises(ValueError): cpos = hex_pipe_corner.plot_cylindrical_nodal_stress(0, off_screen=True) diff --git a/tests/text_examples.py b/tests/text_examples.py index 36f44671..e8213db5 100644 --- a/tests/text_examples.py +++ b/tests/text_examples.py @@ -21,10 +21,10 @@ shaft = None -skip_plotting = pytest.mark.skipif(not system_supports_plotting(), +IS_MAC = platform.system() == 'Darwin' +skip_plotting = pytest.mark.skipif(not system_supports_plotting() or IS_MAC, reason="Requires active X Server") skip_no_shaft = pytest.mark.skipif(shaft is None, reason="Requires example file") -skip_mac = pytest.mark.skipif(platform.system() == 'Darwin', reason="Flaky Mac tests") def test_load_verif(): @@ -64,7 +64,6 @@ def test_show_cell_qual(): @skip_plotting @skip_no_shaft @pytest.mark.skipif(not HAS_IMAGEIO, reason='Requires imageio_ffmpeg') -@skip_mac def test_shaft_animate(tmpdir): filename = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) shaft.animate_nodal_solution(5, element_components='SHAFT_MESH', From a8f782528281fcd1c1cbeee0055657baaac56013 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 5 Aug 2021 13:18:15 -0600 Subject: [PATCH 16/16] add missing cameraposition to rst tests --- tests/test_rst.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_rst.py b/tests/test_rst.py index 6b94ba47..eba10bed 100644 --- a/tests/test_rst.py +++ b/tests/test_rst.py @@ -39,6 +39,7 @@ import numpy as np import pytest from pyvista.plotting import system_supports_plotting +from pyvista.plotting.renderer import CameraPosition from ansys.mapdl import reader as pymapdl_reader from ansys.mapdl.reader import examples