Describe the bug
The cylc graph utility generally is interactive & requires relevant GUI application modules, but the --reference option in itself does not. However, the logic is written such that running with the --reference option will go through the standard list of module imports, including of gtk & gobject, terminating if these are not imported successfully:
https://github.com/cylc/cylc-flow/blob/8ac7ae39460cf974ee4a545ff97ddcb1400e023c/bin/cylc-graph#L194-L202
So cylc graph --reference will fail in an environment without GTK, when it should according to inherent requirements work. Indeed, a user has expressed that it would be useful for them to use it without the need for GTK. Enabling it to do so requires only a minor restructure to the bin/cylc-graph code.
Release version(s) and/or repository branch(es) affected?
Not applicable for Cylc 8 & newer versions, where the graphing code has been replaced & GTK is not longer used in the codebase (:tada:).
Steps to reproduce the bug
You should observe by running the relevant command for some 'example-suite':
$ cylc graph --reference <suite-name>
ERROR: no X environment? No module named gtk
(or gobject instead of gtk).
Expected behavior
cylc graph --reference runs as standard in an environment without GTK or Gobject.
Pull requests welcome!
This is an Open Source project - please consider contributing a bug fix
yourself (please read CONTRIBUTING.md before starting any work though).
I just took a quick look at the code. Unfortunately it's not as simple as avoiding the import test above if --reference is specified, because the reference graph is still written out via graph.draw() in the underlying xdot gtk application, which also imports gtk. Probably not too difficult to disintengtangle this if we really needed to, but I'm not sure it's worth the effort (for the reasons you gave on Discourse @sadielbartholomew - cylc 8 etc. Plus I don't see a user need for reference graphs - unlike a graphical representation they are harder to interpret than the suite.rc graph syntax itself).
So maybe we keep this issue to acknowledge the problem, but close it as "won't fix"?
I re-implemented the --reference functionality for Cylc8 independent of pygtk. It's not too much code but really doesn't fit into the Cylc7 cylc-graph framework.
https://github.com/cylc/cylc-flow/pull/2966/commits/5b75c8c73980ef104256d905b1cbfd112536303d
Given the internal nature of the code and the timescale of Cylc8 can we punt this?
I re-implemented the
--referencefunctionality for Cylc8 independent of pygtk. It's not too much code but really doesn't fit into the Cylc7 cylc-graph framework.
I had forgotten about this, and it only took a few minutes to back-port it to Cylc 7 as a new command, so I'll reopen this and put up a PR ... given that there is (at least some) user demand.
馃槙 This should have closed automatically with the merge of #3349, but it hasn't. I'm not sure why not, since that PR uses the standard 'close' syntax, but I'll close this manually.
Thanks for closing this @sadielbartholomew - good spot :+1:
Auto-close only works for PRs to master.