From 6663aef739dc22ee1892196cd7d4965eb835953d Mon Sep 17 00:00:00 2001 From: lkk7 Date: Mon, 9 Jun 2025 21:54:32 +0200 Subject: [PATCH 1/4] Fix pydot tests --- cwltool/cwlviewer.py | 20 ++++++++++++++------ mypy-stubs/pydot.pyi | 1 - 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cwltool/cwlviewer.py b/cwltool/cwlviewer.py index e544a568e..094d37900 100644 --- a/cwltool/cwlviewer.py +++ b/cwltool/cwlviewer.py @@ -89,8 +89,8 @@ def _set_inner_edges(self) -> None: self._dot_graph.add_node(n) self._dot_graph.add_edge( pydot.Edge( - str(inner_edge_row["source_step"]), - str(inner_edge_row["target_step"]), + pydot.quote_id_if_necessary(str(inner_edge_row["source_step"])), + pydot.quote_id_if_necessary(str(inner_edge_row["target_step"])), ) ) @@ -100,7 +100,6 @@ def _set_input_edges(self) -> None: inputs_subgraph = pydot.Subgraph(graph_name="cluster_inputs") self._dot_graph.add_subgraph(inputs_subgraph) inputs_subgraph.set("rank", "same") - inputs_subgraph.create_attribute_methods(["style"]) inputs_subgraph.set("style", "dashed") inputs_subgraph.set("label", "Workflow Inputs") @@ -120,7 +119,12 @@ def _set_input_edges(self) -> None: ) n.set_name(str(input_row["input"])) inputs_subgraph.add_node(n) - self._dot_graph.add_edge(pydot.Edge(str(input_row["input"]), str(input_row["step"]))) + self._dot_graph.add_edge( + pydot.Edge( + pydot.quote_id_if_necessary(str(input_row["input"])), + pydot.quote_id_if_necessary(str(input_row["step"])), + ) + ) def _set_output_edges(self) -> None: with open(_get_output_edges_query_path) as f: @@ -128,7 +132,6 @@ def _set_output_edges(self) -> None: outputs_graph = pydot.Subgraph(graph_name="cluster_outputs") self._dot_graph.add_subgraph(outputs_graph) outputs_graph.set("rank", "same") - outputs_graph.create_attribute_methods(["style"]) outputs_graph.set("style", "dashed") outputs_graph.set("label", "Workflow Outputs") outputs_graph.set("labelloc", "b") @@ -148,7 +151,12 @@ def _set_output_edges(self) -> None: ) n.set_name(str(output_edge_row["output"])) outputs_graph.add_node(n) - self._dot_graph.add_edge(pydot.Edge(output_edge_row["step"], output_edge_row["output"])) + self._dot_graph.add_edge( + pydot.Edge( + pydot.quote_id_if_necessary(output_edge_row["step"]), + pydot.quote_id_if_necessary(output_edge_row["output"]), + ) + ) def _get_root_graph_uri(self) -> rdflib.term.Identifier: with open(_get_root_query_path) as f: diff --git a/mypy-stubs/pydot.pyi b/mypy-stubs/pydot.pyi index bd0ab3147..3641b25b0 100644 --- a/mypy-stubs/pydot.pyi +++ b/mypy-stubs/pydot.pyi @@ -21,7 +21,6 @@ class Common: def get_attributes(self) -> Dict[str, str]: ... def set_sequence(self, seq: str) -> None: ... def get_sequence(self) -> str: ... - def create_attribute_methods(self, obj_attributes: List[str]) -> None: ... class Error(Exception): value: Any From 1ed32af57730481f3f0c1bc17460d277ebc09a22 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Tue, 20 Aug 2024 10:22:00 +0200 Subject: [PATCH 2/4] Revert "skip pydot 3.x+ for now" This reverts commit 3299069f645d201407353a8add5887c474bd1f38. --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index df82a6f43..6d915e657 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ mypy-extensions psutil>=5.6.6 importlib_resources>=1.4;python_version<'3.9' coloredlogs -pydot>=1.4.1,<3 +pydot>=1.4.1 argcomplete>=1.12.0 pyparsing!=3.0.2 # breaks --print-dot (pydot) https://github.com/pyparsing/pyparsing/issues/319 cwl-utils>=0.32 diff --git a/setup.py b/setup.py index 748e97aae..b4b9172e9 100644 --- a/setup.py +++ b/setup.py @@ -133,7 +133,7 @@ "psutil >= 5.6.6", "importlib_resources>=1.4;python_version<'3.9'", "coloredlogs", - "pydot >= 1.4.1, <3", + "pydot >= 1.4.1", "argcomplete", "pyparsing != 3.0.2", # breaks --print-dot (pydot) https://github.com/pyparsing/pyparsing/issues/319 "cwl-utils >= 0.32", From 88e10ca3347428fc93200322d12673724aa92581 Mon Sep 17 00:00:00 2001 From: lkk7 Date: Tue, 10 Jun 2025 09:34:32 +0200 Subject: [PATCH 3/4] Add `quote_id_if_necessary` to `pydot.pyi` --- mypy-stubs/pydot.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mypy-stubs/pydot.pyi b/mypy-stubs/pydot.pyi index 3641b25b0..881b3e508 100644 --- a/mypy-stubs/pydot.pyi +++ b/mypy-stubs/pydot.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Sequence, Union +from typing import Any, Dict, List, Optional, Sequence, Union PY3: Any str_type = str @@ -12,6 +12,9 @@ def is_windows() -> bool: ... def is_anaconda() -> bool: ... def get_executable_extension() -> str: ... def graph_from_dot_data(s: str) -> List["Dot"]: ... +def quote_id_if_necessary( + s: str, unquoted_keywords: Optional[Sequence[str]] = None +) -> str: ... class Common: def set_parent_graph(self, parent_graph: "Graph") -> None: ... From 551d6b571aec8ef1f1359d924805aa5bdc718770 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Tue, 10 Jun 2025 10:32:11 +0200 Subject: [PATCH 4/4] fix formatting --- mypy-stubs/pydot.pyi | 4 +--- tests/test_context.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mypy-stubs/pydot.pyi b/mypy-stubs/pydot.pyi index 881b3e508..ecf3a453b 100644 --- a/mypy-stubs/pydot.pyi +++ b/mypy-stubs/pydot.pyi @@ -12,9 +12,7 @@ def is_windows() -> bool: ... def is_anaconda() -> bool: ... def get_executable_extension() -> str: ... def graph_from_dot_data(s: str) -> List["Dot"]: ... -def quote_id_if_necessary( - s: str, unquoted_keywords: Optional[Sequence[str]] = None -) -> str: ... +def quote_id_if_necessary(s: str, unquoted_keywords: Optional[Sequence[str]] = None) -> str: ... class Common: def set_parent_graph(self, parent_graph: "Graph") -> None: ... diff --git a/tests/test_context.py b/tests/test_context.py index 5f3666ce9..505dfd635 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -1,10 +1,10 @@ import logging import subprocess import sys +from collections.abc import MutableMapping from io import StringIO from pathlib import Path from typing import cast -from collections.abc import MutableMapping from cwltool.context import RuntimeContext from cwltool.factory import Factory