# tools = [reader, recall, readwise, obsidian, librarything, snipd, neoreader, youtube]
# items = [note_item, web_article_item, annotation_item, book_item, youtube_video_item, podcast_item, research_paper_item, document_item]
tools_from_code() informationitems_from_code()
Create graphiz visualisation
graphiz
module.
Helper functions
The function get_items_for_tool
filters all the instances of the class InformationItem based on which information items can be processed by the given tool.
get_info_items_for_tool
get_info_items_for_tool (tool_name:str, info_items:dict[infoflow.classdb.InformationItem ])
Filters all the instances of the class InformationItem based on which information items can be processed by the given tool.
Graphiz visualisation
The function to create the workflow visualisation for the given info_items
and tools
. This is done in two steps. First we use the function create_workflow_viz
that functions as a wrapper around the build_graphiz_from_instances
function.
The create_workflow_viz
has two tasks:
- It makes calling the
build_graphiz_from_instances
function easier by assuming we want to use all instances from theTool
andInformationItem
classes. If we want to use a single instance, we can pass a single instance ofTool
orInformationItem
. If we want several, but not all, instances ofTool
orInformationItem
, we can pass a dict of instances. - It adds the option to filter the graph to be created on a single
Tool
-name. If the parametertool_filter
is used, the function calls theget_info_items_for_tool
function and filters the neededInformationItem
instances based on that tool. This way only those parts of the graph will be drawn that we want to see.
build_graphiz_from_instances
build_graphiz_from_instances (info_items:dict[infoflow.classdb.Informati onItem], tools:dict[infoflow.classdb.Tool])
Create a graphviz visualisation based on the instances of the InformationItem class and their flow through the instances of the Tool class.
create_workflow_viz
create_workflow_viz (items:None|infoflow.classdb.InformationItem|dict[str ,infoflow.classdb.InformationItem]=None, tools:None| infoflow.classdb.Tool|dict[str,infoflow.classdb.Tool ]=None, tool_filter:None|str=None)
Create workflow visualization with flexible filtering options.
An example for creating the actual visualisation for the given info_items
and tools
.
= Tool.get_instances()
tools_inst = InformationItem.get_instances() items_inst
items_inst
{'web_article': InformationItem(name='Web Article', info_type=<InformationType.WEB_ARTICLE: 'web_article'>, method=[<Method.MANUAL: 'manual'>, None, None, None, None], toolflow=[['Reader', 'Recall'], 'Recall', 'Reader', None, None], slug='web_article'),
'annotation': InformationItem(name='Annotation', info_type=<InformationType.ANNOTATION: 'annotations&highlights'>, method=[<Method.AUTOMATIC: 'automatic'>, None, None, None, None], toolflow=[None, None, None, 'Readwise', ['Recall', 'Obsidian']], slug='annotation'),
'note': InformationItem(name='Note', info_type=<InformationType.NOTE: 'note'>, method=[<Method.MANUAL: 'manual'>, None, None, None, None], toolflow=[None, 'Obsidian', 'Obsidian', 'Obsidian', 'Obsidian'], slug='note'),
'book': InformationItem(name='Book', info_type=<InformationType.BOOK: 'book'>, method=[<Method.MANUAL: 'manual'>, None, None, None, None], toolflow=['LibraryThing', 'LibraryThing', 'NeoReader', 'Readwise', 'Obsidian'], slug='book'),
'podcast': InformationItem(name='Podcast', info_type=<InformationType.PODCAST: 'podcast'>, method=[<Method.AUTOMATIC: 'automatic'>, None, None, None, None], toolflow=['Snipd', 'Snipd', 'Snipd', 'Readwise', 'Obsidian'], slug='podcast'),
'research_paper': InformationItem(name='Research Paper', info_type=<InformationType.RESEARCH_PAPER: 'research_paper'>, method=[<Method.MANUAL: 'manual'>, None, None, None, None], toolflow=[['Recall', 'NeoReader'], ['Recall', 'NeoReader'], 'NeoReader', 'Readwise', ['Obsidian', 'Recall']], slug='research_paper'),
'document': InformationItem(name='Document', info_type=<InformationType.DOCUMENT: 'document'>, method=[<Method.MANUAL: 'manual'>, None, None, None, None], toolflow=['NeoReader', 'NeoReader', 'NeoReader', 'Readwise', ['Obsidian', 'Recall']], slug='document'),
'youtube_video': InformationItem(name='YouTube Video', info_type=<InformationType.YOUTUBE_VIDEO: 'youtube_video'>, method=[<Method.AUTOMATIC: 'automatic'>, None, None, None, None], toolflow=['YouTube', 'YouTube', 'YouTube', 'Obsidian', 'Obsidian'], slug='youtube_video')}
= create_workflow_viz(items_inst, tools_inst)
viz type(viz)
graphviz.graphs.Digraph
viz
= create_workflow_viz(items_inst['research_paper'])
viz_document viz_document
= create_workflow_viz(tool_filter='neoreader')
viz_tool viz_tool
To get the SVG
output, you can use the _repr_image_svg_xml
method of the Digraph
object. Below is an example showing the first 200 characters.
200] viz._repr_image_svg_xml()[:
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"\n "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<!-- Generated by graphviz version 2.43.0 (0)'