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

Fix matplotlib import in DVGeoCST #182

Merged
merged 3 commits into from
Feb 14, 2023

Conversation

eytanadler
Copy link
Contributor

Purpose

In very specific cases in GitHub Action builds for OpenAeroStruct, the matplotlib import was failing because of something in the font manager. With a brief effort, I was not able to reproduce it locally. One case that fails on GitHub Actions is with Python 3.8 (seems to be fixed in Python 3.10 and beyond) and the following Python package versions:

Package             Version   Editable project location                       Location                                                           Installer
------------------- --------- ----------------------------------------------- ------------------------------------------------------------------ ---------
attrs               22.2.0                                                    /opt/hostedtoolcache/Python/3.[8](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:11:9).16/x64/lib/python3.8/site-packages pip
certifi             2022.12.7                                                 /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
charm               0.1.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages
charset-normalizer  3.0.1                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
contourpy           1.0.7                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
coverage            4.5.4                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
cycler              0.11.0                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
degen-geom          0.0.1                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages
exceptiongroup      1.1.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
fonttools           4.38.0                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
fortranformat       1.2.2                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages
idna                3.4                                                       /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
importlib-resources 5.10.2                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
iniconfig           2.0.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
kiwisolver          1.4.4                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
matplotlib          3.7.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
mdolab-baseclasses  1.7.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
mpi4py              3.1.4                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
networkx            3.0                                                       /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
numpy               1.20.0                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
numpy-stl           3.0.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
openaerostruct      2.5.3     /home/runner/work/OpenAeroStruct/OpenAeroStruct /home/runner/work/OpenAeroStruct/OpenAeroStruct
openmdao            3.10.0                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
openvsp             3.27.1                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages
packaging           23.0                                                      /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pandas              1.5.3                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
parameterized       0.8.1                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
Pillow              [9](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:11:10).4.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pip                 23.0                                                      /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pluggy              1.0.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pyDOE2              1.3.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pygeo               1.12.2                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pyparsing           3.0.9                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pyspline            1.5.2     /home/runner/work/OpenAeroStruct/pyspline       /home/runner/work/OpenAeroStruct/pyspline
pytest              7.2.1                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pytest-cov          4.0.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
python-dateutil     2.8.2                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
python-utils        3.5.2                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
pytz                2022.7.1                                                  /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
requests            2.28.2                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
scipy               1.6.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
setuptools          56.0.0                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
six                 1.16.0                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
testflo             1.4.[10](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:11:11)                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
tomli               2.0.1                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
urllib3             1.26.14                                                   /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
utilities           0.1.0                                                     /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages
wheel               0.38.4                                                    /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages pip
zipp                3.[13](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:11:14).0                                                    /opt/hostedtoolcache/Python/3.8.[16](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:11:17)/x64/lib/python3.8/site-packages pip

The error raised when pytest is then called is:

-> Run python -m pytest --cov-config=.coveragerc --cov=openaerostruct --cov-report=xml
Fatal Python error: Aborted

Thread 0x00007f22c67ff640 (most recent call first):
  File "/opt/hostedtoolcache/Python/3.[8](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:12:9).16/x64/lib/python3.8/threading.py", line 306 in wait
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/threading.py", line 558 in wait
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/threading.py", line 1252 in run
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/threading.py", line [9](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:12:10)32 in _bootstrap_inner
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/threading.py", line 890 in _bootstrap

Current thread 0x00007f22f61acb80 (most recent call first):
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/subprocess.py", line 1639 in _execute_child
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/subprocess.py", line 858 in __init__
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/subprocess.py", line 493 in run
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/subprocess.py", line 415 in check_output
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/font_manager.py", line 249 in _get_fontconfig_fonts
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/font_manager.py", line 275 in findSystemFonts
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/font_manager.py", line [10](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:12:11)14 in __init__
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1542 in _load_fontmanager
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1548 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/text.py", line 16 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1042 in _handle_fromlist
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 45 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/contour.py", line 13 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1042 in _handle_fromlist
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/colorbar.py", line 19 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/matplotlib/pyplot.py", line 52 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pygeo/parameterization/DVGeoCST.py", line 25 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pygeo/parameterization/__init__.py", line 3 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pygeo/__init__.py", line 7 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 843 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "/home/runner/work/OpenAeroStruct/OpenAeroStruct/openaerostruct/tests/test_aero_ffd.py", line 7 in <module>
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 168 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "<frozen importlib._bootstrap>", line 1014 in _gcd_import
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/importlib/__init__.py", line 127 in import_module
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/pathlib.py", line 533 in import_path
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/python.py", line 618 in _importtestmodule
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/python.py", line 529 in _getobj
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/python.py", line 3[11](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:12:12) in obj
  File "/opt/hostedtoolcache/Python/3.8.[16](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:12:17)/x64/lib/python3.8/site-packages/_pytest/python.py", line 546 in _inject_setup_module_fixture
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/python.py", line 532 in collect
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/runner.py", line 370 in <lambda>
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/runner.py", line 339 in from_call
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/runner.py", line 370 in pytest_make_collect_report
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/runner.py", line 538 in collect_one_node
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/main.py", line 831 in genitems
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/main.py", line 834 in genitems
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/main.py", line 664 in perform_collect
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/main.py", line 334 in pytest_collection
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/main.py", line 323 in _main
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/main.py", line 270 in wrap_session
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/main.py", line 3[17](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:12:18) in pytest_cmdline_main
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pluggy/_hooks.py", line [26](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:12:27)5 in __call__
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/_pytest/config/__init__.py", line 167 in main
  ...
/home/runner/work/_temp/060ee01b-4c4b-47bf-b6e4-cd0064001b2b.sh: line 1: 117[27](https://github.com/mdolab/OpenAeroStruct/actions/runs/4175394644/jobs/7230248894#step:12:28) Aborted                 (core dumped) python -m pytest --cov-config=.coveragerc --cov=openaerostruct --cov-report=xml

By catching the ImportError instead of only if matplotlib is not installed, this problem is caught. The error may have something to do with matplotlib/matplotlib#19560.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

@eytanadler eytanadler requested a review from a team as a code owner February 14, 2023 17:10
@eytanadler eytanadler requested review from hajdik and lamkina and removed request for ArshSaja February 14, 2023 17:22
@codecov
Copy link

codecov bot commented Feb 14, 2023

Codecov Report

Merging #182 (11ae74b) into main (cc5c642) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##             main     #182   +/-   ##
=======================================
  Coverage   64.76%   64.76%           
=======================================
  Files          47       47           
  Lines       11949    11949           
=======================================
  Hits         7739     7739           
  Misses       4210     4210           
Impacted Files Coverage Δ
pygeo/constraints/DVCon.py 71.72% <ø> (ø)
pygeo/constraints/baseConstraint.py 57.22% <ø> (ø)
pygeo/constraints/gearPostConstraint.py 16.36% <ø> (ø)
pygeo/geo_utils/dcel.py 11.30% <ø> (ø)
pygeo/geo_utils/ffd_generation.py 83.89% <ø> (ø)
pygeo/geo_utils/node_edge_face.py 45.71% <ø> (ø)
pygeo/geo_utils/pointselect.py 7.14% <ø> (ø)
pygeo/geo_utils/projection.py 17.76% <ø> (ø)
pygeo/geo_utils/split_quad.py 7.31% <ø> (ø)
pygeo/mphys/mphys_dvgeo.py 0.00% <ø> (ø)
... and 10 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@hajdik hajdik merged commit a6ed01f into mdolab:main Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants