Skip to content

Commit 7a058fe

Browse files
authored
print-dot: Removed primary path prefix from graph labels (#1647)
1 parent 7b9d7d5 commit 7a058fe

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

cwltool/cwlrdf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,4 @@ def printdot(
194194
stdout: Union[TextIO, StreamWriter],
195195
) -> None:
196196
cwl_viewer = CWLViewer(printrdf(wf, ctx, "n3")) # type: CWLViewer
197-
stdout.write(cwl_viewer.dot())
197+
stdout.write(cwl_viewer.dot().replace(f"{wf.metadata['id']}#", ""))

tests/test_examples.py

+12-17
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,6 @@ def test_var_spool_cwl_checker3() -> None:
10091009
def test_print_dot() -> None:
10101010
# print Workflow
10111011
cwl_path = get_data("tests/wf/revsort.cwl")
1012-
cwl_posix_path = Path(cwl_path).as_posix()
10131012
expected_dot = pydot.graph_from_dot_data(
10141013
"""
10151014
digraph {{
@@ -1023,10 +1022,10 @@ def test_print_dot() -> None:
10231022
rank=same,
10241023
style=dashed
10251024
];
1026-
"file://{cwl_posix_path}#workflow_input" [fillcolor="#94DDF4",
1025+
"workflow_input" [fillcolor="#94DDF4",
10271026
label=workflow_input,
10281027
style=filled];
1029-
"file://{cwl_posix_path}#reverse_sort" [fillcolor="#94DDF4",
1028+
"reverse_sort" [fillcolor="#94DDF4",
10301029
label=reverse_sort,
10311030
style=filled];
10321031
}}
@@ -1036,35 +1035,31 @@ def test_print_dot() -> None:
10361035
rank=same,
10371036
style=dashed
10381037
];
1039-
"file://{cwl_posix_path}#sorted_output" [fillcolor="#94DDF4",
1038+
"sorted_output" [fillcolor="#94DDF4",
10401039
label=sorted_output,
10411040
style=filled];
10421041
}}
1043-
"file://{cwl_posix_path}#rev" [fillcolor=lightgoldenrodyellow,
1042+
"rev" [fillcolor=lightgoldenrodyellow,
10441043
label=rev,
10451044
style=filled];
1046-
"file://{cwl_posix_path}#sorted" [fillcolor=lightgoldenrodyellow,
1045+
"sorted" [fillcolor=lightgoldenrodyellow,
10471046
label=sorted,
10481047
style=filled];
1049-
"file://{cwl_posix_path}#rev" -> "file://{cwl_posix_path}#sorted";
1050-
"file://{cwl_posix_path}#sorted" -> "file://{cwl_posix_path}#sorted_output";
1051-
"file://{cwl_posix_path}#workflow_input" -> "file://{cwl_posix_path}#rev";
1052-
"file://{cwl_posix_path}#reverse_sort" -> "file://{cwl_posix_path}#sorted";
1048+
"rev" -> "sorted";
1049+
"sorted" -> "sorted_output";
1050+
"workflow_input" -> "rev";
1051+
"reverse_sort" -> "sorted";
10531052
}}
1054-
""".format(
1055-
cwl_posix_path=cwl_posix_path
1056-
)
1053+
""".format()
10571054
)[0]
10581055
stdout = StringIO()
10591056
assert main(["--debug", "--print-dot", cwl_path], stdout=stdout) == 0
10601057
computed_dot = pydot.graph_from_dot_data(stdout.getvalue())[0]
10611058
computed_edges = sorted(
1062-
(urlparse(source).fragment, urlparse(target).fragment)
1063-
for source, target in computed_dot.obj_dict["edges"]
1059+
(source, target) for source, target in computed_dot.obj_dict["edges"]
10641060
)
10651061
expected_edges = sorted(
1066-
(urlparse(source).fragment, urlparse(target).fragment)
1067-
for source, target in expected_dot.obj_dict["edges"]
1062+
(source, target) for source, target in expected_dot.obj_dict["edges"]
10681063
)
10691064
assert computed_edges == expected_edges
10701065

0 commit comments

Comments
 (0)