save digraph from notebook

Options
oscieux
oscieux Registered Posts: 3 ✭✭✭

Hi,

From this example,

# Create Digraph object
dot = Digraph()

# Add nodes
dot.node('1')
dot.node('3')
dot.node('2')
dot.node('5')

# Add edges
dot.edges(['12', '13', '35'])

# Visualize the graph
dot

I would like to save this graph on a folder with a svg or png extension.

Thanks

Tagged:

Answers

  • Sarina
    Sarina Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer Posts: 315 Dataiker
    edited July 17
    Options

    Hi @oscieux
    ,

    Thank you for posting your sample code! To save your result to a managed folder, you can do something like this:

    import dataiku
    # for an existing folder named 'graphviz_folder'
    folder = dataiku.Folder('graphviz_folder')
    
    file_path = folder.get_info()['path'] + '/graphviz_filename'
    dot.render(file_path, format='svg')


    Then in your managed folder you'll see:

    Screen Shot 2022-03-18 at 11.03.03 AM.png

    This will work for folders on your local filesystem. Let me know if you have any questions about this.

    Thanks,
    Sarina 

Setup Info
    Tags
      Help me…