From 5962bb43eb4074d230272654c3b0904d7413e1b1 Mon Sep 17 00:00:00 2001 From: Liam Huber Date: Wed, 27 Mar 2024 15:12:30 -0700 Subject: [PATCH] Update graphviz (#267) * Update graphviz Not python-graphviz, but the non-python one on conda-forge * [dependabot skip] Update env file * Downgrade python-graphviz * [dependabot skip] Update env file * Add a warning about windows+pdf and try and let it through the tests * Bump python-graphviz back up to latest * [dependabot skip] Update env file --------- Co-authored-by: pyiron-runner --- .binder/environment.yml | 2 +- .ci_support/environment.yml | 2 +- docs/environment.yml | 2 +- pyiron_workflow/node.py | 11 +++++++++++ tests/unit/test_node.py | 36 +++++++++++++++++++++++++++--------- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.binder/environment.yml b/.binder/environment.yml index 482a842a..9e772e2b 100644 --- a/.binder/environment.yml +++ b/.binder/environment.yml @@ -5,7 +5,7 @@ dependencies: - coverage - bidict =0.23.1 - cloudpickle =3.0.0 -- graphviz =8.1.0 +- graphviz =9.0.0 - h5io =0.2.2 - h5io_browser =0.0.9 - matplotlib =3.8.3 diff --git a/.ci_support/environment.yml b/.ci_support/environment.yml index c677e131..879c77e0 100644 --- a/.ci_support/environment.yml +++ b/.ci_support/environment.yml @@ -5,7 +5,7 @@ dependencies: - coverage - bidict =0.23.1 - cloudpickle =3.0.0 -- graphviz =8.1.0 +- graphviz =9.0.0 - h5io =0.2.2 - h5io_browser =0.0.9 - matplotlib =3.8.3 diff --git a/docs/environment.yml b/docs/environment.yml index 6bd44d06..ccfeea72 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -10,7 +10,7 @@ dependencies: - coverage - bidict =0.23.1 - cloudpickle =3.0.0 -- graphviz =8.1.0 +- graphviz =9.0.0 - h5io =0.2.2 - h5io_browser =0.0.9 - matplotlib =3.8.3 diff --git a/pyiron_workflow/node.py b/pyiron_workflow/node.py index 0572417e..9148b594 100644 --- a/pyiron_workflow/node.py +++ b/pyiron_workflow/node.py @@ -10,6 +10,7 @@ import sys from abc import ABC from concurrent.futures import Future +import platform from typing import Any, Literal, Optional, TYPE_CHECKING import warnings @@ -645,7 +646,17 @@ def draw( Returns: (graphviz.graphs.Digraph): The resulting graph object. + + Warnings: + Rendering a PDF format appears to not be working on Windows right now. """ + if format == "pdf" and platform.system() == "Windows": + warnings.warn( + "Graphviz does not appear to be playing well with Windows right now," + "this will probably fail and you will need to try a different format." + "If it _doesn't_ fail, please contact the developers by raising an " + "issue at github.com/pyiron/pyiron_workflow" + ) if size is not None: size = f"{size[0]},{size[1]}" graph = GraphvizNode(self, depth=depth, rankdir=rankdir, size=size).graph diff --git a/tests/unit/test_node.py b/tests/unit/test_node.py index 1782d49d..ce84b572 100644 --- a/tests/unit/test_node.py +++ b/tests/unit/test_node.py @@ -1,5 +1,7 @@ from concurrent.futures import Future import os +import platform +from subprocess import CalledProcessError import sys from typing import Literal, Optional import unittest @@ -318,15 +320,31 @@ def test_draw(self): any(self.n1.working_directory.path.iterdir()) ) - fmt = "pdf" # This is just so we concretely know the filename suffix - self.n1.draw(save=True, format=fmt) - expected_name = self.n1.label + "_graph." + fmt - # That name is just an implementation detail, update it as needed - self.assertTrue( - self.n1.working_directory.path.joinpath(expected_name).is_file(), - msg="If `save` is called, expect the rendered image to exist in the working" - "directory" - ) + for fmt in ["pdf", "png"]: + with self.subTest(f"Testing with format {fmt}"): + if fmt == "pdf" and platform.system() == "Windows": + with self.assertRaises( + CalledProcessError, + msg="Graphviz doesn't seem to be happy about the " + "combindation PDF format and Windows right now. We " + "throw a warning for it in `Node.draw`, so if this " + "test ever fails and this combination _doesn't_ fail, " + "remove this extra bit of testing and remove the " + "warning." + ): + self.n1.draw(save=True, format=fmt) + else: + self.n1.draw(save=True, format=fmt) + expected_name = self.n1.label + "_graph." + fmt + # That name is just an implementation detail, update it as + # needed + self.assertTrue( + self.n1.working_directory.path.joinpath( + expected_name + ).is_file(), + msg="If `save` is called, expect the rendered image to " + "exist in the working directory" + ) user_specified_name = "foo" self.n1.draw(filename=user_specified_name, format=fmt)