Submit your inspiring success story or innovative use case to the 2022 Dataiku Frontrunner Awards! ENTER YOUR SUBMISSION

save digraph from notebook

oscieux
Level 1
save digraph from notebook

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

0 Kudos
1 Reply
SarinaS
Dataiker
Dataiker

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 

0 Kudos