Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions cwltool/cwlviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

import pydot
import rdflib
from packaging.version import Version

if Version(pydot.__version__) > Version("3.0"):
quote_id_if_necessary = pydot.quote_id_if_necessary
else:
quote_id_if_necessary = pydot.quote_if_necessary # type: ignore[attr-defined]


def _get_inner_edges_query() -> str:
Expand Down Expand Up @@ -99,8 +105,8 @@ def _set_inner_edges(self) -> None:
self._dot_graph.add_node(n)
self._dot_graph.add_edge(
pydot.Edge(
pydot.quote_id_if_necessary(str(inner_edge_row["source_step"])),
pydot.quote_id_if_necessary(str(inner_edge_row["target_step"])),
quote_id_if_necessary(str(inner_edge_row["source_step"])),
quote_id_if_necessary(str(inner_edge_row["target_step"])),
)
)

Expand Down Expand Up @@ -130,8 +136,8 @@ def _set_input_edges(self) -> None:
inputs_subgraph.add_node(n)
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"])),
quote_id_if_necessary(str(input_row["input"])),
quote_id_if_necessary(str(input_row["step"])),
)
)

Expand Down Expand Up @@ -161,8 +167,8 @@ def _set_output_edges(self) -> None:
outputs_graph.add_node(n)
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"]),
quote_id_if_necessary(output_edge_row["step"]),
quote_id_if_necessary(output_edge_row["output"]),
)
)

Expand Down
150 changes: 0 additions & 150 deletions mypy-stubs/pydot.pyi

This file was deleted.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ requires = [
"cwl-utils>=0.32",
"toml",
"argcomplete>=1.12.0",
"rich-argparse"
"rich-argparse",
"pydot >= 1.4.1"
]
build-backend = "setuptools.build_meta"

Expand Down
9 changes: 6 additions & 3 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,10 @@ def test_var_spool_cwl_checker3() -> None:
def test_print_dot() -> None:
# print Workflow
cwl_path = get_data("tests/wf/three_step_color.cwl")
expected_dot = pydot.graph_from_dot_data(
"""
expected_dot = cast(
list[pydot.core.Dot],
pydot.graph_from_dot_data(
"""
digraph {{
graph [bgcolor="#eeeeee",
clusterrank=local,
Expand Down Expand Up @@ -1041,10 +1043,11 @@ def test_print_dot() -> None:
"command_line_tool" -> "file_output";
}}
""".format()
),
)[0]
stdout = StringIO()
assert main(["--debug", "--print-dot", cwl_path], stdout=stdout) == 0
computed_dot = pydot.graph_from_dot_data(stdout.getvalue())[0]
computed_dot = cast(list[pydot.core.Dot], pydot.graph_from_dot_data(stdout.getvalue()))[0]
computed_edges = sorted((source, target) for source, target in computed_dot.obj_dict["edges"])
expected_edges = sorted((source, target) for source, target in expected_dot.obj_dict["edges"])
assert computed_edges == expected_edges
Expand Down
Loading