Skip to content

Commit

Permalink
print-dot: Removed primary path prefix from graph labels (#1647)
Browse files Browse the repository at this point in the history
  • Loading branch information
RenskeW authored Mar 29, 2022
1 parent 7b9d7d5 commit 7a058fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cwltool/cwlrdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ def printdot(
stdout: Union[TextIO, StreamWriter],
) -> None:
cwl_viewer = CWLViewer(printrdf(wf, ctx, "n3")) # type: CWLViewer
stdout.write(cwl_viewer.dot())
stdout.write(cwl_viewer.dot().replace(f"{wf.metadata['id']}#", ""))
29 changes: 12 additions & 17 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,6 @@ def test_var_spool_cwl_checker3() -> None:
def test_print_dot() -> None:
# print Workflow
cwl_path = get_data("tests/wf/revsort.cwl")
cwl_posix_path = Path(cwl_path).as_posix()
expected_dot = pydot.graph_from_dot_data(
"""
digraph {{
Expand All @@ -1023,10 +1022,10 @@ def test_print_dot() -> None:
rank=same,
style=dashed
];
"file://{cwl_posix_path}#workflow_input" [fillcolor="#94DDF4",
"workflow_input" [fillcolor="#94DDF4",
label=workflow_input,
style=filled];
"file://{cwl_posix_path}#reverse_sort" [fillcolor="#94DDF4",
"reverse_sort" [fillcolor="#94DDF4",
label=reverse_sort,
style=filled];
}}
Expand All @@ -1036,35 +1035,31 @@ def test_print_dot() -> None:
rank=same,
style=dashed
];
"file://{cwl_posix_path}#sorted_output" [fillcolor="#94DDF4",
"sorted_output" [fillcolor="#94DDF4",
label=sorted_output,
style=filled];
}}
"file://{cwl_posix_path}#rev" [fillcolor=lightgoldenrodyellow,
"rev" [fillcolor=lightgoldenrodyellow,
label=rev,
style=filled];
"file://{cwl_posix_path}#sorted" [fillcolor=lightgoldenrodyellow,
"sorted" [fillcolor=lightgoldenrodyellow,
label=sorted,
style=filled];
"file://{cwl_posix_path}#rev" -> "file://{cwl_posix_path}#sorted";
"file://{cwl_posix_path}#sorted" -> "file://{cwl_posix_path}#sorted_output";
"file://{cwl_posix_path}#workflow_input" -> "file://{cwl_posix_path}#rev";
"file://{cwl_posix_path}#reverse_sort" -> "file://{cwl_posix_path}#sorted";
"rev" -> "sorted";
"sorted" -> "sorted_output";
"workflow_input" -> "rev";
"reverse_sort" -> "sorted";
}}
""".format(
cwl_posix_path=cwl_posix_path
)
""".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_edges = sorted(
(urlparse(source).fragment, urlparse(target).fragment)
for source, target in computed_dot.obj_dict["edges"]
(source, target) for source, target in computed_dot.obj_dict["edges"]
)
expected_edges = sorted(
(urlparse(source).fragment, urlparse(target).fragment)
for source, target in expected_dot.obj_dict["edges"]
(source, target) for source, target in expected_dot.obj_dict["edges"]
)
assert computed_edges == expected_edges

Expand Down

0 comments on commit 7a058fe

Please sign in to comment.