Skip to content

Commit abc4562

Browse files
authored
[BUG] fix sporadic tkinter failures in CI (#1937)
Fixes #1747 by forcing `"Agg"` backend for `matplotlib` in CI.
1 parent f8f18f9 commit abc4562

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/test_models/conftest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import numpy as np
1+
import os
2+
23
import pytest
4+
from skbase.utils.dependencies import _check_soft_dependencies
35
import torch
46

57
from pytorch_forecasting import TimeSeriesDataSet
68
from pytorch_forecasting.data import EncoderNormalizer, GroupNormalizer, NaNLabelEncoder
7-
from pytorch_forecasting.data.examples import generate_ar_data, get_stallion_data
9+
10+
# used to prevent tkinter related errors in CI, see #1937
11+
if _check_soft_dependencies("matplotlib", severity="none"):
12+
if os.environ.get("GITHUB_ACTIONS") == "true":
13+
import matplotlib
14+
15+
matplotlib.use("Agg")
16+
817

918
torch.manual_seed(23)
1019

0 commit comments

Comments
 (0)