rez.utils.graph_utils

Functions for manipulating dot-based resolve graphs.

rez.utils.graph_utils.prune_graph(graph_str, package_name)[source]

Prune a package graph so it only contains nodes accessible from the given package.

Parameters
  • graph_str (str) – Dot-language graph string.

  • package_name (str) – Name of package of interest.

Returns

Pruned graph, as a string.

rez.utils.graph_utils.read_graph_from_string(txt)[source]

Read a graph from a string, either in dot format, or our own compressed format.

Returns

Graph object.

Return type

pygraph.digraph

rez.utils.graph_utils.save_graph(graph_str, dest_file, fmt=None, image_ratio=None)[source]

Render a graph to an image file.

Parameters
  • graph_str (str) – Dot-language graph string.

  • dest_file (str) – Filepath to save the graph to.

  • fmt (str) – Format, eg “png”, “jpg”.

  • image_ratio (float) – Image ratio.

Returns

String representing format that was written, such as ‘png’.

rez.utils.graph_utils.save_graph_object(g, dest_file, fmt=None, image_ratio=None)[source]

Like save_graph, but takes a pydot Dot object.

rez.utils.graph_utils.view_graph(graph_str, dest_file=None)[source]

View a dot graph in an image viewer.

rez.utils.graph_utils.write_compacted(g)[source]

Write a graph in our own compacted format.

Returns

str.

rez.utils.graph_utils.write_dot(g)[source]

Replacement for pygraph.readwrite.dot.write, which is dog slow.

Note

This isn’t a general replacement. It will work for the graphs that Rez generates, but there are no guarantees beyond that.

Parameters

g (pygraph.digraph) – Input graph.

Returns

Graph in dot format.

Return type

str