panels.kg_context

KG Context panel: component seeding, subgraph topology, failure modes, events.

Reads the kg_context artifact to render a seed-match bar chart, an interactive Pyvis subgraph (asset, components, failure modes, past events, upstream paths), and filterable tables of failure modes, in-scope documents (with extracted causal statements), and a past-event timeline.

Attributes

JsonDict

Functions

build_component_seed_chart(kg_context)

Build a bar chart of components grouped by seed_match_type.

build_pyvis_html(kg_context[, height_px])

Components, failure modes, optional asset + past events — from kg_context JSON only.

_cached_pyvis_html(kg_json, height_px)

render_kg_panel(kg_context)

Render the KG Context section.

truncate_safe(val, n)

Stringify a value and truncate to n characters with an ellipsis.

Module Contents

panels.kg_context.JsonDict[source]
panels.kg_context.build_component_seed_chart(kg_context)[source]

Build a bar chart of components grouped by seed_match_type.

@ In, kg_context, dict, the kg_context artifact; reads components[]

seed_match_type/component_type

@ Out, fig, plotly.graph_objects.Figure, the chart, or None if no components

Parameters:

kg_context (JsonDict)

Return type:

Optional[Any]

panels.kg_context.build_pyvis_html(kg_context, height_px=480)[source]

Components, failure modes, optional asset + past events — from kg_context JSON only.

Parameters:
Return type:

str

panels.kg_context._cached_pyvis_html(kg_json, height_px)[source]
Parameters:
  • kg_json (str)

  • height_px (int)

Return type:

str

panels.kg_context.render_kg_panel(kg_context)[source]

Render the KG Context section.

@ In, kg_context, dict, the kg_context artifact; reads components,

failure_modes, past_events, documents, upstream_paths, asset_id; None shows an info note

@ Out, None

Parameters:

kg_context (Optional[JsonDict])

Return type:

None

panels.kg_context.truncate_safe(val, n)[source]

Stringify a value and truncate to n characters with an ellipsis.

@ In, val, object, the value to stringify (None becomes “”) @ In, n, int, maximum length of the returned string @ Out, out, str, the (possibly truncated) string

Parameters:
  • val (Any)

  • n (int)

Return type:

str