Repository: dask/dask
Pull request #8794 (2022-03-09 16:46:04)

Temporarily xfail graphviz tests on windows
Something in the recent pango or graphviz builds on conda-forge broke,
and now these tests are failing. Xfail these tests temporarily until the
upstream issue is resolved.



Patch:
diff --git a/dask/base.py b/dask/base.py
index a21fabb9e..cda4a7e77 100644
--- a/dask/base.py
+++ b/dask/base.py
@@ -1425,22 +1425,20 @@ def replace_name_in_key(key, rename: Mapping[str, str]):
 
 def clone_key(key, seed):
     """Clone a key from a Dask collection, producing a new key with the same prefix and
-    indices and a token which a deterministic function of the previous token and seed.
+    indices and a token which is a deterministic function of the previous key and seed.
 
     Examples
     --------
-    >>> clone_key("inc-cbb1eca3bafafbb3e8b2419c4eebb387", 123)  # doctest: +SKIP
-    'inc-1d291de52f5045f8a969743daea271fd'
-    >>> clone_key(("sum-cbb1eca3bafafbb3e8b2419c4eebb387", 4, 3), 123)  # doctest: +SKIP
-    ('sum-f0962cc58ef4415689a86cc1d4cc1723', 4, 3)
+    >>> clone_key("x", 123)
+    'x-dc2b8d1c184c72c19faa81c797f8c6b0'
+    >>> clone_key("inc-cbb1eca3bafafbb3e8b2419c4eebb387", 123)
+    'inc-f81b5a88038a2132882aa29a9fcfec06'
+    >>> clone_key(("sum-cbb1eca3bafafbb3e8b2419c4eebb387", 4, 3), 123)
+    ('sum-fd6be9e9fe07fc232ad576fa997255e8', 4, 3)
     """
     if isinstance(key, tuple) and key and isinstance(key[0], str):
         return (clone_key(key[0], seed),) + key[1:]
     if isinstance(key, str):
         prefix = key_split(key)
-        token = key[len(prefix) + 1 :]
-        if token:
-            return prefix + "-" + tokenize(token, seed)
-        else:
-            return tokenize(key, seed)
+        return prefix + "-" + tokenize(key, seed)
     raise TypeError(f"Expected str or tuple[str, Hashable, ...]; got {key}")
diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py
index 507dea870..26fbc4f00 100644
--- a/dask/dataframe/core.py
+++ b/dask/dataframe/core.py
@@ -603,7 +603,7 @@ Dask Name: {name}, {task} tasks"""
         >>> import dask
         >>> ddf = dask.datasets.timeseries(start="2021-01-01", end="2021-01-07", freq="1H").clear_divisions()
         >>> divisions = ddf.compute_current_divisions()
-        ... divisions
+        >>> print(divisions)  # doctest: +NORMALIZE_WHITESPACE
         (Timestamp('2021-01-01 00:00:00'),
          Timestamp('2021-01-02 00:00:00'),
          Timestamp('2021-01-03 00:00:00'),
@@ -611,12 +611,14 @@ Dask Name: {name}, {task} tasks"""
          Timestamp('2021-01-05 00:00:00'),
          Timestamp('2021-01-06 00:00:00'),
          Timestamp('2021-01-06 23:00:00'))
+
         >>> ddf.divisions = divisions
         >>> ddf.known_divisions
         True
+
         >>> ddf = ddf.reset_index().clear_divisions()
         >>> divisions = ddf.compute_current_divisions("timestamp")
