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

"dia" format not supported #273

Open
audreyseo opened this issue Aug 12, 2021 · 1 comment
Open

"dia" format not supported #273

audreyseo opened this issue Aug 12, 2021 · 1 comment

Comments

@audreyseo
Copy link

One of the formats listed in self.formats is dia (code), however, when I tried to use this format, such as in dot.write("my/path", format="dia"), I got the following error:

"dot" with args ['-Tdia', '/var/folders/c6/w4rd131d7r5_yd0w7w_rbdh80000gn/T/tmps_v6_rxl'] returned code: 1

stdout, stderr:
 b''
b'Format: "dia" not recognized. Use one of: bmp canon cgimage cmap cmapx cmapx_np dot dot_json eps exr fig gd gd2 gif gv icns ico imap imap_np ismap jp2 jpe jpeg jpg json json0 mp pct pdf pic pict plain plain-ext png pov ps ps2 psd sgi svg svgz tga tif tiff tk vdx vml vmlz vrml wbmp webp xdot xdot1.2 xdot1.4 xdot_json\n'

Was this an option available with an older version of dot? I also noticed in the code that there is nothing preventing users from using formats other than the ones listed in self.formats, which could be a desirable feature.

I'd be happy to make any changes deemed necessary and submit a pull request.

@peternowee
Copy link
Member

Hmm, yes, I am not seeing dia here in Graphviz 2.40.1 either:

$ dot -V
dot - graphviz version 2.40.1 (20161225.0304)
$ dot -T?
Format: "?" not recognized. Use one of: canon cmap cmapx cmapx_np dot dot_json eps fig gd gd2 gif gv imap imap_np ismap jpe jpeg jpg json json0 mp pdf pic plain plain-ext png pov ps ps2 svg svgz tk vml vmlz vrml wbmp x11 xdot xdot1.2 xdot1.4 xdot_json xlib

Was this an option available with an older version of dot?

According to the Graphviz changelog, support for dia was removed in December 2009 with Graphviz 2.26.0. See also Graphviz issue 689, which mentions some recent commits that removed remaining references to the format.

I also noticed in the code that there is nothing preventing users from using formats other than the ones listed in self.formats, which could be a desirable feature.

Problem is that the output formats of Graphviz obviously vary, and we do not know what formats are supported by the Graphviz version the user is using. Perhaps Graphviz compilation (build-time) options can also influence which formats are available, so it is not just the version number that determines the formats available. On the other hand, we can never have a complete list, because we cannot know yet what formats will be supported in future versions of Graphviz that current versions of pydot may have to work with later. I guess we could try to find some compromise, where we keep including the formats for Graphviz versions of the last 10 years and any new formats that are in development for future versions of Graphviz. Then we could drop dia by now under the assumption that no one is using pydot of >=2021 with Graphviz of <=2009. The Changelog also mentions mif was dropped in 2009. Maybe some new formats were added as well. If you want to update the list of formats, you would first have to check which formats were supported over the years, but if build-time options influence the available formats, then you cannot really depend on old Graphviz binaries for that and might need to look for a complete list somewhere in the source code, I don't know.

Another obvious idea would be to query Graphviz dynamically during pydot initialization, but I do not know if that is really such a great idea. It will be quite a lot of work to implement, maybe slow and error-prone, and will also make user code less portable because they cannot be sure which convenience methods (e.g. write_dia()) will be available (although running into errors in Python already may not be so bad, considering that otherwise an error will be hit when calling Graphviz anyway).

About preventing users from using formats other than the ones listed in formats, I think that the Dot.write() and Dot.create() methods are flexible by design. Especially if Graphviz introduces support for a new format in a future version, current pydot already needs to allow that. I do not know if users really use the pydot formats list much, but it is used internally to generate the convenience methods, like Dot.write_dia(), Dot.write_png(), Dot.create_svg(), etc. Those are basically just front-ends to the Dot.write() and Dot.create() methods, filling in the format parameter.

By the way, if you want to work on this, know that #242 touches on some of the same parts of the code. They will not be in each other's way much, but just know that some rebasing may be involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants