Graph view¶
fs.graph is a GraphView — the fluent read/write surface over the graph. Reads return
handles that wrap the underlying models (Shelf,
Theme, Card) and add navigation methods. See the
exploring-the-graph guide for task-oriented usage.
GraphView¶
.. py:class:: GraphView(chunk_store, graph_store)
- module:
foodscholar.graph_view
Bases: :py:class:
objectFluent read/write surface around the chunk + graph stores.
Exposed as
fs.graphon the facade. Holds no state of its own — every call routes through the underlying stores, so the view stays in lockstep with mutations made directly on the stores or by the phase modules... py:method:: GraphView.shelf(shelf_id)
- module:
foodscholar.graph_view
.. py:method:: GraphView.theme(theme_id)
- module:
foodscholar.graph_view
.. py:method:: GraphView.card(target_id, target_type)
- module:
foodscholar.graph_view
.. py:method:: GraphView.chunk(chunk_id)
- module:
foodscholar.graph_view
.. py:method:: GraphView.shelves(*, facet=None)
- module:
foodscholar.graph_view
.. py:method:: GraphView.themes()
- module:
foodscholar.graph_view
.. py:method:: GraphView.roots()
- module:
foodscholar.graph_view
Shelves with no parent — the top of every facet.
.. py:method:: GraphView.search(query, *, shelf=None, theme=None, k=10)
- module:
foodscholar.graph_view
Hybrid retrieval over the chunk store, optionally scoped to a shelf or theme.
.. py:method:: GraphView.add_shelf(shelf=None, /, **kwargs)
- module:
foodscholar.graph_view
Insert (or upsert) a shelf. Pass a
Shelfmodel or keyword args.
.. py:method:: GraphView.add_shelves(shelves)
- module:
foodscholar.graph_view
.. py:method:: GraphView.add_theme(theme=None, /, **kwargs)
- module:
foodscholar.graph_view
.. py:method:: GraphView.add_themes(themes)
- module:
foodscholar.graph_view
.. py:method:: GraphView.add_card(card=None, /, **kwargs)
- module:
foodscholar.graph_view
.. py:method:: GraphView.add_cards(cards)
- module:
foodscholar.graph_view
.. py:method:: GraphView.attach_chunks(chunks, *, shelf=None, theme=None)
- module:
foodscholar.graph_view
Attach chunks to a shelf or theme.
Updates both the graph edges AND the denormalized
shelf_ids/theme_idson the chunk records, so the chunk store can filter on them at search time. Idempotent — re-running merges sets, doesn’t duplicate.
.. py:method:: GraphView.summary()
- module:
foodscholar.graph_view
Cheap snapshot of graph size — useful for notebook sanity checks.
Handles¶
.. py:class:: ShelfHandle(view, shelf)
- module:
foodscholar.graph_view
Bases: :py:class:
objectRead-side handle around a
Shelfplus navigation methods... py:property:: ShelfHandle.shelf_id
- module:
foodscholar.graph_view
- type:
str
.. py:property:: ShelfHandle.label
- module:
foodscholar.graph_view
- type:
str
.. py:property:: ShelfHandle.facet
- module:
foodscholar.graph_view
- type:
~typing.Literal[‘foods’, ‘health’, ‘sustainability’, ‘dietary_patterns’, ‘allergies’, ‘nutrients’]
.. py:property:: ShelfHandle.depth
- module:
foodscholar.graph_view
- type:
int
.. py:property:: ShelfHandle.foodon_id
- module:
foodscholar.graph_view
- type:
str | None
.. py:property:: ShelfHandle.parent_shelf_id
- module:
foodscholar.graph_view
- type:
str | None
.. py:property:: ShelfHandle.chunk_count
- module:
foodscholar.graph_view
- type:
int
.. py:property:: ShelfHandle.model
- module:
foodscholar.graph_view
- type:
~foodscholar.io.graph.Shelf
Return the underlying Pydantic model (for serialization).
.. py:method:: ShelfHandle.parent()
- module:
foodscholar.graph_view
.. py:method:: ShelfHandle.children()
- module:
foodscholar.graph_view
.. py:method:: ShelfHandle.neighbors(hops=1)
- module:
foodscholar.graph_view
.. py:method:: ShelfHandle.themes()
- module:
foodscholar.graph_view
.. py:method:: ShelfHandle.chunks()
- module:
foodscholar.graph_view
.. py:method:: ShelfHandle.card()
- module:
foodscholar.graph_view
.. py:class:: ThemeHandle(view, theme)
- module:
foodscholar.graph_view
Bases: :py:class:
object.. py:property:: ThemeHandle.theme_id
- module:
foodscholar.graph_view
- type:
str
.. py:property:: ThemeHandle.label
- module:
foodscholar.graph_view
- type:
str
.. py:property:: ThemeHandle.shelf_ids
- module:
foodscholar.graph_view
- type:
list[str]
.. py:property:: ThemeHandle.chunk_count
- module:
foodscholar.graph_view
- type:
int
.. py:property:: ThemeHandle.discovered_by
- module:
foodscholar.graph_view
- type:
str
.. py:property:: ThemeHandle.model
- module:
foodscholar.graph_view
- type:
~foodscholar.io.graph.Theme
.. py:method:: ThemeHandle.shelves()
- module:
foodscholar.graph_view
.. py:method:: ThemeHandle.chunks()
- module:
foodscholar.graph_view
.. py:method:: ThemeHandle.card()
- module:
foodscholar.graph_view
.. py:class:: CardHandle(view, card)
- module:
foodscholar.graph_view
Bases: :py:class:
object.. py:property:: CardHandle.card_id
- module:
foodscholar.graph_view
- type:
str
.. py:property:: CardHandle.target_id
- module:
foodscholar.graph_view
- type:
str
.. py:property:: CardHandle.target_type
- module:
foodscholar.graph_view
- type:
~typing.Literal[‘shelf’, ‘theme’]
.. py:property:: CardHandle.title
- module:
foodscholar.graph_view
- type:
str
.. py:property:: CardHandle.summary
- module:
foodscholar.graph_view
- type:
str
.. py:property:: CardHandle.tip
- module:
foodscholar.graph_view
- type:
str | None
.. py:property:: CardHandle.evidence_quality
- module:
foodscholar.graph_view
- type:
~typing.Literal[‘high’, ‘medium’, ‘low’, ‘debated’, ‘unclear’]
.. py:property:: CardHandle.cited_chunk_ids
- module:
foodscholar.graph_view
- type:
list[str]
.. py:property:: CardHandle.model
- module:
foodscholar.graph_view
- type:
~foodscholar.io.graph.Card
.. py:method:: CardHandle.target()
- module:
foodscholar.graph_view
.. py:method:: CardHandle.cited_chunks()
- module:
foodscholar.graph_view