python-eigen-ingenuity 0.4.35b2__py3-none-any.whl → 0.4.36__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.
- eigeningenuity/assetmodel.py +1 -1
- eigeningenuity/historianmulti.py +2 -2
- eigeningenuity/util.py +1 -1
- modelbuilder/src/assetmodelcsvwriter.py +1 -0
- modelbuilder/src/assetmodelutilities.py +16 -86
- modelbuilder/src/configmanager.py +68 -79
- modelbuilder/src/connectors/httpsconnector.py +11 -13
- modelbuilder/src/csvcontentsmanager.py +84 -38
- modelbuilder/src/csvwriter.py +29 -65
- modelbuilder/src/fileanalyser.py +91 -0
- modelbuilder/src/filemanager.py +40 -29
- modelbuilder/src/processors/__init__.py +0 -0
- modelbuilder/src/processors/cypherfileprocessor.py +73 -0
- modelbuilder/src/processors/labelmanager.py +133 -0
- modelbuilder/src/processors/nodefileprocessor.py +266 -0
- modelbuilder/src/processors/propertymanager.py +87 -0
- modelbuilder/src/processors/relationshipfileprocessor.py +283 -0
- modelbuilder/src/processors/relationshipmanager.py +31 -0
- modelbuilder/src/queries/cypherbuilder.py +3 -15
- modelbuilder/src/queries/typedefs.py +6 -3
- modelbuilder/src/versionmanager.py +13 -11
- {python_eigen_ingenuity-0.4.35b2.dist-info → python_eigen_ingenuity-0.4.36.dist-info}/METADATA +1 -1
- python_eigen_ingenuity-0.4.36.dist-info/RECORD +46 -0
- python_eigen_ingenuity-0.4.35b2.dist-info/RECORD +0 -38
- {python_eigen_ingenuity-0.4.35b2.dist-info → python_eigen_ingenuity-0.4.36.dist-info}/WHEEL +0 -0
- {python_eigen_ingenuity-0.4.35b2.dist-info → python_eigen_ingenuity-0.4.36.dist-info}/entry_points.txt +0 -0
- {python_eigen_ingenuity-0.4.35b2.dist-info → python_eigen_ingenuity-0.4.36.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import messages
|
|
2
|
+
from queries.cypherbuilder import QueryBuilder
|
|
3
|
+
from queries.typedefs import Properties
|
|
4
|
+
import assetmodelutilities as amu
|
|
5
|
+
from queries.query import Neo4jQuery
|
|
6
|
+
import processors.labelmanager as lm
|
|
7
|
+
import processors.relationshipmanager as rm
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RelationshipFileProcessor:
|
|
11
|
+
|
|
12
|
+
def __init__(self, filename, config, contents):
|
|
13
|
+
self.filename = filename
|
|
14
|
+
self.contents = contents
|
|
15
|
+
|
|
16
|
+
self.primary_property = config.get_primary_property()
|
|
17
|
+
self.add_system_properties = not config.get_no_system_properties()
|
|
18
|
+
|
|
19
|
+
self.required_labels = config.get_required_labels()
|
|
20
|
+
self.creation_time_property = config.get_creation_time_property()
|
|
21
|
+
self.update_time_property = config.get_update_time_property()
|
|
22
|
+
|
|
23
|
+
self.from_node_alias = config.get_from_alias()
|
|
24
|
+
self.from_label_alias = config.get_from_label_alias()
|
|
25
|
+
self.to_node_alias = config.get_to_alias()
|
|
26
|
+
self.to_label_alias = config.get_to_label_alias()
|
|
27
|
+
self.relationship_alias = config.get_relationship_alias()
|
|
28
|
+
|
|
29
|
+
self.validate_only = config.in_validation_mode()
|
|
30
|
+
self.summarise = config.in_summary_mode()
|
|
31
|
+
|
|
32
|
+
self.allow_blanks = config.get_allow_blanks()
|
|
33
|
+
self.batch_rate = config.get_batch_rate()
|
|
34
|
+
self.start_from = config.get_start_from()
|
|
35
|
+
self.last_row = config.get_end_at()
|
|
36
|
+
|
|
37
|
+
self.from_types = amu.from_types
|
|
38
|
+
self.to_types = amu.to_types
|
|
39
|
+
self.relation_types = amu.relation_types
|
|
40
|
+
self.all_types = amu.all_types
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_last_row(self, num_rows):
|
|
44
|
+
if self.last_row < 0:
|
|
45
|
+
last_row = num_rows
|
|
46
|
+
else:
|
|
47
|
+
last_row = min(num_rows, self.last_row)
|
|
48
|
+
return last_row
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def process_relationship_file(self):
|
|
52
|
+
|
|
53
|
+
# For each line in the file, build a cypher query to MERGE a relationship
|
|
54
|
+
# Each query is added to a list of queries, which are returned to the caller. They are NOT actioned here
|
|
55
|
+
|
|
56
|
+
num_data_rows = self.contents.get_row_count()
|
|
57
|
+
from_columns = self.contents.get_column_numbers_list(self.from_node_alias, self.from_types)
|
|
58
|
+
from_label_columns = self.contents.get_column_numbers_list(self.from_label_alias)
|
|
59
|
+
to_columns = self.contents.get_column_numbers_list(self.to_node_alias, self.to_types)
|
|
60
|
+
to_label_columns = self.contents.get_column_numbers_list(self.to_label_alias)
|
|
61
|
+
relation_columns = self.contents.get_column_numbers_list(self.relationship_alias, self.relation_types)
|
|
62
|
+
other_columns = self.from_node_alias + self.from_label_alias + self.to_node_alias + self.to_label_alias + self.relationship_alias
|
|
63
|
+
property_columns = self.contents.get_other_column_numbers_list(other_columns, self.all_types)
|
|
64
|
+
|
|
65
|
+
queries = []
|
|
66
|
+
from_ref = 'from'
|
|
67
|
+
relation_ref = 'rel'
|
|
68
|
+
to_ref = 'to'
|
|
69
|
+
relation_ref_dot = relation_ref + '.'
|
|
70
|
+
|
|
71
|
+
num_rows = num_data_rows - self.start_from + 1
|
|
72
|
+
this_row = self.start_from-1
|
|
73
|
+
last_row = self.get_last_row(num_data_rows)
|
|
74
|
+
while this_row < last_row:
|
|
75
|
+
|
|
76
|
+
relationships = rm.validate_relationships(self.contents.get_column_values_list(this_row, relation_columns))
|
|
77
|
+
|
|
78
|
+
properties = self.contents.get_property_values_dict(this_row, property_columns, self.allow_blanks, prefix=relation_ref_dot)
|
|
79
|
+
# If there are multiple From or To nodes, create a relationship query for each combination
|
|
80
|
+
for from_node in self.contents.get_property_values_list(this_row, from_columns, False, self.primary_property, self.primary_property):
|
|
81
|
+
validated_csv_from_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, from_label_columns))
|
|
82
|
+
from_labels = lm.sort_relationship_labels(self.required_labels, validated_csv_from_labels)
|
|
83
|
+
for to_node in self.contents.get_property_values_list(this_row, to_columns, False, self.primary_property, self.primary_property):
|
|
84
|
+
validated_csv_to_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, to_label_columns))
|
|
85
|
+
to_labels = lm.sort_relationship_labels(self.required_labels, validated_csv_to_labels)
|
|
86
|
+
|
|
87
|
+
# We need to create sets of updates that have the same label combinations, and relationship
|
|
88
|
+
|
|
89
|
+
# Build a MERGE query for the relationship(s)
|
|
90
|
+
for relationship in relationships:
|
|
91
|
+
for relation in relationship.split(':'):
|
|
92
|
+
if relation:
|
|
93
|
+
|
|
94
|
+
time_now = amu.get_formatted_time_now()
|
|
95
|
+
query_text = (QueryBuilder()
|
|
96
|
+
.match()
|
|
97
|
+
.node(labels=from_labels, ref_name=from_ref, properties=Properties(from_node))
|
|
98
|
+
.match()
|
|
99
|
+
.node(labels=to_labels, ref_name=to_ref, properties=Properties(to_node))
|
|
100
|
+
.merge()
|
|
101
|
+
.node(ref_name=from_ref)
|
|
102
|
+
.related_to(label=relation, ref_name=relation_ref)
|
|
103
|
+
.node(ref_name=to_ref)
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Add in System properties
|
|
107
|
+
if self.add_system_properties:
|
|
108
|
+
create_time = relation_ref_dot + self.creation_time_property + '=datetime("' + time_now + '")'
|
|
109
|
+
update_time = relation_ref_dot + self.update_time_property + '=datetime("' + time_now + '")'
|
|
110
|
+
query_text = query_text.on_create().set_literal(create_time).set_literal(update_time)
|
|
111
|
+
|
|
112
|
+
if len(properties) > 0:
|
|
113
|
+
query_text = query_text.set(properties=properties)
|
|
114
|
+
query_text = query_text.toStr()
|
|
115
|
+
query = Neo4jQuery('relationship', query_text, time_now)
|
|
116
|
+
|
|
117
|
+
if self.validate_only and not self.summarise:
|
|
118
|
+
print(query.text)
|
|
119
|
+
|
|
120
|
+
queries.append(query)
|
|
121
|
+
|
|
122
|
+
this_row += 1
|
|
123
|
+
messages.message_no_cr(f'Generating queries... {100 * (this_row - self.start_from + 1) / num_rows:.0f}%{chr(13)}')
|
|
124
|
+
|
|
125
|
+
messages.message('', False)
|
|
126
|
+
return queries
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def process_relationship_file_batch(self):
|
|
130
|
+
|
|
131
|
+
# For each line in the file, build a cypher query to MERGE a relationship
|
|
132
|
+
# Each query is added to a list of queries, which are returned to the caller. They are NOT actioned here
|
|
133
|
+
|
|
134
|
+
num_data_rows = self.contents.get_row_count()
|
|
135
|
+
from_columns = self.contents.get_column_numbers_list(self.from_node_alias, self.from_types)
|
|
136
|
+
from_label_columns = self.contents.get_column_numbers_list(self.from_label_alias)
|
|
137
|
+
to_columns = self.contents.get_column_numbers_list(self.to_node_alias, self.to_types)
|
|
138
|
+
to_label_columns = self.contents.get_column_numbers_list(self.to_label_alias)
|
|
139
|
+
relation_columns = self.contents.get_column_numbers_list(self.relationship_alias, self.relation_types)
|
|
140
|
+
other_columns = self.from_node_alias + self.from_label_alias + self.to_node_alias + self.to_label_alias + self.relationship_alias
|
|
141
|
+
property_columns = self.contents.get_other_column_numbers_list(other_columns, self.all_types)
|
|
142
|
+
|
|
143
|
+
queries = []
|
|
144
|
+
from_ref = 'from'
|
|
145
|
+
relation_ref = 'rel'
|
|
146
|
+
to_ref = 'to'
|
|
147
|
+
relation_ref_dot = relation_ref + '.'
|
|
148
|
+
payload_ref = 'payload'
|
|
149
|
+
payload_ref_dot = payload_ref + '.'
|
|
150
|
+
|
|
151
|
+
time_now = amu.get_formatted_time_now()
|
|
152
|
+
|
|
153
|
+
# For best optimisation, we need to create a batch query for all the update with the same labels
|
|
154
|
+
# So we will create a dictionary of queries based on the labels and relationships for each query
|
|
155
|
+
# Since the dictionary key can't be a list, we will create a list (of lists) and use the index in that list as the key
|
|
156
|
+
# When we have worked through all the input and grouped the queries by label and relationship combinations, we will create the queries
|
|
157
|
+
|
|
158
|
+
batch_keys = []
|
|
159
|
+
query_dictionary = {}
|
|
160
|
+
dict_size = 0
|
|
161
|
+
|
|
162
|
+
num_rows = num_data_rows - self.start_from + 1
|
|
163
|
+
this_row = self.start_from-1
|
|
164
|
+
last_row = self.get_last_row(num_data_rows)
|
|
165
|
+
while this_row < last_row:
|
|
166
|
+
relationships = rm.validate_relationships(self.contents.get_column_values_list(this_row, relation_columns))
|
|
167
|
+
properties = self.contents.get_property_values_dict(this_row, property_columns, self.allow_blanks)
|
|
168
|
+
# If there are multiple From or To nodes, create a relationship query for each combination
|
|
169
|
+
for from_node in self.contents.get_property_values_list(this_row, from_columns, False, self.primary_property, self.primary_property):
|
|
170
|
+
validated_csv_from_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, from_label_columns))
|
|
171
|
+
from_labels = lm.sort_relationship_labels(self.required_labels, validated_csv_from_labels)
|
|
172
|
+
for to_node in self.contents.get_property_values_list(this_row, to_columns, False, self.primary_property, self.primary_property):
|
|
173
|
+
validated_csv_to_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, to_label_columns))
|
|
174
|
+
to_labels = lm.sort_relationship_labels(self.required_labels, validated_csv_to_labels)
|
|
175
|
+
|
|
176
|
+
# Build a MERGE query for the relationship(s)
|
|
177
|
+
for relationship in relationships:
|
|
178
|
+
for relation in relationship.split(':'):
|
|
179
|
+
if relation:
|
|
180
|
+
|
|
181
|
+
new_labels = [from_labels, to_labels, relation, list(from_node)[0], list(to_node)[0]]
|
|
182
|
+
query_data = [list(from_node.values())[0], list(to_node.values())[0], properties, time_now]
|
|
183
|
+
|
|
184
|
+
# So now we know all about this particular update. Let's put it in the query dictionary
|
|
185
|
+
try:
|
|
186
|
+
dictionary_index = batch_keys.index(new_labels)
|
|
187
|
+
query_dictionary[dictionary_index].append(query_data)
|
|
188
|
+
except:
|
|
189
|
+
dictionary_index = len(batch_keys)
|
|
190
|
+
query_dictionary[dictionary_index] = [query_data]
|
|
191
|
+
batch_keys.append(new_labels)
|
|
192
|
+
dict_size += 1
|
|
193
|
+
|
|
194
|
+
this_row += 1
|
|
195
|
+
messages.message_no_cr(f'Analysing file... {100 * (this_row - self.start_from + 1) / num_rows:.0f}%{chr(13)}')
|
|
196
|
+
|
|
197
|
+
messages.message('', False)
|
|
198
|
+
|
|
199
|
+
# Right, so now we have a dictionary of updates grouped by labels. Let's create the queries
|
|
200
|
+
query_count = 0
|
|
201
|
+
for from_to_labels, updates in query_dictionary.items():
|
|
202
|
+
num_updates_for_this_label = len(updates)
|
|
203
|
+
num_batches = int((num_updates_for_this_label - 1) / self.batch_rate) + 1
|
|
204
|
+
from_labels = batch_keys[from_to_labels][0]
|
|
205
|
+
to_labels = batch_keys[from_to_labels][1]
|
|
206
|
+
relationship = batch_keys[from_to_labels][2]
|
|
207
|
+
from_key = batch_keys[from_to_labels][3]
|
|
208
|
+
to_key = batch_keys[from_to_labels][4]
|
|
209
|
+
|
|
210
|
+
batch_num = 1
|
|
211
|
+
while batch_num <= num_batches:
|
|
212
|
+
if batch_num == num_batches:
|
|
213
|
+
# Last batch, so
|
|
214
|
+
batch_size = 1 + (num_updates_for_this_label - 1) % self.batch_rate
|
|
215
|
+
else:
|
|
216
|
+
batch_size = self.batch_rate
|
|
217
|
+
|
|
218
|
+
this_size = 0
|
|
219
|
+
payload = []
|
|
220
|
+
while this_size < batch_size:
|
|
221
|
+
# Combine all the update data...
|
|
222
|
+
update = updates[(batch_num - 1) * self.batch_rate + this_size]
|
|
223
|
+
update_properties = update[2] or {} # In case update_properties[2] is {}
|
|
224
|
+
update_properties[from_ref] = update[0]
|
|
225
|
+
update_properties[to_ref] = update[1]
|
|
226
|
+
if self.add_system_properties:
|
|
227
|
+
update_properties[self.update_time_property] = update[3]
|
|
228
|
+
payload.append(update_properties)
|
|
229
|
+
this_size += 1
|
|
230
|
+
query_count += 1
|
|
231
|
+
|
|
232
|
+
formatted_payload = []
|
|
233
|
+
for a_payload in payload:
|
|
234
|
+
formatted_payload.append(Properties(a_payload).format())
|
|
235
|
+
|
|
236
|
+
# Build a MERGE query using queries
|
|
237
|
+
from_keys = " {" + from_key + ":" + payload_ref_dot + from_ref + "}"
|
|
238
|
+
to_keys = " {" + to_key + ":" + payload_ref_dot + to_ref + "}"
|
|
239
|
+
create_time = relation_ref_dot + self.creation_time_property + '=datetime("' + time_now + '")'
|
|
240
|
+
update_time = relation_ref_dot + self.update_time_property + '=datetime("' + time_now + '")'
|
|
241
|
+
|
|
242
|
+
query_text = (QueryBuilder()
|
|
243
|
+
.unwind_list_as(formatted_payload, payload_ref)
|
|
244
|
+
.match()
|
|
245
|
+
.node(labels=from_labels, ref_name=from_ref, properties_literal=from_keys)
|
|
246
|
+
.match()
|
|
247
|
+
.node(labels=to_labels, ref_name=to_ref, properties_literal=to_keys)
|
|
248
|
+
.merge()
|
|
249
|
+
.node(ref_name=from_ref)
|
|
250
|
+
.related_to(label=relationship, ref_name=relation_ref)
|
|
251
|
+
.node(ref_name=to_ref)
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
if self.add_system_properties:
|
|
255
|
+
query_text = query_text.on_create().set_literal(create_time)
|
|
256
|
+
|
|
257
|
+
query_text = query_text.set_literal(relation_ref + ' += ' + payload_ref)
|
|
258
|
+
|
|
259
|
+
if self.add_system_properties:
|
|
260
|
+
query_text = query_text.set_literal(update_time)
|
|
261
|
+
|
|
262
|
+
query_text = query_text.remove_literal(relation_ref_dot + from_ref + ', ' + relation_ref_dot + to_ref)
|
|
263
|
+
query_text = query_text.toStr()
|
|
264
|
+
|
|
265
|
+
query = Neo4jQuery('batch relationship', query_text, time_now, batch_size=this_size)
|
|
266
|
+
|
|
267
|
+
if self.validate_only and not self.summarise:
|
|
268
|
+
print(query.text)
|
|
269
|
+
|
|
270
|
+
queries.append(query)
|
|
271
|
+
messages.message_no_cr(f'Generating queries... {100 * query_count / dict_size:.0f}%{chr(13)}')
|
|
272
|
+
|
|
273
|
+
batch_num += 1
|
|
274
|
+
|
|
275
|
+
messages.message('', False)
|
|
276
|
+
return queries
|
|
277
|
+
|
|
278
|
+
def get_filename(self):
|
|
279
|
+
return self.filename
|
|
280
|
+
|
|
281
|
+
def is_inline_query(self):
|
|
282
|
+
return False
|
|
283
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import assetmodelutilities as amu
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def validate_relationship_string(relationship_string):
|
|
5
|
+
# The input string can be comma or colon separated.
|
|
6
|
+
# We will return a string of colon separated relationships
|
|
7
|
+
# Labels that do not conform to Neo4j naming rules will be back-ticked (`)
|
|
8
|
+
# For example:
|
|
9
|
+
# fruit --> fruit
|
|
10
|
+
# apple,tree --> apple:tree
|
|
11
|
+
# birds&bees --> `birds&bees`
|
|
12
|
+
# one,two,!three --> one:two:`!three`
|
|
13
|
+
|
|
14
|
+
result = ''
|
|
15
|
+
for a_relationship in relationship_string.replace(",", ":").split(':'):
|
|
16
|
+
result += ':' + amu.validate(a_relationship)
|
|
17
|
+
|
|
18
|
+
# Remove the leading ':' from the result because we don't want it
|
|
19
|
+
if result.startswith(':'):
|
|
20
|
+
result = result[1:]
|
|
21
|
+
|
|
22
|
+
return result
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def validate_relationships(relationships):
|
|
26
|
+
# We either get a string, or a list of strings.
|
|
27
|
+
# Process as appropriate and return a string or list of strings to match input
|
|
28
|
+
if isinstance(relationships, str):
|
|
29
|
+
return validate_relationship_string(relationships)
|
|
30
|
+
else:
|
|
31
|
+
return [validate_relationship_string(i) for i in relationships]
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
# Query Builder based on Cymple's OpenSource code
|
|
2
2
|
from typing import List
|
|
3
3
|
from queries.typedefs import Mapping, Properties
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
#def validate_labels(label_string):
|
|
7
|
-
# label_list = label_string.split(':')
|
|
8
|
-
# validated = ''
|
|
9
|
-
# for label in label_list:
|
|
10
|
-
# if label:
|
|
11
|
-
# if ''.join(re.findall("[A-Za-z0-9_]", label)) != label:
|
|
12
|
-
# validated += f':`{label}`'
|
|
13
|
-
# else:
|
|
14
|
-
# validated += f':{label}'
|
|
15
|
-
#
|
|
16
|
-
# return validated
|
|
17
|
-
#
|
|
4
|
+
|
|
5
|
+
|
|
18
6
|
class Query():
|
|
19
7
|
|
|
20
8
|
def __init__(self, query):
|
|
@@ -106,7 +94,7 @@ class Node(Query):
|
|
|
106
94
|
if not properties:
|
|
107
95
|
property_string = ''
|
|
108
96
|
else:
|
|
109
|
-
property_string = f' {{{
|
|
97
|
+
property_string = f' {{{Properties(properties)}}}'
|
|
110
98
|
|
|
111
99
|
ref_name = ref_name or ''
|
|
112
100
|
|
|
@@ -11,7 +11,6 @@ class Properties(dict):
|
|
|
11
11
|
|
|
12
12
|
@staticmethod
|
|
13
13
|
def _escape(string: str) -> str:
|
|
14
|
-
# res = string.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'").replace('\r', '\\r').replace('\n', '\\n')
|
|
15
14
|
res = string.replace('\\', '\\\\').replace('\r', '\\r').replace('\n', '\\n').replace('"', '\\"')
|
|
16
15
|
return res
|
|
17
16
|
|
|
@@ -41,6 +40,9 @@ class Properties(dict):
|
|
|
41
40
|
case 'str':
|
|
42
41
|
result = quote + escaped_value + quote
|
|
43
42
|
case 'int':
|
|
43
|
+
# Remove any leading zeroes because the literal_eval function does not support them
|
|
44
|
+
while escaped_value.startswith('0'):
|
|
45
|
+
escaped_value = escaped_value[1:]
|
|
44
46
|
result = int(ast.literal_eval(escaped_value))
|
|
45
47
|
if result != ast.literal_eval(escaped_value):
|
|
46
48
|
messages.warning_message('Invalid data: ', f'{ast.literal_eval(escaped_value)} is not a valid Integer, {result} used instead')
|
|
@@ -59,9 +61,10 @@ class Properties(dict):
|
|
|
59
61
|
messages.error_message(f'Invalid data: {value} is not a valid date so value not set')
|
|
60
62
|
result = ''
|
|
61
63
|
case _:
|
|
62
|
-
|
|
64
|
+
# Treat unsupported formats as strings
|
|
65
|
+
result = quote + escaped_value + quote
|
|
63
66
|
except:
|
|
64
|
-
messages.error_message('Invalid data: ', f'{value} is not valid for type {given_data_type} so value not set')
|
|
67
|
+
messages.error_message('Invalid data: ', f'{value} is not valid for type {given_data_type} so value not set!')
|
|
65
68
|
result = ''
|
|
66
69
|
else:
|
|
67
70
|
try:
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
from queries.cypherbuilder import QueryBuilder
|
|
2
2
|
from queries.typedefs import Mapping, Properties
|
|
3
3
|
from queries.query import *
|
|
4
|
-
import assetmodelutilities
|
|
4
|
+
import assetmodelutilities as amu
|
|
5
|
+
import processors.labelmanager as lm
|
|
6
|
+
import processors.propertymanager as pm
|
|
7
|
+
import processors.relationshipmanager as rm
|
|
5
8
|
import uuid
|
|
6
9
|
|
|
7
10
|
class VersionManager:
|
|
8
11
|
|
|
9
12
|
def __init__(self, config_manager):
|
|
10
|
-
self.frozen_labels_list = config_manager.get_frozen_labels_list()
|
|
11
|
-
self.version_labels_list = config_manager.get_version_labels_list()
|
|
13
|
+
self.frozen_labels_list = lm.validate_labels(config_manager.get_frozen_labels_list())
|
|
14
|
+
self.version_labels_list = lm.validate_labels(config_manager.get_version_labels_list())
|
|
12
15
|
self.version_prefix = config_manager.get_version_prefix()
|
|
13
16
|
self.version_counter = config_manager.get_version_counter()
|
|
14
17
|
self.version_number = config_manager.get_version_number()
|
|
15
18
|
self.first_version_property = config_manager.get_first_version_property()
|
|
16
19
|
self.last_version_property = config_manager.get_last_version_property()
|
|
17
|
-
self.version_relationship = config_manager.get_version_relationship()
|
|
18
|
-
self.next_version_relationship = config_manager.get_next_version_relationship()
|
|
20
|
+
self.version_relationship = rm.validate_relationship_string(config_manager.get_version_relationship())
|
|
21
|
+
self.next_version_relationship = rm.validate_relationship_string(config_manager.get_next_version_relationship())
|
|
19
22
|
|
|
20
23
|
self.skip_duplicates = config_manager.get_skip_duplicates()
|
|
21
24
|
|
|
@@ -36,7 +39,7 @@ class VersionManager:
|
|
|
36
39
|
self.version_node_labels = [i for i in self.version_labels_list if (not ('!' + i in self.version_labels_list) and not (i.startswith('!')) and i != '')]
|
|
37
40
|
|
|
38
41
|
# Future time is no longer needed
|
|
39
|
-
# self.future =
|
|
42
|
+
# self.future = amu.get_formatted_future_time()
|
|
40
43
|
|
|
41
44
|
self.version_updates = None
|
|
42
45
|
|
|
@@ -50,7 +53,7 @@ class VersionManager:
|
|
|
50
53
|
if original_label in self.frozen_labels_list + self.required_labels:
|
|
51
54
|
version_labels.append(original_label)
|
|
52
55
|
elif '!' + original_label not in self.version_labels_list:
|
|
53
|
-
version_labels.append(self.version_prefix + original_label)
|
|
56
|
+
version_labels.append(lm.validate_label_string(self.version_prefix + original_label))
|
|
54
57
|
else:
|
|
55
58
|
pass
|
|
56
59
|
|
|
@@ -118,7 +121,7 @@ class VersionManager:
|
|
|
118
121
|
for key, value in original_node[self.property_label].items():
|
|
119
122
|
# Force anything that is currently a string to remain a string
|
|
120
123
|
# Without this, strings that look like numbers will be converted to ints (or floats)
|
|
121
|
-
key =
|
|
124
|
+
key = pm.validate_property(key)
|
|
122
125
|
if isinstance(value, str):
|
|
123
126
|
properties[key+':str'] = value
|
|
124
127
|
else:
|
|
@@ -201,7 +204,7 @@ class VersionManager:
|
|
|
201
204
|
try:
|
|
202
205
|
current_node_id = current_node_response[0][self.property_label][self.id_label]
|
|
203
206
|
except:
|
|
204
|
-
# Current node doesn't have the required
|
|
207
|
+
# Current node doesn't have the required node_key, so let's create and execute a query to add it
|
|
205
208
|
current_node_id = str(uuid.uuid4())
|
|
206
209
|
id_property_query = self.build_query_to_add_id_property(query, current_node_id)
|
|
207
210
|
db_connector.execute(id_property_query)
|
|
@@ -226,7 +229,6 @@ class VersionManager:
|
|
|
226
229
|
self.version_updates.combine_results(version_node_return)
|
|
227
230
|
version_node_id = version_node_response[self.id_label]
|
|
228
231
|
|
|
229
|
-
# print(current_node_id, last_version_node_id, version_node_id)
|
|
230
232
|
return current_node_id, last_version_node_id, version_node_id
|
|
231
233
|
|
|
232
234
|
def update_version_numbers(self, current_node, last_version_node, version_node, db_connector):
|
|
@@ -246,7 +248,7 @@ class VersionManager:
|
|
|
246
248
|
).toStr()
|
|
247
249
|
|
|
248
250
|
version_query = Neo4jQuery('get version counter', query_text)
|
|
249
|
-
# This should always return a result because the query will add the
|
|
251
|
+
# This should always return a result because the query will add the node_key if it was missing
|
|
250
252
|
# TODO: ...unless the db connection goes down
|
|
251
253
|
count_response = db_connector.execute(version_query)
|
|
252
254
|
self.version_updates.combine_results(count_response)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
eigeningenuity/__init__.py,sha256=wiP9sP_ibX_oufhkGLXiTLze3fF17CUIHVo1hymdO2U,1500
|
|
2
|
+
eigeningenuity/assetmodel.py,sha256=gpimrnPOhrUCRPmi223eeZ9d5jlYP5JkMQQNJElZuX4,16785
|
|
3
|
+
eigeningenuity/auth.py,sha256=3efTRyiKoKXCYt3F2lZ9KVF82Gw-BfFLC8y9lo8690I,6560
|
|
4
|
+
eigeningenuity/elastic.py,sha256=WG4nlsJXNs_-m76jtj46UfgvLgWLvn6d6QW2dk7LBI4,6648
|
|
5
|
+
eigeningenuity/events.py,sha256=wUc1TkT7047gduNuNfzkSO5tK13ErJdeI2K5cPXhNCY,3336
|
|
6
|
+
eigeningenuity/historian.py,sha256=YGAwaSMSdDAB_czQUCE0POxzYkU5ywsIrhl_abGl7rk,36341
|
|
7
|
+
eigeningenuity/historianmulti.py,sha256=pg4DxpzQTa7P03X5NsVH3IMHXrlzPv-jD-rsf9cC63E,30474
|
|
8
|
+
eigeningenuity/settings.py,sha256=ImYplpNINf1dYaUdarZaxvwf3zHSjE1CG7bOEUqnLT0,2794
|
|
9
|
+
eigeningenuity/smartdash.py,sha256=spzoRXO4tu7cDAd4cwbyxo9RBnYvjbJoXQq8zbXkMEw,3009
|
|
10
|
+
eigeningenuity/sql.py,sha256=y-IMu1fdZjMGFcg7ue7Ubhr0-BDTiUW01x8I7tSR700,5059
|
|
11
|
+
eigeningenuity/util.py,sha256=P-WvDaIkb7OpEADQYCQJWY92wQimMu9u_GHpDZDyC-g,14872
|
|
12
|
+
eigeningenuity/core/__init__.py,sha256=u3wAldyaivF-E2HzMftBNFPWUGNf0ZxGmdMUY6Em6nA,8439
|
|
13
|
+
modelbuilder/__init__.py,sha256=HSsHItu5BbGQiHYTG00QPMNDbC3RkRUaaN50YpksIUA,171
|
|
14
|
+
modelbuilder/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
modelbuilder/src/assetmodelbuilder.py,sha256=Gii5mU5z8spk1d53_veD4rlgaXL3xtev6OFjYWKDCqU,8078
|
|
16
|
+
modelbuilder/src/assetmodelcsvwriter.py,sha256=GKNi_fw7AlY-UG2XhwFIS34Ff3XiVRss-o5MUzyJSV0,1071
|
|
17
|
+
modelbuilder/src/assetmodelutilities.py,sha256=KwyP8-2EfpRHKmGasPJLV74EGYBjSHgxHBAy8xuvh6k,1743
|
|
18
|
+
modelbuilder/src/configmanager.py,sha256=LwIGf87so4VeYhIEJ3WVEEj834QCq0svDs2gcyGowuI,22948
|
|
19
|
+
modelbuilder/src/csvcontentsmanager.py,sha256=6IIzmCz6zEhpm0gZm-3Nr9_ASKrNo70xJoqn7EJPMD0,6491
|
|
20
|
+
modelbuilder/src/csvwriter.py,sha256=m2XVbyZq3Gq2bb36HqvOFuTuet1fi1nRPURL6yEtfjI,14051
|
|
21
|
+
modelbuilder/src/fileanalyser.py,sha256=LUWrqogjBXsXHV-maoEOmu6FKuu7JmvNZJZMlFhbKQA,3627
|
|
22
|
+
modelbuilder/src/filemanager.py,sha256=h8BHOEWA94jvDw8WCiGbXwhRDm2FvycJgoTyO1gTi88,18834
|
|
23
|
+
modelbuilder/src/fileprocessors.py,sha256=-ZoaqsnlOA4Rh_unF3L-TE6RqCgYHheGd_FQRSa-DRc,35692
|
|
24
|
+
modelbuilder/src/messages.py,sha256=6JnW-ke6nHGUA4hTEBvo_kVlNJTXoV4LWw8mNwMpBCQ,1325
|
|
25
|
+
modelbuilder/src/versionmanager.py,sha256=WKrxY8JkSIquHxivS5eyN5W0izJ5LWLmxSvd9wg_5Is,18289
|
|
26
|
+
modelbuilder/src/connectors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
modelbuilder/src/connectors/boltconnector.py,sha256=N4hNEXzRWkPgDrRi49tgUdYw_y4ODu-mZUS3AiYAH7k,4579
|
|
28
|
+
modelbuilder/src/connectors/dbconnectors.py,sha256=KKaKGO-jduohHLK4yfROotEJBxF4JqHAFCm7nJtBb18,1496
|
|
29
|
+
modelbuilder/src/connectors/genericconnector.py,sha256=bMfnbrOWq97BC9oM7RIA58bNdC4kR3q3XDOiOVvYNkU,861
|
|
30
|
+
modelbuilder/src/connectors/httpsconnector.py,sha256=06TrQSEa5bmqXjPPAqz1hXrOEOwzeiV-9v8scyQGRg8,6006
|
|
31
|
+
modelbuilder/src/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
modelbuilder/src/processors/cypherfileprocessor.py,sha256=Y77GddRVhQKNhs6V4jfqwE2LhZvINZ1NX0a_lRadlds,2868
|
|
33
|
+
modelbuilder/src/processors/labelmanager.py,sha256=03fD-JXjdeEyHXUeihst5rVWgmd-3-Y8fSMM42OfsT8,6237
|
|
34
|
+
modelbuilder/src/processors/nodefileprocessor.py,sha256=Ww9KhNk9YAKSb91LxapLX_NgGdvSwIbnX7bfPPMok-s,12773
|
|
35
|
+
modelbuilder/src/processors/propertymanager.py,sha256=O47J-2ZBuDWLointG6LhEDh-T_5PXHHSp2cECQ2fpno,3795
|
|
36
|
+
modelbuilder/src/processors/relationshipfileprocessor.py,sha256=hSL-094K0lxOW8TkBW54dkUg1GogO2iaEj_d5jM8KDM,14937
|
|
37
|
+
modelbuilder/src/processors/relationshipmanager.py,sha256=lDtE_5AdKzL3boq7VD8Gmpai8Uscq79vRxkzYQL8A9A,1105
|
|
38
|
+
modelbuilder/src/queries/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
+
modelbuilder/src/queries/cypherbuilder.py,sha256=XHChyxnTyJegfVhN949UU0T3t3Lf1CKgN0yCN8Cx8cM,10384
|
|
40
|
+
modelbuilder/src/queries/query.py,sha256=gN69uwsf-0F6_dGx9cxLGuM17960_FV58pyimJ9usxY,2472
|
|
41
|
+
modelbuilder/src/queries/typedefs.py,sha256=8uAnLfE_EyAfrdMZuotfu_YHqORXhWfgPG3Yltvyr5A,6129
|
|
42
|
+
python_eigen_ingenuity-0.4.36.dist-info/METADATA,sha256=KO3bssf3MwVYQchzQI98wOm6nI9XRSzfYCYM2s8-Wys,32119
|
|
43
|
+
python_eigen_ingenuity-0.4.36.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
44
|
+
python_eigen_ingenuity-0.4.36.dist-info/entry_points.txt,sha256=G3LjFQX5xKaN4mqtqCL8uaC-gRbP5T5x9r0gBTJTXXA,70
|
|
45
|
+
python_eigen_ingenuity-0.4.36.dist-info/top_level.txt,sha256=lFiZ43CY_1bmdtRidIXbA6rrY2d92Rs-9tH8pcgI-XU,28
|
|
46
|
+
python_eigen_ingenuity-0.4.36.dist-info/RECORD,,
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
eigeningenuity/__init__.py,sha256=wiP9sP_ibX_oufhkGLXiTLze3fF17CUIHVo1hymdO2U,1500
|
|
2
|
-
eigeningenuity/assetmodel.py,sha256=_-E-JixY1ZvyDWayT9NgTq7EHdJ-cUQpwE3ekzcHB54,16772
|
|
3
|
-
eigeningenuity/auth.py,sha256=3efTRyiKoKXCYt3F2lZ9KVF82Gw-BfFLC8y9lo8690I,6560
|
|
4
|
-
eigeningenuity/elastic.py,sha256=WG4nlsJXNs_-m76jtj46UfgvLgWLvn6d6QW2dk7LBI4,6648
|
|
5
|
-
eigeningenuity/events.py,sha256=wUc1TkT7047gduNuNfzkSO5tK13ErJdeI2K5cPXhNCY,3336
|
|
6
|
-
eigeningenuity/historian.py,sha256=YGAwaSMSdDAB_czQUCE0POxzYkU5ywsIrhl_abGl7rk,36341
|
|
7
|
-
eigeningenuity/historianmulti.py,sha256=iFGJft7C0WQVcbZt-I-ufy1AsxcmOl7nNGM11m3eWO8,30448
|
|
8
|
-
eigeningenuity/settings.py,sha256=ImYplpNINf1dYaUdarZaxvwf3zHSjE1CG7bOEUqnLT0,2794
|
|
9
|
-
eigeningenuity/smartdash.py,sha256=spzoRXO4tu7cDAd4cwbyxo9RBnYvjbJoXQq8zbXkMEw,3009
|
|
10
|
-
eigeningenuity/sql.py,sha256=y-IMu1fdZjMGFcg7ue7Ubhr0-BDTiUW01x8I7tSR700,5059
|
|
11
|
-
eigeningenuity/util.py,sha256=owDeWljj5vbBUcC8UNf5HTOH6DZgXpIrer68dSnEP2U,14858
|
|
12
|
-
eigeningenuity/core/__init__.py,sha256=u3wAldyaivF-E2HzMftBNFPWUGNf0ZxGmdMUY6Em6nA,8439
|
|
13
|
-
modelbuilder/__init__.py,sha256=HSsHItu5BbGQiHYTG00QPMNDbC3RkRUaaN50YpksIUA,171
|
|
14
|
-
modelbuilder/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
modelbuilder/src/assetmodelbuilder.py,sha256=Gii5mU5z8spk1d53_veD4rlgaXL3xtev6OFjYWKDCqU,8078
|
|
16
|
-
modelbuilder/src/assetmodelcsvwriter.py,sha256=PRI3nPFjShHRxbdUvogrHE7kOd1veLXRkzS-dqW0zYc,1030
|
|
17
|
-
modelbuilder/src/assetmodelutilities.py,sha256=E-bqfMToxPxszylt42PwezfY0YF6PaI4NiK2pjiBd40,5050
|
|
18
|
-
modelbuilder/src/configmanager.py,sha256=gz_gkM1N4XINTsEk_iMmo6U1S8OBA2GcCaHz02coF90,23022
|
|
19
|
-
modelbuilder/src/csvcontentsmanager.py,sha256=fgYmvFRNGxxYENqa5qipJh5BIXnDoVWv0hJqnZI740w,5253
|
|
20
|
-
modelbuilder/src/csvwriter.py,sha256=DUkWI_QuOiZS79tWI0r1gzHUQWY5k2qozVbCsfeOGg0,15560
|
|
21
|
-
modelbuilder/src/filemanager.py,sha256=cRjrHnKJ1tZAVzXU0FJWOX0jIf16SBq3XErkpfP3GHo,18267
|
|
22
|
-
modelbuilder/src/fileprocessors.py,sha256=-ZoaqsnlOA4Rh_unF3L-TE6RqCgYHheGd_FQRSa-DRc,35692
|
|
23
|
-
modelbuilder/src/messages.py,sha256=6JnW-ke6nHGUA4hTEBvo_kVlNJTXoV4LWw8mNwMpBCQ,1325
|
|
24
|
-
modelbuilder/src/versionmanager.py,sha256=inEjs_jW7ph5-6g6-cc8xRjHKcVH7474G95U_sUlPiQ,18132
|
|
25
|
-
modelbuilder/src/connectors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
modelbuilder/src/connectors/boltconnector.py,sha256=N4hNEXzRWkPgDrRi49tgUdYw_y4ODu-mZUS3AiYAH7k,4579
|
|
27
|
-
modelbuilder/src/connectors/dbconnectors.py,sha256=KKaKGO-jduohHLK4yfROotEJBxF4JqHAFCm7nJtBb18,1496
|
|
28
|
-
modelbuilder/src/connectors/genericconnector.py,sha256=bMfnbrOWq97BC9oM7RIA58bNdC4kR3q3XDOiOVvYNkU,861
|
|
29
|
-
modelbuilder/src/connectors/httpsconnector.py,sha256=WjtAzXwN-8w2UNoCXfEUWJktzh_eK_f0PQtPOdzcdnI,6104
|
|
30
|
-
modelbuilder/src/queries/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
-
modelbuilder/src/queries/cypherbuilder.py,sha256=6443jCufAfYkb8KySB75aeoUJjlgTTn9mJRBjTXvkx4,10745
|
|
32
|
-
modelbuilder/src/queries/query.py,sha256=gN69uwsf-0F6_dGx9cxLGuM17960_FV58pyimJ9usxY,2472
|
|
33
|
-
modelbuilder/src/queries/typedefs.py,sha256=Ckzvbyj5FCQnRxoGC9hL_jIOLWMEQOn1J5vFVw45aGM,5944
|
|
34
|
-
python_eigen_ingenuity-0.4.35b2.dist-info/METADATA,sha256=oJ_kYElgSeYhsulFVJXYiDRcwDRakFFXKmqeGMxY7ZA,32121
|
|
35
|
-
python_eigen_ingenuity-0.4.35b2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
36
|
-
python_eigen_ingenuity-0.4.35b2.dist-info/entry_points.txt,sha256=G3LjFQX5xKaN4mqtqCL8uaC-gRbP5T5x9r0gBTJTXXA,70
|
|
37
|
-
python_eigen_ingenuity-0.4.35b2.dist-info/top_level.txt,sha256=lFiZ43CY_1bmdtRidIXbA6rrY2d92Rs-9tH8pcgI-XU,28
|
|
38
|
-
python_eigen_ingenuity-0.4.35b2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.4.35b2.dist-info → python_eigen_ingenuity-0.4.36.dist-info}/top_level.txt
RENAMED
|
File without changes
|