Skip to content

Commit

Permalink
dag: mermaid: Use quotation marks to escape node name.
Browse files Browse the repository at this point in the history
Fixes #7731
  • Loading branch information
daavoo committed May 24, 2022
1 parent 68b0d61 commit 109d0e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dvc/commands/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _show_mermaid(G, markdown: bool = False):
for node in nodes:
total_nodes += 1
node_id = f"node{total_nodes}"
graph += f"\n\t{node_id}[{node}]"
graph += f'\n\t{node_id}["{node}"]'
node_ids[node] = node_id
edges = sorted((str(a), str(b)) for b, a in pipeline.edges)
for a, b in edges:
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/command/test_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ def test_show_mermaid(repo):
line.rstrip() for line in _show_mermaid(repo.index.graph).splitlines()
] == [
"flowchart TD",
"\tnode1[stage: '1']",
"\tnode2[stage: '2']",
"\tnode3[stage: '3']",
"\tnode4[stage: '4']",
"\tnode5[stage: 'a.dvc']",
"\tnode6[stage: 'b.dvc']",
"\tnode1[\"stage: '1'\"]",
"\tnode2[\"stage: '2'\"]",
"\tnode3[\"stage: '3'\"]",
"\tnode4[\"stage: '4'\"]",
"\tnode5[\"stage: 'a.dvc'\"]",
"\tnode6[\"stage: 'b.dvc'\"]",
"\tnode3-->node4",
"\tnode5-->node1",
"\tnode5-->node3",
Expand All @@ -190,12 +190,12 @@ def test_show_mermaid_markdown(repo, dvc, capsys, mocker):
] == [
"```mermaid",
"flowchart TD",
"\tnode1[stage: '1']",
"\tnode2[stage: '2']",
"\tnode3[stage: '3']",
"\tnode4[stage: '4']",
"\tnode5[stage: 'a.dvc']",
"\tnode6[stage: 'b.dvc']",
"\tnode1[\"stage: '1'\"]",
"\tnode2[\"stage: '2'\"]",
"\tnode3[\"stage: '3'\"]",
"\tnode4[\"stage: '4'\"]",
"\tnode5[\"stage: 'a.dvc'\"]",
"\tnode6[\"stage: 'b.dvc'\"]",
"\tnode3-->node4",
"\tnode5-->node1",
"\tnode5-->node3",
Expand Down

0 comments on commit 109d0e4

Please sign in to comment.