def convert_to_images(pipeline_path): dot = {} dot['low'] = convert_to_dot(pipeline_path, detail_level=DetailLevel.lowest, show_input_ports=False, show_output_ports=False) dot['medium'] = convert_to_dot(pipeline_path, detail_level=DetailLevel.medium, show_input_ports=False, show_output_ports=False) dot['medium_io'] = convert_to_dot(pipeline_path, detail_level=DetailLevel.medium, show_input_ports=True, show_output_ports=True) dot['high'] = convert_to_dot(pipeline_path, detail_level=DetailLevel.highest, show_input_ports=True, show_output_ports=True) for name, dot_str in dot.items(): try: converter = ImageConverter(dot_str) converter.to_image() except: print('Error while processing "{}" version.'.format(name)) raise
def convert_oozie_to_png(xml_oozie_string, detail_level, show_input_ports, show_output_ports, vertical_orientation, dot_program_path='/usr/bin/dot'): """Convert XML Oozie workflow definition to a PNG image Args: xml_oozie_string (string): Oozie XML detail_level (DetailLevel): level of presentation details show_input_ports (bool): show_output_ports (bool): vertical_orientation (bool): True if the graph should be drawn from top to bottom, False if it should be drawn from left to right. dot_program_path (string): path to the 'dot' program Return: byte string """ dot_string = convert_oozie_to_dot(xml_oozie_string, detail_level, show_input_ports, show_output_ports, vertical_orientation) dot_processor = ImageConverter(dot_string, dot_program_path) image = dot_processor.to_image() return image
def test_convert_incorrect_dot_format_to_image(self): dot_with_port_not_defined_earlier = """ digraph{ "node1":"port1" -> "node2" } """ with pytest.raises(Exception): ImageConverter(dot_with_port_not_defined_earlier).to_image() dot_without_wrapping = """ node1 -> node2 """ with pytest.raises(Exception): ImageConverter(dot_without_wrapping).to_image()