Skip to content

Commit 97a24ba

Browse files
committed
new edits
1 parent 607fe93 commit 97a24ba

File tree

1 file changed

+52
-16
lines changed

1 file changed

+52
-16
lines changed

src/dackar/knowledge_graph/KGconstruction.py

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ def __init__(self, config_file_path, import_folder_path, uri, pwd, processedData
2929

3030
self.graphSchemas = {}
3131

32-
self.equipmentIDs = []
33-
3432
self.predefinedGraphSchemas = {'conditionReportSchema' : 'conditionReportSchema.toml',
3533
'customMbseSchema' : 'customMbseSchema.toml',
3634
'monitoringSystemSchema' : 'monitoringSystemSchema.toml',
@@ -40,12 +38,61 @@ def __init__(self, config_file_path, import_folder_path, uri, pwd, processedData
4038
def resetGraph(self):
4139
self.py2neo.reset()
4240

43-
def importGraphSchemas(filename):
41+
def importGraphSchema(graphSchemaName, TomlFilename):
42+
# Check imported graphSchema against self.graphSchemas
43+
44+
# Add graphSchema to self.graphSchemas
45+
4446
pass
4547

46-
def schemaValidation(self, constructionSchema, graphSchema):
48+
def schemaValidation(self, constructionSchema):
4749
pass
4850

51+
def genericWorkflow(self, data, constructionSchema):
52+
# Check constructionSchema against self.graphSchemas
53+
54+
# Parse data (pd.dataframe?) and update KG
55+
56+
'''
57+
---- Example of construction schema ----
58+
59+
constructionSchema = {'nodes': nodeConstructionSchema,
60+
'edges': edgeConstructionSchema}
61+
62+
nodeConstructionSchema = {'nodeLabel1': {'property1': 'node.colA', 'property2': 'node.colB'},
63+
'nodeLabel2': {'property1': 'node.colC'}}
64+
65+
edgeConstructionSchema = [{'source': ('nodeLabel1.property1','col1'),
66+
'target': ('nodeLabel2.property1','col2'),
67+
'type': 'edgeType',
68+
'properties': {'property1': 'colAlpha', 'property2': 'colBeta'}}]
69+
'''
70+
71+
72+
'''
73+
---- Example of graph schema (toml file) ----
74+
75+
title = "Graph Schema for ..."
76+
version = "1.0"
77+
78+
# Nodes
79+
[node.label1]
80+
description = "This node represents ..."
81+
properties = [{name = "prop1", type = "date", required = bool},
82+
{name = "prop2", type = "string", required = bool},
83+
]
84+
85+
# Relationships
86+
[relationships.relation1]
87+
description = "relation1 indicates ... "
88+
from_entity = entity1
89+
to_entity = entity2
90+
properties = [{name = "prop1", type = "int" , required = bool},
91+
{name = "prop2", type = "float", required = bool},
92+
]
93+
'''
94+
95+
# These are workflows specific to the RIAM project
4996
def mbseWorkflow(self, name, type, nodesFile, edgesFile):
5097
if type =='customMBSE':
5198
mbseModel = customMBSEobject(nodesFile,
@@ -131,18 +178,7 @@ def kgConstructionWorkflow(self, dataframe, graphSchema, constructionSchema):
131178
lr=edge['type'],
132179
pr=edge['properties'])
133180

134-
'''
135-
nodeConstructionSchema = {'nodeLabel1': {'property1': 'node.colA', 'property2': 'node.colB'},
136-
'nodeLabel2': {'property1': 'node.colC'}}
137-
138-
edgeConstructionSchema = [{'source': ('nodeLabel1.property1','col1'),
139-
'target': ('nodeLabel2.property1','col2'),
140-
'type': 'edgeType',
141-
'properties': {'property1': 'colAlpha', 'property2': 'colBeta'}}]
142-
143-
constructionSchema = {'nodes': nodeConstructionSchema,
144-
'edges': edgeConstructionSchema}
145-
'''
181+
146182

147183

148184
'''

0 commit comments

Comments
 (0)