Skip to content

Commit ec6cffa

Browse files
Conditionally set matplotlib backend to Agg only if running in GitHub Actions and OS is windows, since GHA macos apparently doesn't like Agg backend (https://github.com/softwareengineerprogrammer/GEOPHIRES/actions/runs/14779862524/job/41496253000\#step:5:721)
1 parent fa32232 commit ec6cffa

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

.github/workflows/github-actions.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ jobs:
119119
- name: test
120120
env:
121121
TOXPYTHON: '${{ matrix.toxpython }}'
122-
123-
# Prevent intermittent GitHub Actions Windows failures per https://github.com/NREL/GEOPHIRES-X/issues/365
124-
MPLBACKEND: 'Agg'
125-
126122
run: >
127123
tox -e ${{ matrix.tox_env }} -v
128124

tests/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import matplotlib
1+
import os
22

3-
# Backend should be 'Agg' in GitHub Actions to prevent intermittent Windows failures
4-
# per https://github.com/NREL/GEOPHIRES-X/issues/365
5-
print(f'[DEBUG] matplotlib backend: {matplotlib.get_backend()}')
3+
import matplotlib as mpl
4+
5+
if os.name == 'nt' and 'TOXPYTHON' in os.environ:
6+
# Backend should be 'Agg' in GitHub Actions to prevent intermittent Windows failures
7+
# per https://github.com/NREL/GEOPHIRES-X/issues/365
8+
mpl.use('Agg')
9+
10+
print(f'[DEBUG] matplotlib backend: {mpl.get_backend()}')

0 commit comments

Comments
 (0)