-        ... divisions
+        >>> print(divisions)  # doctest: +NORMALIZE_WHITESPACE
         (Timestamp('2021-01-01 00:00:00'),
          Timestamp('2021-01-02 00:00:00'),
          Timestamp('2021-01-03 00:00:00'),
@@ -624,6 +626,7 @@ Dask Name: {name}, {task} tasks"""
          Timestamp('2021-01-05 00:00:00'),
          Timestamp('2021-01-06 00:00:00'),
          Timestamp('2021-01-06 23:00:00'))
+
         >>> ddf = ddf.set_index("timestamp", divisions=divisions, sorted=True)
         """
         if col is None and self.known_divisions:


Test patch:
diff --git a/dask/tests/test_base.py b/dask/tests/test_base.py
index f2e972224..b84ec6148 100644
--- a/dask/tests/test_base.py
+++ b/dask/tests/test_base.py
@@ -1009,6 +1009,11 @@ def test_compute_nested():
 @pytest.mark.skipif(
     sys.flags.optimize, reason="graphviz exception with Python -OO flag"
 )
+@pytest.mark.xfail(
+    sys.platform == "win32",
+    reason="graphviz/pango on conda-forge currently broken for windows",
+    strict=False,
+)
 def test_visualize():
     pytest.importorskip("graphviz")
     with tmpdir() as d:
@@ -1479,11 +1484,12 @@ def test_optimizations_ctd():
 
 def test_clone_key():
     h = object()  # arbitrary hashable
-    assert clone_key("inc-1-2-3", 123) == "inc-27b6e15b795fcaff169e0e0df14af97a"
-    assert clone_key("x", 123) == "dc2b8d1c184c72c19faa81c797f8c6b0"
-    assert clone_key("x", 456) == "b76f061b547b00d18b9c7a18ccc47e2d"
+    assert clone_key("inc-1-2-3", 123) == "inc-4dfeea2f9300e67a75f30bf7d6182ea4"
+    assert clone_key("x", 123) == "x-dc2b8d1c184c72c19faa81c797f8c6b0"
+    assert clone_key("x", 456) == "x-b76f061b547b00d18b9c7a18ccc47e2d"
+    assert clone_key(("x", 1), 456) == ("x-b76f061b547b00d18b9c7a18ccc47e2d", 1)
     assert clone_key(("sum-1-2-3", h, 1), 123) == (
-        "sum-27b6e15b795fcaff169e0e0df14af97a",
+        "sum-1efd41f02035dc802f4ebb9995d07e9d",
         h,
         1,
     )
@@ -1491,7 +1497,7 @@ def test_clone_key():
         clone_key(1, 2)
 
 
-def test_compte_as_if_collection_low_level_task_graph():
+def test_compute_as_if_collection_low_level_task_graph():
     # See https://github.com/dask/dask/pull/7969
     da = pytest.importorskip("dask.array")
     x = da.arange(10)
diff --git a/dask/tests/test_dot.py b/dask/tests/test_dot.py
index 131d16b1b..93d46aed0 100644
--- a/dask/tests/test_dot.py
+++ b/dask/tests/test_dot.py
@@ -178,6 +178,11 @@ def test_to_graphviz_with_unconnected_node():
         pytest.param("svg", SVG, marks=ipython_not_installed_mark),
     ],
 )
+@pytest.mark.xfail(
+    sys.platform == "win32",
+    reason="graphviz/pango on conda-forge currently broken for windows",
+    strict=False,
+)
 def test_dot_graph(tmpdir, format, typ):
     # Use a name that the shell would interpret specially to ensure that we're
     # not vulnerable to shell injection when interacting with `dot`.
@@ -211,6 +216,11 @@ def test_dot_graph(tmpdir, format, typ):
         pytest.param("svg", SVG, marks=ipython_not_installed_mark),
     ],
 )
+@pytest.mark.xfail(
+    sys.platform == "win32",
+    reason="graphviz/pango on conda-forge currently broken for windows",
+    strict=False,
+)
 def test_dot_graph_no_filename(tmpdir, format, typ):
     before = tmpdir.listdir()
     result = dot_graph(dsk, filename=None, format=format)
@@ -221,6 +231,11 @@ def test_dot_graph_no_filename(tmpdir, format, typ):
 
 
 @ipython_not_installed_mark
+@pytest.mark.xfail(
+    sys.platform == "win32",
+    reason="graphviz/pango on conda-forge currently broken for windows",
+    strict=False,
+)
 def test_dot_graph_defaults():
     # Test with default args.
     default_name = "mydask"
@@ -258,6 +273,11 @@ def test_dot_graph_defaults():
         ),
     ],
 )
+@pytest.mark.xfail(
+    sys.platform == "win32",
+    reason="graphviz/pango on conda-forge currently broken for windows",
+    strict=False,
+)
 def test_filenames_and_formats(tmpdir, filename, format, target, expected_result_type):
     result = dot_graph(dsk, filename=str(tmpdir.join(filename)), format=format)
     assert tmpdir.join(target).exists()