src.dackar.knowledge_graph.kg_ingest_fmea_workflow¶
kg_ingest_fmea_workflow.py ───────────────────────────────────────────────────────────────────────────── Ingest parsed FMEA records (output of fmeaParser.parse_fmea_file) into Neo4j.
Graph objects created per FMEA record ────────────────────────────────────── Nodes:
fmea_case one per unique (fmea_source_ref, sheet) combination failure_mode one per record (keyed by failure_mode_id; merged if duplicate) risk_assessment one per record when at least one of severity/occurrence/detection
is present
effect one per record when local_effect text is present
- Edges:
fmea_case -[:IDENTIFIES_FAILURE_MODE]-> failure_mode failure_mode -[:HAS_RISK_ASSESSMENT]-> risk_assessment failure_mode -[:LEADS_TO_EFFECT]-> effect failure_mode -[:APPLIES_TO]-> element_usage (see below)
Component-type resolution (APPLIES_TO edges)
─────────────────────────────────────────────
FMEA data is class-level: a row for “centrifugal_pump / seal degradation”
applies to every centrifugal pump in the plant. During ingestion the
component_type value is resolved to individual element_usage node IDs by
querying the live KG (mbseSchema v3.1):
MATCH (c:element_usage)-[:instance_of]->(def:element_definition) WHERE toLower(def.domain_category) = toLower($component_type) RETURN c.id AS component_id
An APPLIES_TO edge is created for each matched element_usage. If no
usages are found for a type the failure_mode node is still written (with the
component_type property set) and a warning is logged so the gap can be
addressed when MBSE entities are loaded.
CLI usage ─────────
- python -m dackar.knowledge_graph.kg_ingest_fmea_workflow
–schema src/dackar/knowledge_graph/schemas/fmeaSchema.toml –schema src/dackar/knowledge_graph/schemas/mbseSchema.toml –neo4j-uri bolt://localhost:7687 –neo4j-user neo4j –neo4j-pass secret fmea_pump.xlsx fmea_valve.xlsx
Attributes¶
Functions¶
|
Return all element_usage IDs whose linked element_definition matches component_type. |
|
Extract the shared normalization quality report attached by fmeaParser. |
|
Build a Neo4j graph batch from parsed FMEA records. |
|
Build and ingest a FMEA graph into Neo4j. |
|
CLI entry point. |
Module Contents¶
- src.dackar.knowledge_graph.kg_ingest_fmea_workflow._resolve_component_type(client, component_type, database, cache)[source]¶
Return all element_usage IDs whose linked element_definition matches component_type.
Matches against
element_definition.domain_category(mbseSchema v3.1). Results are cached per component_type string to avoid redundant queries.- Parameters:
client (dackar.knowledge_graph.py2neo.Py2Neo) – Active Neo4j connection.
component_type (str) – Equipment class string (e.g.
"centrifugal_pump").database (Optional[str]) – Neo4j target database;
Noneuses the driver default.cache (Dict[str, List[str]]) – Mutable dict used as an in-process cache across calls.
- Returns:
List of element_usage
idvalues (may be empty).- Return type:
List[str]
- src.dackar.knowledge_graph.kg_ingest_fmea_workflow._extract_fmea_ingestion_quality(fmea_records)[source]¶
Extract the shared normalization quality report attached by fmeaParser.
- Parameters:
fmea_records (Sequence[Dict[str, Any]])
- Return type:
Dict[str, Any]
- src.dackar.knowledge_graph.kg_ingest_fmea_workflow.build_fmea_graph(schema_paths, fmea_records, client=None, database=None)[source]¶
Build a Neo4j graph batch from parsed FMEA records.
Creates
fmea_case,failure_mode,risk_assessment, andeffectnodes with their connecting edges. When client is supplied,APPLIES_TOedges toelement_usagenodes are also created after resolvingcomponent_typeagainst the live KG (mbseSchema v3.1).- Parameters:
schema_paths (Union[str, pathlib.Path, Iterable[Union[str, pathlib.Path]]]) – One or more paths to TOML schema files.
fmea_records (Sequence[Dict[str, Any]]) – Output of
fmeaParser.parse_fmea_file().client (Optional[dackar.knowledge_graph.py2neo.Py2Neo]) – Optional live
Py2Neoconnection used to resolve component types to element_usage IDs. WhenNone, APPLIES_TO edges are omitted.database (Optional[str]) – Neo4j target database;
Noneuses the driver default.
- Returns:
A two-tuple
(nodes, edges)suitable forkg_schema_builder_workflow.ingest_graph_toml().- Return type:
Tuple[List[Dict[str, Any]], List[Dict[str, Any]]]
- src.dackar.knowledge_graph.kg_ingest_fmea_workflow.ingest_fmea_to_neo4j(client, schema_paths, fmea_records, *, database=None, create_constraints=True)[source]¶
Build and ingest a FMEA graph into Neo4j.
- Parameters:
client (dackar.knowledge_graph.py2neo.Py2Neo) – Active
Py2Neoconnection.schema_paths (Union[str, pathlib.Path, Iterable[Union[str, pathlib.Path]]]) – One or more TOML schema file paths.
fmea_records (Sequence[Dict[str, Any]]) – Parsed FMEA records from
fmeaParser.parse_fmea_file().database (Optional[str]) – Target Neo4j database;
Noneuses the driver default.create_constraints (bool) – Apply DDL constraints/indexes before ingestion.
- Returns:
(node_count, edge_count)written to the database.- Return type:
Tuple[int, int]