def __write_dot(self, target, commands, outs): from dvc.utils.compat import StringIO import networkx from networkx.drawing.nx_pydot import write_dot _, edges, _ = self.__build_graph(target, commands, outs) edges = [edge[::-1] for edge in edges] simple_g = networkx.DiGraph() simple_g.add_edges_from(edges) dot_file = StringIO() write_dot(simple_g, dot_file) logger.info(dot_file.getvalue())
def _walk_exc(self, exc_info): import traceback buffer = StringIO() traceback.print_exception(*exc_info, file=buffer) exc = exc_info[1] tb = buffer.getvalue() exc_list = [str(exc)] tb_list = [tb] # NOTE: parsing chained exceptions. See dvc/exceptions.py for more info while hasattr(exc, "cause") and exc.cause: exc_list.append(str(exc.cause)) if hasattr(exc, "cause_tb") and exc.cause_tb: tb_list.insert(0, str(exc.cause_tb)) exc = exc.cause return exc_list, tb_list
def to_yaml_string(data): stream = StringIO() yaml = YAML() yaml.default_flow_style = False yaml.dump(data, stream) return stream.getvalue()