From fc724ccd55eb4d7ebfe70262527b634d57fba568 Mon Sep 17 00:00:00 2001 From: Ricardo Vieira Date: Mon, 12 Jun 2023 18:08:09 +0200 Subject: [PATCH] Stop support pydot-ng and test pydot in CI --- .github/workflows/test.yml | 2 +- pytensor/printing.py | 33 +++++++-------------------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8fc482fd95..1dc18e83ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -139,7 +139,7 @@ jobs: - name: Install dependencies shell: bash -l {0} run: | - mamba install --yes -q "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service graphviz cython pytest coverage pytest-cov pytest-benchmark sympy + mamba install --yes -q "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service pydot graphviz cython pytest coverage pytest-cov pytest-benchmark sympy # numba-scipy downgrades the installed scipy to 1.7.3 in Python 3.8, but # not numpy, even though scipy 1.7 requires numpy<1.23. When installing # PyTensor next, pip installs a lower version of numpy via the PyPI. diff --git a/pytensor/printing.py b/pytensor/printing.py index 11b266021b..0f6c50fd64 100644 --- a/pytensor/printing.py +++ b/pytensor/printing.py @@ -39,34 +39,15 @@ pydot_imported = False pydot_imported_msg = "" try: - # pydot-ng is a fork of pydot that is better maintained - import pydot_ng as pd + import pydot as pd - if pd.find_graphviz(): - pydot_imported = True - else: - pydot_imported_msg = "pydot-ng can't find graphviz. Install graphviz." + pd.Dot.create(pd.Dot()) + pydot_imported = True except ImportError: - try: - # fall back on pydot if necessary - import pydot as pd - - if hasattr(pd, "find_graphviz"): - if pd.find_graphviz(): - pydot_imported = True - else: - pydot_imported_msg = "pydot can't find graphviz" - else: - pd.Dot.create(pd.Dot()) - pydot_imported = True - except ImportError: - # tests should not fail on optional dependency - pydot_imported_msg = ( - "Install the python package pydot or pydot-ng. Install graphviz." - ) - except Exception as e: - pydot_imported_msg = "An error happened while importing/trying pydot: " - pydot_imported_msg += str(e.args) + pydot_imported_msg = "pydot package not installed" +except Exception as e: + pydot_imported_msg = "An error happened while importing/testing pydot: " + pydot_imported_msg += str(e.args) _logger = logging.getLogger("pytensor.printing")