python-eigen-ingenuity 0.5.29b1__py3-none-any.whl → 0.5.30b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modelbuilder/src/csvcontentsmanager.py +3 -3
- modelbuilder/src/processors/nodefileprocessor.py +14 -2
- modelbuilder/src/processors/relationshipfileprocessor.py +48 -5
- modelbuilder/src/property.py +3 -1
- {python_eigen_ingenuity-0.5.29b1.dist-info → python_eigen_ingenuity-0.5.30b1.dist-info}/METADATA +1 -1
- {python_eigen_ingenuity-0.5.29b1.dist-info → python_eigen_ingenuity-0.5.30b1.dist-info}/RECORD +9 -9
- {python_eigen_ingenuity-0.5.29b1.dist-info → python_eigen_ingenuity-0.5.30b1.dist-info}/WHEEL +0 -0
- {python_eigen_ingenuity-0.5.29b1.dist-info → python_eigen_ingenuity-0.5.30b1.dist-info}/entry_points.txt +0 -0
- {python_eigen_ingenuity-0.5.29b1.dist-info → python_eigen_ingenuity-0.5.30b1.dist-info}/top_level.txt +0 -0
|
@@ -134,7 +134,7 @@ class CSVContentsManager:
|
|
|
134
134
|
def get_property_values_dict(self, row_number, column_numbers, allow_blank_property_list, default_key='', prefix='', blank_override='', allow_split=True):
|
|
135
135
|
this_row = self.data_list[row_number]
|
|
136
136
|
if allow_split:
|
|
137
|
-
split_values = [this_row[column].split('::') for column in column_numbers]
|
|
137
|
+
split_values = [this_row[column].split('::', 2) for column in column_numbers]
|
|
138
138
|
else:
|
|
139
139
|
split_values = [[this_row[column]] for column in column_numbers]
|
|
140
140
|
split_keys = [(value[0] + ':').split(':') for value in split_values]
|
|
@@ -144,10 +144,10 @@ class CSVContentsManager:
|
|
|
144
144
|
def get_property_values_list(self, row_number, column_numbers, default_key='', override_key='', allow_split=True, override_format=None):
|
|
145
145
|
this_row = self.data_list[row_number]
|
|
146
146
|
if allow_split:
|
|
147
|
-
split_values = [this_row[column].split('::') for column in column_numbers]
|
|
147
|
+
split_values = [this_row[column].split('::', 2) for column in column_numbers]
|
|
148
148
|
else:
|
|
149
149
|
split_values = [[this_row[column]] for column in column_numbers]
|
|
150
150
|
split_keys = [(value[0]+':').split(':') for value in split_values]
|
|
151
151
|
these_keys = [override_key or self.mapped_keys[column] if self.types[column] == '' else self.mapped_keys[column] or default_key for column in column_numbers]
|
|
152
|
-
this_list = [Neo4jProperty(these_keys[count], this_row[column], override_format or self.formats[column]) if len(split_values[count]) == 1 else Neo4jProperty(split_values[count][0] or default_key, split_values[count][1], override_format or split_keys[count][1] or self.formats[column]) for count, column in enumerate(column_numbers) if this_row[column]]
|
|
152
|
+
this_list = [Neo4jProperty(these_keys[count], this_row[column], override_format or self.formats[column]) if len(split_values[count]) == 1 else Neo4jProperty(split_values[count][0] or default_key, split_values[count][1], override_format or split_keys[count][1] or self.formats[column], match_labels=(split_values[count][2] if len(split_values[count]) > 2 else '')) for count, column in enumerate(column_numbers) if this_row[column]]
|
|
153
153
|
return this_list
|
|
@@ -50,6 +50,16 @@ class NodeFileProcessor:
|
|
|
50
50
|
last_row = min(num_rows, self.last_row)
|
|
51
51
|
return last_row
|
|
52
52
|
|
|
53
|
+
def get_inline_merge_labels(self, label_string):
|
|
54
|
+
# For node MERGE, only colon-separated labels are directly supported.
|
|
55
|
+
# OR expressions (label1|label2) are ignored here because MERGE cannot express label OR.
|
|
56
|
+
if not label_string:
|
|
57
|
+
return []
|
|
58
|
+
if '|' in label_string:
|
|
59
|
+
messages.warning_message('Unsupported inline node label expression: ', f'{label_string} (ignoring OR labels for MERGE)')
|
|
60
|
+
return []
|
|
61
|
+
return lm.validate_label_string_to_list(label_string)
|
|
62
|
+
|
|
53
63
|
def process_node_file(self):
|
|
54
64
|
|
|
55
65
|
# For each line in the file, build a cypher query to MERGE a node
|
|
@@ -70,7 +80,6 @@ class NodeFileProcessor:
|
|
|
70
80
|
|
|
71
81
|
while this_row < last_row:
|
|
72
82
|
validated_csv_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, label_columns))
|
|
73
|
-
merge_labels, new_labels, remove_labels = lm.sort_node_labels(self.required_labels, validated_csv_labels)
|
|
74
83
|
row_properties = self.contents.get_property_values_dict(this_row, property_columns, self.blank_property_list, blank_override=self.blank_property_override, allow_split=False)
|
|
75
84
|
properties = pm.combine_properties(self.required_properties, row_properties)
|
|
76
85
|
# Remove any properties we don't want
|
|
@@ -82,6 +91,8 @@ class NodeFileProcessor:
|
|
|
82
91
|
|
|
83
92
|
for primary_property in self.contents.get_property_values_list(this_row, node_columns, self.primary_property, allow_split=True, override_format='str'):
|
|
84
93
|
time_now = amu.get_formatted_time_now()
|
|
94
|
+
inline_merge_labels = self.get_inline_merge_labels(primary_property.match_labels)
|
|
95
|
+
merge_labels, new_labels, remove_labels = lm.sort_node_labels(self.required_labels, validated_csv_labels + inline_merge_labels)
|
|
85
96
|
|
|
86
97
|
# Build a simple MERGE query using queries
|
|
87
98
|
query_text = (QueryBuilder()
|
|
@@ -156,10 +167,11 @@ class NodeFileProcessor:
|
|
|
156
167
|
|
|
157
168
|
while this_row < last_row:
|
|
158
169
|
validated_csv_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, label_columns))
|
|
159
|
-
merge_labels, new_labels, remove_labels = lm.sort_node_labels(self.required_labels, validated_csv_labels)
|
|
160
170
|
row_properties = self.contents.get_property_values_dict(this_row, property_columns, self.blank_property_list, blank_override=self.blank_property_override, allow_split=False)
|
|
161
171
|
|
|
162
172
|
for primary_property in self.contents.get_property_values_list(this_row, node_columns, self.primary_property, allow_split=True, override_format='str'):
|
|
173
|
+
inline_merge_labels = self.get_inline_merge_labels(primary_property.match_labels)
|
|
174
|
+
merge_labels, new_labels, remove_labels = lm.sort_node_labels(self.required_labels, validated_csv_labels + inline_merge_labels)
|
|
163
175
|
properties = pm.combine_properties(self.required_properties, row_properties)
|
|
164
176
|
# Remove any properties we don't want
|
|
165
177
|
for unwanted in self.unrequired_properties:
|
|
@@ -58,6 +58,29 @@ class RelationshipFileProcessor:
|
|
|
58
58
|
last_row = min(num_rows, self.last_row)
|
|
59
59
|
return last_row
|
|
60
60
|
|
|
61
|
+
def get_inline_match_labels(self, node_ref, label_string):
|
|
62
|
+
# Supports:
|
|
63
|
+
# label1 -> node_ref:label1
|
|
64
|
+
# label1:label2 -> node_ref:label1 AND node_ref:label2
|
|
65
|
+
# label1|label2 -> node_ref:label1 OR node_ref:label2
|
|
66
|
+
# label1:label2|label3 -> (node_ref:label1 AND node_ref:label2) OR node_ref:label3
|
|
67
|
+
if not label_string:
|
|
68
|
+
return [], ''
|
|
69
|
+
|
|
70
|
+
if '|' not in label_string:
|
|
71
|
+
return lm.validate_label_string_to_list(label_string), ''
|
|
72
|
+
|
|
73
|
+
option_literals = []
|
|
74
|
+
for option in label_string.split('|'):
|
|
75
|
+
these_labels = lm.validate_label_string_to_list(option)
|
|
76
|
+
if these_labels:
|
|
77
|
+
option_literals.append('(' + ' AND '.join([f'{node_ref}:{label}' for label in these_labels]) + ')')
|
|
78
|
+
|
|
79
|
+
if not option_literals:
|
|
80
|
+
return [], ''
|
|
81
|
+
|
|
82
|
+
return [], '(' + ' OR '.join(option_literals) + ')'
|
|
83
|
+
|
|
61
84
|
def process_relationship_file(self):
|
|
62
85
|
|
|
63
86
|
# For each line in the file, build a cypher query to MERGE a relationship
|
|
@@ -97,10 +120,12 @@ class RelationshipFileProcessor:
|
|
|
97
120
|
# If there are multiple From or To nodes, create a relationship query for each combination
|
|
98
121
|
for from_node in self.contents.get_property_values_list(this_row, from_columns, self.primary_property, self.from_property, override_format='str'):
|
|
99
122
|
validated_csv_from_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, from_label_columns))
|
|
100
|
-
|
|
123
|
+
inline_from_labels, inline_from_where = self.get_inline_match_labels(from_ref, from_node.match_labels)
|
|
124
|
+
from_labels = lm.sort_relationship_labels(self.required_labels + self.from_required_labels, validated_csv_from_labels + inline_from_labels)
|
|
101
125
|
for to_node in self.contents.get_property_values_list(this_row, to_columns, self.primary_property, self.to_property, override_format='str'):
|
|
102
126
|
validated_csv_to_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, to_label_columns))
|
|
103
|
-
|
|
127
|
+
inline_to_labels, inline_to_where = self.get_inline_match_labels(to_ref, to_node.match_labels)
|
|
128
|
+
to_labels = lm.sort_relationship_labels(self.required_labels + self.to_required_labels, validated_csv_to_labels + inline_to_labels)
|
|
104
129
|
|
|
105
130
|
# Build a MERGE query for the relationship(s)
|
|
106
131
|
for relationship in relationships:
|
|
@@ -113,6 +138,13 @@ class RelationshipFileProcessor:
|
|
|
113
138
|
.node(labels=from_labels, ref_name=from_ref, properties=from_node)
|
|
114
139
|
.match()
|
|
115
140
|
.node(labels=to_labels, ref_name=to_ref, properties=to_node)
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
where_literals = [i for i in [inline_from_where, inline_to_where] if i]
|
|
144
|
+
if where_literals:
|
|
145
|
+
query_text = query_text.where_literal(' AND '.join(where_literals))
|
|
146
|
+
|
|
147
|
+
query_text = (query_text
|
|
116
148
|
.merge()
|
|
117
149
|
.node(ref_name=from_ref)
|
|
118
150
|
.related_to(label=relation, ref_name=relation_ref)
|
|
@@ -195,10 +227,12 @@ class RelationshipFileProcessor:
|
|
|
195
227
|
# If there are multiple From or To nodes, create a relationship query for each combination
|
|
196
228
|
for from_node in self.contents.get_property_values_list(this_row, from_columns, self.primary_property, self.from_property, override_format='str'):
|
|
197
229
|
validated_csv_from_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, from_label_columns))
|
|
198
|
-
|
|
230
|
+
inline_from_labels, inline_from_where = self.get_inline_match_labels(from_ref, from_node.match_labels)
|
|
231
|
+
from_labels = lm.sort_relationship_labels(self.required_labels + self.from_required_labels, validated_csv_from_labels + inline_from_labels)
|
|
199
232
|
for to_node in self.contents.get_property_values_list(this_row, to_columns, self.primary_property, self.to_property, override_format='str'):
|
|
200
233
|
validated_csv_to_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, to_label_columns))
|
|
201
|
-
|
|
234
|
+
inline_to_labels, inline_to_where = self.get_inline_match_labels(to_ref, to_node.match_labels)
|
|
235
|
+
to_labels = lm.sort_relationship_labels(self.required_labels + self.to_required_labels, validated_csv_to_labels + inline_to_labels)
|
|
202
236
|
|
|
203
237
|
# Build a MERGE query for the relationship(s)
|
|
204
238
|
for relationship in relationships:
|
|
@@ -214,7 +248,7 @@ class RelationshipFileProcessor:
|
|
|
214
248
|
|
|
215
249
|
query_data_list = []
|
|
216
250
|
for count in range(max(len(param_from_nodes), len(param_to_nodes), len(param_explicit_props), len(param_calc_props))):
|
|
217
|
-
new_labels_list = [[from_labels, to_labels, relation, from_node.key, to_node.key, param_calc_props[min(count, len(param_calc_props) - 1)]]]
|
|
251
|
+
new_labels_list = [[from_labels, to_labels, relation, from_node.key, to_node.key, inline_from_where, inline_to_where, param_calc_props[min(count, len(param_calc_props) - 1)]]]
|
|
218
252
|
query_data_list += [[param_from_nodes[min(count, len(param_from_nodes) - 1)].value.replace('\\\\n', '\n'), param_to_nodes[min(count, len(param_to_nodes) - 1)].value.replace('\\\\n', '\n'), param_explicit_props[min(count, len(param_explicit_props) - 1)], param_calc_props[min(count, len(param_calc_props) - 1)], time_now]]
|
|
219
253
|
|
|
220
254
|
# So now we know all about this particular update. Let's put it in the query dictionary
|
|
@@ -245,6 +279,8 @@ class RelationshipFileProcessor:
|
|
|
245
279
|
relationship = batch_keys[from_to_labels][2]
|
|
246
280
|
from_node = batch_keys[from_to_labels][3]
|
|
247
281
|
to_node = batch_keys[from_to_labels][4]
|
|
282
|
+
from_where = batch_keys[from_to_labels][5]
|
|
283
|
+
to_where = batch_keys[from_to_labels][6]
|
|
248
284
|
batch_num = 1
|
|
249
285
|
while batch_num <= num_batches:
|
|
250
286
|
if batch_num == num_batches:
|
|
@@ -285,6 +321,13 @@ class RelationshipFileProcessor:
|
|
|
285
321
|
.node(labels=from_labels, ref_name=from_ref, properties_literal=from_keys)
|
|
286
322
|
.match()
|
|
287
323
|
.node(labels=to_labels, ref_name=to_ref, properties_literal=to_keys)
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
where_literals = [i for i in [from_where, to_where] if i]
|
|
327
|
+
if where_literals:
|
|
328
|
+
query_text = query_text.where_literal(' AND '.join(where_literals))
|
|
329
|
+
|
|
330
|
+
query_text = (query_text
|
|
288
331
|
.merge()
|
|
289
332
|
.node(ref_name=from_ref)
|
|
290
333
|
.related_to(label=relationship, ref_name=relation_ref)
|
modelbuilder/src/property.py
CHANGED
|
@@ -6,7 +6,7 @@ from querymanager import QueryManager
|
|
|
6
6
|
|
|
7
7
|
class Neo4jProperty():
|
|
8
8
|
|
|
9
|
-
def __init__(self, key, value = None, format = None, type = None, blank_override = False):
|
|
9
|
+
def __init__(self, key, value = None, format = None, type = None, blank_override = False, match_labels=''):
|
|
10
10
|
|
|
11
11
|
self.key = pm.validate_property(key)
|
|
12
12
|
# Sanitise the value
|
|
@@ -20,6 +20,8 @@ class Neo4jProperty():
|
|
|
20
20
|
self.format = format
|
|
21
21
|
# type is the kind of thing this is, such as ID, START_ID etc. See assetmodelutilities.py for the full list
|
|
22
22
|
self.type = type
|
|
23
|
+
# Optional inline label selector used when matching nodes from csv values such as key::value::labelA|labelB
|
|
24
|
+
self.match_labels = match_labels
|
|
23
25
|
|
|
24
26
|
# We'll format the value the first time someone wants it, so say it's not formatted yet
|
|
25
27
|
self.formatted_values = {}
|
{python_eigen_ingenuity-0.5.29b1.dist-info → python_eigen_ingenuity-0.5.30b1.dist-info}/RECORD
RENAMED
|
@@ -41,12 +41,12 @@ modelbuilder/src/assetmodelbuilder.py,sha256=92Yu9CvmObPYDdqCpn8eBCaZ_KGBhm307Ys
|
|
|
41
41
|
modelbuilder/src/assetmodelcsvwriter.py,sha256=GKNi_fw7AlY-UG2XhwFIS34Ff3XiVRss-o5MUzyJSV0,1071
|
|
42
42
|
modelbuilder/src/assetmodelutilities.py,sha256=S_q5F7mVulk13zCeC1A8cLkJDXj_BR5_yFi3vTw3xUQ,1746
|
|
43
43
|
modelbuilder/src/configmanager.py,sha256=PbqzYwav6rAm-3Wd8JegYuEEY44iugC_IQ45abUkGbI,30789
|
|
44
|
-
modelbuilder/src/csvcontentsmanager.py,sha256=
|
|
44
|
+
modelbuilder/src/csvcontentsmanager.py,sha256=U5j2kmSWTxPfHURuZPXRk4b2VBLLHMraqjbTZGS9WU8,7923
|
|
45
45
|
modelbuilder/src/csvwriter.py,sha256=2Xc6kdV6cYwCjrVF6WaZfS6tVp8-oc0ksIHSOx6iqj8,14132
|
|
46
46
|
modelbuilder/src/fileanalyser.py,sha256=L7x44NmOaD0spXO9GLAWrGTp-npM8T0xCqCYesMGHgU,4301
|
|
47
47
|
modelbuilder/src/filemanager.py,sha256=nfRQlW-AIp8ICu1CO0MO55OyWMWDQJrW4Z8yRRhBs-k,26454
|
|
48
48
|
modelbuilder/src/messages.py,sha256=6JnW-ke6nHGUA4hTEBvo_kVlNJTXoV4LWw8mNwMpBCQ,1325
|
|
49
|
-
modelbuilder/src/property.py,sha256=
|
|
49
|
+
modelbuilder/src/property.py,sha256=W67yx-vourlFDTsAcSgJOOlb4Q0exZFWf3gbNP2blJI,11615
|
|
50
50
|
modelbuilder/src/querymanager.py,sha256=Wr0LcY7iCwmLyeSx8LcdbQT2xt1viltp6XFvP3Bg5v8,3270
|
|
51
51
|
modelbuilder/src/versionmanager.py,sha256=B8mrYY5Der0sWi1GQjduyVGZ6BuAb6rTNVAZzQlP4k4,19148
|
|
52
52
|
modelbuilder/src/connectors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -57,9 +57,9 @@ modelbuilder/src/connectors/httpsconnector.py,sha256=DOZyxRW3JQcaiaYtnx0_Jq2dBEh
|
|
|
57
57
|
modelbuilder/src/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
58
|
modelbuilder/src/processors/cypherfileprocessor.py,sha256=EmaLsBhC6gWQwvhyY7Ks2HEbGEzDoGAZfu2nBkh2hOs,2941
|
|
59
59
|
modelbuilder/src/processors/labelmanager.py,sha256=b2xkIqMd2hptplm5Sp10zoc7LGOKTVZH2jDKN7brvYU,6619
|
|
60
|
-
modelbuilder/src/processors/nodefileprocessor.py,sha256
|
|
60
|
+
modelbuilder/src/processors/nodefileprocessor.py,sha256=8D93Yy9HsOGMtbOnsodjgqGLGkoI0AC31PdxamnDjqA,15338
|
|
61
61
|
modelbuilder/src/processors/propertymanager.py,sha256=zLr8S0HPZMXeUp1RUzVXWyNa64MxLufXrOqh5uL1mwU,6978
|
|
62
|
-
modelbuilder/src/processors/relationshipfileprocessor.py,sha256=
|
|
62
|
+
modelbuilder/src/processors/relationshipfileprocessor.py,sha256=3rt7dSrncSP3k-cO_LlmidYrtctfX3zgr3_IJLNXq2k,21405
|
|
63
63
|
modelbuilder/src/processors/relationshipmanager.py,sha256=lDtE_5AdKzL3boq7VD8Gmpai8Uscq79vRxkzYQL8A9A,1105
|
|
64
64
|
modelbuilder/src/queries/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
65
65
|
modelbuilder/src/queries/cypherbuilder.py,sha256=VpUGuPo-Ba3skjCVBFjmxm4ORQBGgF5cDiQYnK67hLA,10418
|
|
@@ -88,8 +88,8 @@ regressiontests/eigeningenuity/historian-multi/test_getRawDatapoints.py,sha256=f
|
|
|
88
88
|
regressiontests/eigeningenuity/historian-multi/test_listDataTags.py,sha256=TcceNSjCKoiK5SJcgTH2JXfKLYxIHdQdwZWlkpGnEVM,2006
|
|
89
89
|
regressiontests/eigeningenuity/historian-multi/test_tagManagement.py,sha256=ylInBt453d1RaSih1eTTxGPZmb60UK4vMwI3UW-U1JY,4830
|
|
90
90
|
regressiontests/eigeningenuity/historian-multi/test_writePoints.py,sha256=51tfUSLUqLKcCKJ1EyhjfzoC_4OP6n1oL3zgTSkXu4s,2696
|
|
91
|
-
python_eigen_ingenuity-0.5.
|
|
92
|
-
python_eigen_ingenuity-0.5.
|
|
93
|
-
python_eigen_ingenuity-0.5.
|
|
94
|
-
python_eigen_ingenuity-0.5.
|
|
95
|
-
python_eigen_ingenuity-0.5.
|
|
91
|
+
python_eigen_ingenuity-0.5.30b1.dist-info/METADATA,sha256=3UcrOAM_sycljpwTUxEO6BCHYJjV83ijz7yyE4eMqlM,8124
|
|
92
|
+
python_eigen_ingenuity-0.5.30b1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
93
|
+
python_eigen_ingenuity-0.5.30b1.dist-info/entry_points.txt,sha256=G3LjFQX5xKaN4mqtqCL8uaC-gRbP5T5x9r0gBTJTXXA,70
|
|
94
|
+
python_eigen_ingenuity-0.5.30b1.dist-info/top_level.txt,sha256=oDWOSmlNPKNBlIEKP8_JaV01O60jTcUIt2tDkq3OD18,56
|
|
95
|
+
python_eigen_ingenuity-0.5.30b1.dist-info/RECORD,,
|
{python_eigen_ingenuity-0.5.29b1.dist-info → python_eigen_ingenuity-0.5.30b1.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|