Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Strange output (input, cable and output on separate "lines") #258

Closed
TorbjornHouge opened this issue Nov 15, 2021 · 14 comments · Fixed by #261
Closed

[bug] Strange output (input, cable and output on separate "lines") #258

TorbjornHouge opened this issue Nov 15, 2021 · 14 comments · Fixed by #261
Labels
bug Something isn't working

Comments

@TorbjornHouge
Copy link

test1

I am a very new user, but trying to run tutorial examples (and example yml-files), all end up the same, with the input X1, wire W1 and output X2 on separate lines, making them very strange and hard to read compared to the nice versions on Github tutorial.

This happens on all yml-files I have tried, also the last one, but it seems that it consistently places the input on the first row, the wire on second and output on third even when there are several inputs, wires and outputs like it is in the final tutorial example.

@formatc1702
Copy link
Collaborator

formatc1702 commented Nov 15, 2021

That is quite weird! I've never seen something like this myself.

Could you please post

  • The WireViz version / GitHub branch you are using (using the -V CLI flag)
  • Your installed GraphViz version (dot -V)
  • The contents of the .gv file that gets generated along with the image you have posted above?

You can also paste the .gv output on https://edotor.net/ yourself to see if it gets rendered correctly there... If it appears fine, it seems like your local GraphViz installation could be to blame...

@TorbjornHouge
Copy link
Author

Thank you for the reply.

WireViz version 0.3.1 (Installed using pip3 today, running on Python 3.10 installed from Windows 10 store).
GraphViz version 2.49.3 (20211023.0002)

.gv file (renamed to .txt to allow it to be uploaded):
test1.gv.txt
It does, however, look like the png file shown on top when pasting to https://edotor.net/

I am, as you see above, running this on Windows, and I installed today, so I am not surprised if that has something to do with it. Also, Windows store installs python into a somewhat odd location I think, but it doesn't give any errors when running it, so I don't really know.

@formatc1702
Copy link
Collaborator

formatc1702 commented Nov 15, 2021

It looks like a Windows vs. Unix newline issue. Look at the first two/four lines of the .gv file:

graph {
// Graph generated by WireViz 0.3.1// https://github.com/formatc1702/WireViz	graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]

There is a missing newline between the end of the GithUb link, and the graph [] keyword.
Edit: (and another one between version number and URL)

The code should show:

graph {
// Graph generated by WireViz 0.3.1
// https://github.com/formatc1702/WireViz
	graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]

and editing that line in edotor.net fixes the issue.

@formatc1702
Copy link
Collaborator

formatc1702 commented Nov 15, 2021

I generally develop and use WireViz on macOS, but I have successfully been using a custom branch, very similar to v0.3 on Windows 10 using Python 3.8.10 and GraphViz 2.38.0, with no issues.

Please have a look at Harness.py, lines 94 to 97:

    def create_graph(self) -> Graph:
        dot = Graph()
        dot.body.append(f'// Graph generated by {APP_NAME} {__version__}')
        dot.body.append(f'// {APP_URL}')

What happens when you add \n to the end of the two appended strings? Is that enough?
What happens when you add \r\n to simulate a full Windows-style CR+LF?

@TorbjornHouge
Copy link
Author

Thanks, that fixes it.
Looking a bit more, it appears that the crucial part is that "rankdir=LR" gets commented away and without that it looks strange.

@formatc1702
Copy link
Collaborator

Looks like my last comment beat yours by two seconds, so I'm writing again in case you missed it.

@TorbjornHouge
Copy link
Author

Both \n and \r\n gives good results with the same output to png, the only difference I spot is an extra line in the gv file.
Thanks a lot for the help.

@formatc1702
Copy link
Collaborator

formatc1702 commented Nov 15, 2021

No problem.
We'll have to look into who is introducing the issue:

  • Python 3.10 vs 3.8
  • GraphViz 2.49 vs 2.38
  • The graphviz Python module 0.18.2* vs 0.17

My bet is on the last one.

* 0.18.2 is the current version on PyPI so I assume this is what you have installed.

@TorbjornHouge
Copy link
Author

Correct, 0.18.2

@laurierloi
Copy link

laurierloi commented Nov 15, 2021

Had similar issue running in WSL

wireviz: 0.3.1
graphviz: 2.42.2
python graphviz: 0.18.2

If it can be any help

jlecoeur added a commit to jlecoeur/WireViz that referenced this issue Nov 26, 2021
The two header comments were missing an endline.

Closes wireviz#258
@jlecoeur
Copy link
Contributor

I encountered the same issue, solved it in the PR linked above.

@formatc1702
Copy link
Collaborator

formatc1702 commented Nov 27, 2021

I can confirm that this behavior is introduced by v0.18 of the graphviz Python package; where as v0.17 did include the newline automatically.

I considered filing a bug report, but the current documentation seems to indicate that the final newline is intended to be included in the string:

[the body attribute of the Graph or Digraph object] holds the verbatim list of lines to be written to the source file (including their newline).

Thanks @jlecoeur for the corresponging PR.

@kvid
Copy link
Collaborator

kvid commented Aug 14, 2023

I know this issue was fixed in the master branch and therefore closed in 2021. However, multiple duplicate issues has later been reported because the fix is still not included in the dev branch or any of the PR branches. By reopening and pinning this issue (until including the fix in the major development branches), I hope it will be easier to discover, and thereby reduce the amount of duplicate issues.

@kvid kvid reopened this Aug 14, 2023
@kvid kvid changed the title Strange output (input, cable and output on separate "lines") [bug] Strange output (input, cable and output on separate "lines") Aug 14, 2023
@kvid kvid added the bug Something isn't working label Aug 14, 2023
@kvid
Copy link
Collaborator

kvid commented Aug 28, 2023

I cherry-picked the fix for this issue into dev yesterday (see #316 (comment) for details) and when the PR branches get rebased on top of dev again, then they also will contain it.

@kvid kvid unpinned this issue May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants