python-eigen-ingenuity 0.5.5__tar.gz → 0.5.6__tar.gz
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.
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/MANIFEST.in +3 -1
- {python_eigen_ingenuity-0.5.5/python_eigen_ingenuity.egg-info → python_eigen_ingenuity-0.5.6}/PKG-INFO +6 -1
- python_eigen_ingenuity-0.5.6/README-nocli.md +8 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/README.md +5 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/assetmodelbuilder.py +3 -2
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/configmanager.py +7 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/filemanager.py +11 -2
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/processors/nodefileprocessor.py +35 -16
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/processors/propertymanager.py +11 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/processors/relationshipfileprocessor.py +8 -4
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/queries/cypherbuilder.py +6 -3
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/queries/typedefs.py +60 -11
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6/python_eigen_ingenuity.egg-info}/PKG-INFO +6 -1
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/python_eigen_ingenuity.egg-info/SOURCES.txt +2 -0
- python_eigen_ingenuity-0.5.6/python_eigen_ingenuity.egg-info/entry_points.txt +2 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/setup.py +7 -2
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/assetmodel.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/auth.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/core/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/elastic.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/events.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/historian.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/historianmulti.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/settings.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/smartdash.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/sql.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/util.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/assetmodelcsvwriter.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/assetmodelutilities.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/connectors/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/connectors/boltconnector.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/connectors/dbconnectors.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/connectors/genericconnector.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/connectors/httpsconnector.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/csvcontentsmanager.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/csvwriter.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/fileanalyser.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/messages.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/processors/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/processors/cypherfileprocessor.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/processors/labelmanager.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/processors/relationshipmanager.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/queries/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/queries/query.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/versionmanager.py +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/pyproject.toml +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/python_eigen_ingenuity.egg-info/dependency_links.txt +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/python_eigen_ingenuity.egg-info/requires.txt +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/python_eigen_ingenuity.egg-info/top_level.txt +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/requirements.txt +0 -0
- {python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-eigen-ingenuity
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.6
|
|
4
4
|
Summary: A python library used to query data from the Eigen Ingenuity system
|
|
5
5
|
Home-page: https://www.eigen.co/
|
|
6
6
|
Author: Murray Callander
|
|
@@ -75,6 +75,11 @@ This library supports python 3.10 onwards. It may work for earlier versions of p
|
|
|
75
75
|
|
|
76
76
|
The python-eigen-ingenuity library contains 2 modules:
|
|
77
77
|
|
|
78
|
+
# Note <!-- omit in toc -->
|
|
79
|
+
This version of the library includes a CLI tool for building assetmodels on Eigen Systems (See [ModelBuilder Section](#asset-model-builder)). On some secured machines this cli tool may cause the library to fail to install, or raise an error.
|
|
80
|
+
|
|
81
|
+
if this occurs, install the version without the CLI tool [here](https://pypi.org/project/python-eigen-ingenuity-nocli/)
|
|
82
|
+
|
|
78
83
|
### 1. Eigen Ingenuity <!-- omit in toc -->
|
|
79
84
|
This module is used to query data from many of the databases in the Ingenuity Platform, including:
|
|
80
85
|
- timeseries historians (influx, PI, IP21, cognite)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# About<a id="about"></a>
|
|
2
|
+
|
|
3
|
+
This is a version of the Eigen python library [python-eigen-ingenuity](https://pypi.org/project/python-eigen-ingenuity/) without the cli tool for building assetmodels. The model builder is still available in the code, but the always-active cli functionality is removed.
|
|
4
|
+
|
|
5
|
+
Th reason for this is that on some user computers that are locked down for security reasons, the library will fail to install with the cli present.
|
|
6
|
+
|
|
7
|
+
For the full documentation on how to use the library please refer to the ReadMe of the [Main Project](https://pypi.org/project/python-eigen-ingenuity/)
|
|
8
|
+
|
|
@@ -53,6 +53,11 @@ This library supports python 3.10 onwards. It may work for earlier versions of p
|
|
|
53
53
|
|
|
54
54
|
The python-eigen-ingenuity library contains 2 modules:
|
|
55
55
|
|
|
56
|
+
# Note <!-- omit in toc -->
|
|
57
|
+
This version of the library includes a CLI tool for building assetmodels on Eigen Systems (See [ModelBuilder Section](#asset-model-builder)). On some secured machines this cli tool may cause the library to fail to install, or raise an error.
|
|
58
|
+
|
|
59
|
+
if this occurs, install the version without the CLI tool [here](https://pypi.org/project/python-eigen-ingenuity-nocli/)
|
|
60
|
+
|
|
56
61
|
### 1. Eigen Ingenuity <!-- omit in toc -->
|
|
57
62
|
This module is used to query data from many of the databases in the Ingenuity Platform, including:
|
|
58
63
|
- timeseries historians (influx, PI, IP21, cognite)
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/assetmodelbuilder.py
RENAMED
|
@@ -63,8 +63,8 @@ def _convert_sys_argv_(func):
|
|
|
63
63
|
@_convert_sys_argv_
|
|
64
64
|
def build(path:str='.', config:str='config.ini', file:str='', query:list=[], preprocess:list=[], postprocess:list=[], delete_all:list=[], separator:str=';',
|
|
65
65
|
start_from:int=1, end_at:int=1, no_versions:bool=False, no_system_properties:bool=False, ignore_nodes:bool=False, skip_duplicates:bool=False,
|
|
66
|
-
no_duplicates:bool=False, allow_blanks:list=[], batch:int=0, auth:bool=False, order:str='qnrc', primary_property:str='', required_labels:list=[],
|
|
67
|
-
required_properties:list=[], database:str='0', verify:bool=False, summarise:bool=False, show_queries:bool=False, show_returns:bool=False,
|
|
66
|
+
no_duplicates:bool=False, allow_blanks:list=[], batch:int=0, auth:bool=False, order:str='qnrc', filetypes:str='qnrc', primary_property:str='', required_labels:list=[],
|
|
67
|
+
required_properties:list=[], database:str='0', verify:bool=False, summarise:bool=False, show_queries:bool=False, show_returns:bool=False,
|
|
68
68
|
write_queries:str='', write_returns:str='', display_rate='auto', create_node_csv_file:bool=False, node_labels:list=[], node_properties:list=[],
|
|
69
69
|
csv_file_suffix:str='', create_relationship_csv_file:bool=False, csv_to_labels:list=[], csv_to_properties:str=''):
|
|
70
70
|
"""The main model builder tools, features a suite of options that allow for importing, exporting, building and updating neo4j data models
|
|
@@ -92,6 +92,7 @@ def build(path:str='.', config:str='config.ini', file:str='', query:list=[], pre
|
|
|
92
92
|
batch: Number of queries to batch together when processing a node .csv file, significantly improves performance
|
|
93
93
|
auth: Enable Azure Authentication
|
|
94
94
|
order: Order in which to process the input files. Default is qnrc
|
|
95
|
+
filetypes: File types to process. Default is all
|
|
95
96
|
|
|
96
97
|
# Override values in the config file
|
|
97
98
|
primary_property: Primary property
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/configmanager.py
RENAMED
|
@@ -43,6 +43,7 @@ class ConfigManager:
|
|
|
43
43
|
parser.add_argument('-a', '--auth', action='store_true', help='Enable Azure Authentication')
|
|
44
44
|
default_order = 'qnrc'
|
|
45
45
|
parser.add_argument('-o', '--order', default=default_order, help='Order in which to process the input files. Default is ' + default_order)
|
|
46
|
+
parser.add_argument('-ft', '--filetypes', default=default_order, help='File types to process. Default is all')
|
|
46
47
|
|
|
47
48
|
# Overrides... used to override values in the config file
|
|
48
49
|
parser.add_argument('-pp', '--primaryproperty', default='', help='Primary node_key')
|
|
@@ -173,6 +174,9 @@ class ConfigManager:
|
|
|
173
174
|
self.orders[input_type] = order + 1
|
|
174
175
|
count += 1
|
|
175
176
|
|
|
177
|
+
# Identify which files to process (note: order is unimportant, just presence (or not))
|
|
178
|
+
self.process_file_types = ''.join(list(dict.fromkeys(re.findall("[" + default_order + "]", args.filetypes))))
|
|
179
|
+
|
|
176
180
|
# Data for .csv file generation
|
|
177
181
|
self.node_csvfile_requested = args.createnodecsvfile
|
|
178
182
|
self.node_labels = lm.validate_labels([args.nodelabels])
|
|
@@ -433,6 +437,9 @@ class ConfigManager:
|
|
|
433
437
|
def get_process_order(self):
|
|
434
438
|
return self.orders
|
|
435
439
|
|
|
440
|
+
def get_process_file_types(self):
|
|
441
|
+
return self.process_file_types
|
|
442
|
+
|
|
436
443
|
def get_frozen_labels_list(self):
|
|
437
444
|
return self.frozen_labels_list
|
|
438
445
|
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/filemanager.py
RENAMED
|
@@ -25,6 +25,7 @@ class FileManager:
|
|
|
25
25
|
self.start_from = config_manager.get_start_from()
|
|
26
26
|
self.batch_rate = config_manager.get_batch_rate()
|
|
27
27
|
self.stop_on_failure = config_manager.get_stop_on_failure()
|
|
28
|
+
self.process_file_types = config_manager.get_process_file_types()
|
|
28
29
|
|
|
29
30
|
# Create a list of error each type
|
|
30
31
|
self.both_file_list = []
|
|
@@ -62,8 +63,16 @@ class FileManager:
|
|
|
62
63
|
self.unrecognised_file_type_list.append(a_file)
|
|
63
64
|
|
|
64
65
|
def add_file_to_process_list(self, file_processor, file_type):
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
if file_type in ['pre', 'pre-file', 'post', 'post-file']:
|
|
67
|
+
file_type_check = 'q'
|
|
68
|
+
else:
|
|
69
|
+
file_type_check = file_type
|
|
70
|
+
|
|
71
|
+
if file_type_check in self.process_file_types:
|
|
72
|
+
priority = self.process_order[file_type]
|
|
73
|
+
self.valid_file_list[priority] += [{'processor': file_processor, 'type': file_type}]
|
|
74
|
+
else:
|
|
75
|
+
info_message(file_processor.get_filename(), ' not processed as requested')
|
|
67
76
|
|
|
68
77
|
def analyse_lst_file(self, filename):
|
|
69
78
|
|
|
@@ -70,17 +70,24 @@ class NodeFileProcessor:
|
|
|
70
70
|
row_properties = self.contents.get_property_values_dict(this_row, property_columns, self.blank_property_list)
|
|
71
71
|
properties = pm.combine_properties(self.required_properties, row_properties)
|
|
72
72
|
# Remove any properties we don't want
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
property_list = list(properties.keys())
|
|
74
|
+
for unwanted in self.unrequired_properties:
|
|
75
|
+
for property in property_list:
|
|
76
|
+
if property.split(':')[0] == unwanted:
|
|
77
|
+
try:
|
|
78
|
+
properties.pop(property)
|
|
79
|
+
except:
|
|
80
|
+
pass
|
|
81
|
+
|
|
78
82
|
for k in list(properties):
|
|
79
83
|
if k.startswith(':'):
|
|
80
84
|
properties.pop(k)
|
|
81
85
|
else:
|
|
82
86
|
properties[property_ref_dot + k] = properties.pop(k)
|
|
83
87
|
|
|
88
|
+
# Split out those properties that are dependent on others, so that we can add them in the right order
|
|
89
|
+
explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
|
|
90
|
+
|
|
84
91
|
for primary_property in self.contents.get_property_values_list(this_row, node_columns, self.primary_property):
|
|
85
92
|
time_now = amu.get_formatted_time_now()
|
|
86
93
|
|
|
@@ -103,8 +110,10 @@ class NodeFileProcessor:
|
|
|
103
110
|
query_text = query_text.set_labels(ref_name=property_ref, labels=new_labels)
|
|
104
111
|
if len(remove_labels) > 0:
|
|
105
112
|
query_text = query_text.remove_literal(f'{property_ref}:{":".join(remove_labels)}')
|
|
106
|
-
if len(
|
|
107
|
-
query_text = query_text.set(properties=
|
|
113
|
+
if len(explicit_properties) > 0:
|
|
114
|
+
query_text = query_text.set(properties=explicit_properties, property_ref=property_ref_dot)
|
|
115
|
+
if len(calculated_properties) > 0:
|
|
116
|
+
query_text = query_text.set(properties=calculated_properties, property_ref=property_ref_dot)
|
|
108
117
|
|
|
109
118
|
query_text = query_text.toStr()
|
|
110
119
|
|
|
@@ -162,23 +171,29 @@ class NodeFileProcessor:
|
|
|
162
171
|
for primary_property in self.contents.get_property_values_list(this_row, node_columns, self.primary_property):
|
|
163
172
|
properties = pm.combine_properties(self.required_properties, row_properties)
|
|
164
173
|
# Remove any properties we don't want
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
property_list = list(properties.keys())
|
|
175
|
+
for unwanted in self.unrequired_properties:
|
|
176
|
+
for property in property_list:
|
|
177
|
+
if property.split(':')[0] == unwanted:
|
|
178
|
+
try:
|
|
179
|
+
properties.pop(property)
|
|
180
|
+
except:
|
|
181
|
+
pass
|
|
182
|
+
|
|
170
183
|
properties = {**properties, **primary_property}
|
|
171
184
|
|
|
172
185
|
for k in list(properties):
|
|
173
186
|
if k.startswith(':'):
|
|
174
187
|
properties.pop(k)
|
|
175
188
|
|
|
176
|
-
|
|
189
|
+
explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
|
|
190
|
+
|
|
191
|
+
query_data = [explicit_properties, calculated_properties, time_now]
|
|
177
192
|
|
|
178
193
|
# So now we know all about this particular update. Let's put it in the query dictionary
|
|
179
194
|
# We'll group these by unique combinations of labels and primary key type
|
|
180
195
|
# Have to use a list since a dictionary key can't be a dictionary
|
|
181
|
-
dictionary_key = [new_labels, merge_labels, remove_labels, list(primary_property)[0].split(':')[0]]
|
|
196
|
+
dictionary_key = [new_labels, merge_labels, remove_labels, list(primary_property)[0].split(':')[0], calculated_properties]
|
|
182
197
|
try:
|
|
183
198
|
dictionary_index = batch_keys.index(dictionary_key)
|
|
184
199
|
query_dictionary[dictionary_index].append(query_data)
|
|
@@ -213,8 +228,9 @@ class NodeFileProcessor:
|
|
|
213
228
|
# Combine all the update data...
|
|
214
229
|
update = updates[(batch_num-1)*self.batch_rate + this_size]
|
|
215
230
|
update_properties = update[0] or {}
|
|
231
|
+
func_properties = update[1] or {}
|
|
216
232
|
if self.add_system_properties:
|
|
217
|
-
update_properties[self.update_time_property] = update[
|
|
233
|
+
update_properties[self.update_time_property] = update[2]
|
|
218
234
|
payload.append(update_properties)
|
|
219
235
|
this_size += 1
|
|
220
236
|
query_count += 1
|
|
@@ -222,7 +238,7 @@ class NodeFileProcessor:
|
|
|
222
238
|
formatted_payload = []
|
|
223
239
|
property_count = 0
|
|
224
240
|
for a_payload in payload:
|
|
225
|
-
formatted_payload.append(Properties(a_payload).format())
|
|
241
|
+
formatted_payload.append(Properties(a_payload).format(property_ref_dot))
|
|
226
242
|
property_count += len(a_payload)
|
|
227
243
|
|
|
228
244
|
# Build a MERGE query using queries
|
|
@@ -239,6 +255,9 @@ class NodeFileProcessor:
|
|
|
239
255
|
)
|
|
240
256
|
if len(remove_labels) > 0:
|
|
241
257
|
query_text = query_text.remove_literal(f'{property_ref}:{":".join(remove_labels)}')
|
|
258
|
+
if func_properties:
|
|
259
|
+
query_text = query_text.set_functional(func_properties, property_ref_dot)
|
|
260
|
+
property_count += len(func_properties)
|
|
242
261
|
if self.add_system_properties:
|
|
243
262
|
query_text = query_text.set_literal(id_property + '= CASE WHEN ' + id_property + ' IS null THEN randomUUID() ELSE ' + id_property + ' END')
|
|
244
263
|
query_text = query_text.set_literal(creation_property + '= CASE WHEN ' + creation_property + ' IS null THEN ' + property_ref_dot + self.update_time_property + ' ELSE ' + creation_property + ' END')
|
|
@@ -116,3 +116,14 @@ def combine_properties(default_properties, actual_properties):
|
|
|
116
116
|
combined_properties[property] = value
|
|
117
117
|
|
|
118
118
|
return combined_properties
|
|
119
|
+
|
|
120
|
+
def split_out_functional_properties(properties):
|
|
121
|
+
explicit = {}
|
|
122
|
+
functional = {}
|
|
123
|
+
for key, value in properties.items():
|
|
124
|
+
if '{' in value and '}' in value:
|
|
125
|
+
functional[key] = value
|
|
126
|
+
else:
|
|
127
|
+
explicit[key] = value
|
|
128
|
+
|
|
129
|
+
return explicit, functional
|
|
@@ -109,7 +109,7 @@ class RelationshipFileProcessor:
|
|
|
109
109
|
query_text = query_text.on_create().set_literal(create_time).set_literal(update_time)
|
|
110
110
|
|
|
111
111
|
if len(properties) > 0:
|
|
112
|
-
query_text = query_text.set(properties=properties)
|
|
112
|
+
query_text = query_text.set(properties=properties, property_ref=relation_ref_dot)
|
|
113
113
|
query_text = query_text.toStr()
|
|
114
114
|
query = Neo4jQuery('relationship', query_text, time_now)
|
|
115
115
|
|
|
@@ -177,8 +177,9 @@ class RelationshipFileProcessor:
|
|
|
177
177
|
for relation in relationship.split(':'):
|
|
178
178
|
if relation:
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
|
|
181
|
+
new_labels = [from_labels, to_labels, relation, list(from_node)[0], list(to_node)[0], calculated_properties]
|
|
182
|
+
query_data = [list(from_node.values())[0], list(to_node.values())[0], explicit_properties, calculated_properties, time_now]
|
|
182
183
|
|
|
183
184
|
# So now we know all about this particular update. Let's put it in the query dictionary
|
|
184
185
|
try:
|
|
@@ -220,10 +221,11 @@ class RelationshipFileProcessor:
|
|
|
220
221
|
# Combine all the update data...
|
|
221
222
|
update = updates[(batch_num - 1) * self.batch_rate + this_size]
|
|
222
223
|
update_properties = update[2] or {} # In case update_properties[2] is {}
|
|
224
|
+
func_properties = update[3] or {} # In case update_properties[3] is {}
|
|
223
225
|
update_properties[from_ref + from_type] = update[0]
|
|
224
226
|
update_properties[to_ref + to_type] = update[1]
|
|
225
227
|
if self.add_system_properties:
|
|
226
|
-
update_properties[self.update_time_property] = update[
|
|
228
|
+
update_properties[self.update_time_property] = update[4]
|
|
227
229
|
payload.append(update_properties)
|
|
228
230
|
this_size += 1
|
|
229
231
|
query_count += 1
|
|
@@ -253,6 +255,8 @@ class RelationshipFileProcessor:
|
|
|
253
255
|
query_text = query_text.on_create().set_literal(create_time)
|
|
254
256
|
|
|
255
257
|
query_text = query_text.set_literal(relation_ref + ' += ' + payload_ref)
|
|
258
|
+
if func_properties:
|
|
259
|
+
query_text = query_text.set_functional(func_properties, relation_ref_dot)
|
|
256
260
|
|
|
257
261
|
if self.add_system_properties:
|
|
258
262
|
query_text = query_text.set_literal(update_time)
|
|
@@ -94,7 +94,7 @@ class Node(Query):
|
|
|
94
94
|
if not properties:
|
|
95
95
|
property_string = ''
|
|
96
96
|
else:
|
|
97
|
-
property_string = f' {{{Properties(properties)}}}'
|
|
97
|
+
property_string = f' {{{Properties(properties).to_str(property_ref=ref_name)}}}'
|
|
98
98
|
|
|
99
99
|
ref_name = ref_name or ''
|
|
100
100
|
|
|
@@ -207,8 +207,11 @@ class Return(Query):
|
|
|
207
207
|
|
|
208
208
|
class Set(Query):
|
|
209
209
|
|
|
210
|
-
def set(self, properties: Properties):
|
|
211
|
-
return ValidAfterSet(self.query + ' SET ' + Properties(properties).to_str("=", ","))
|
|
210
|
+
def set(self, properties: Properties, property_ref=''):
|
|
211
|
+
return ValidAfterSet(self.query + ' SET ' + Properties(properties).to_str("=", ",", property_ref))
|
|
212
|
+
|
|
213
|
+
def set_functional(self, properties: Properties, property_ref=''):
|
|
214
|
+
return ValidAfterSet(self.query + ' SET ' + Properties(properties).to_str("=", ",", property_ref, property_ref))
|
|
212
215
|
|
|
213
216
|
def set_labels(self, ref_name: str = '', labels: List[str] = None):
|
|
214
217
|
if not labels:
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/queries/typedefs.py
RENAMED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
"""Cymple's API type definitions."""
|
|
2
1
|
from collections import namedtuple
|
|
3
2
|
import ast
|
|
4
3
|
import datetime
|
|
5
4
|
import messages
|
|
5
|
+
import processors.propertymanager as pm
|
|
6
6
|
|
|
7
7
|
Mapping = namedtuple('Mapping', ['ref_name', 'returned_name'], defaults=(None, None))
|
|
8
8
|
|
|
9
9
|
class Properties(dict):
|
|
10
|
-
"""A dict class storing a set of properties."""
|
|
11
10
|
|
|
12
11
|
@staticmethod
|
|
13
12
|
def _escape(string: str) -> str:
|
|
@@ -15,7 +14,52 @@ class Properties(dict):
|
|
|
15
14
|
return res
|
|
16
15
|
|
|
17
16
|
@staticmethod
|
|
18
|
-
def _format_value(key, value):
|
|
17
|
+
def _format_value(key, value, ref=''):
|
|
18
|
+
|
|
19
|
+
def parse_formula(formula):
|
|
20
|
+
num_open = 0
|
|
21
|
+
num_close = 0
|
|
22
|
+
parsed = ''
|
|
23
|
+
index = 0
|
|
24
|
+
open = False
|
|
25
|
+
property_name = ''
|
|
26
|
+
while index < len(formula):
|
|
27
|
+
this_char = formula[index]
|
|
28
|
+
next_char = (formula+' ')[index+1]
|
|
29
|
+
if this_char == '{':
|
|
30
|
+
if next_char == '{':
|
|
31
|
+
if open:
|
|
32
|
+
property_name += this_char
|
|
33
|
+
else:
|
|
34
|
+
parsed += this_char
|
|
35
|
+
index += 1
|
|
36
|
+
else:
|
|
37
|
+
open = True
|
|
38
|
+
property_name = ''
|
|
39
|
+
num_open += 1
|
|
40
|
+
elif this_char == '}':
|
|
41
|
+
if next_char == '}':
|
|
42
|
+
if open:
|
|
43
|
+
property_name += this_char
|
|
44
|
+
else:
|
|
45
|
+
parsed += this_char
|
|
46
|
+
index += 1
|
|
47
|
+
else:
|
|
48
|
+
parsed += ref + pm.validate_property(property_name)
|
|
49
|
+
open = False
|
|
50
|
+
num_close += 1
|
|
51
|
+
else:
|
|
52
|
+
if open:
|
|
53
|
+
property_name += this_char
|
|
54
|
+
else:
|
|
55
|
+
parsed += this_char
|
|
56
|
+
index += 1
|
|
57
|
+
|
|
58
|
+
ok = (num_open == num_close)
|
|
59
|
+
if num_open == 0:
|
|
60
|
+
parsed = quote + parsed + quote
|
|
61
|
+
|
|
62
|
+
return parsed, ok
|
|
19
63
|
|
|
20
64
|
def try_date_format(date_format):
|
|
21
65
|
try:
|
|
@@ -38,7 +82,9 @@ class Properties(dict):
|
|
|
38
82
|
try:
|
|
39
83
|
match given_data_type:
|
|
40
84
|
case 'str':
|
|
41
|
-
result =
|
|
85
|
+
result, ok = parse_formula(escaped_value)
|
|
86
|
+
if not ok:
|
|
87
|
+
messages.warning_message(f'{escaped_value} is not valid')
|
|
42
88
|
case 'int':
|
|
43
89
|
# Remove any leading zeroes because the literal_eval function does not support them
|
|
44
90
|
while escaped_value.startswith('0'):
|
|
@@ -86,7 +132,9 @@ class Properties(dict):
|
|
|
86
132
|
else:
|
|
87
133
|
match str(data_type):
|
|
88
134
|
case 'str':
|
|
89
|
-
result =
|
|
135
|
+
result, ok = parse_formula(escaped_value)
|
|
136
|
+
if not ok:
|
|
137
|
+
messages.warning_message(f'{escaped_value} is not valid')
|
|
90
138
|
case "<class 'int'>":
|
|
91
139
|
if escaped_value != '0' and escaped_value.startswith('0'):
|
|
92
140
|
# Has a leading 0, so treat as a string
|
|
@@ -110,21 +158,22 @@ class Properties(dict):
|
|
|
110
158
|
result = ''
|
|
111
159
|
case _:
|
|
112
160
|
# Shouldn't get here, but just in case use a string
|
|
113
|
-
result =
|
|
161
|
+
result, ok = parse_formula(escaped_value)
|
|
162
|
+
if not ok:
|
|
163
|
+
messages.warning_message(f'{escaped_value} is not valid')
|
|
114
164
|
|
|
115
165
|
return result
|
|
116
166
|
|
|
117
|
-
def to_str(self, comparison_operator: str = ':', boolean_operator: str = ',') -> str:
|
|
118
|
-
""
|
|
119
|
-
pairs = [f'{key.split(":")[0]}{comparison_operator}{Properties._format_value(key, str(value))}' for key, value in self.items()]
|
|
167
|
+
def to_str(self, comparison_operator: str = ':', boolean_operator: str = ',', property_ref='', key_ref='') -> str:
|
|
168
|
+
pairs = [f'{key_ref}{key.split(":")[0]}{comparison_operator}{Properties._format_value(key, str(value), property_ref)}' for key, value in self.items()]
|
|
120
169
|
res = boolean_operator.join(pairs)
|
|
121
170
|
return res
|
|
122
171
|
|
|
123
|
-
def format(self):
|
|
172
|
+
def format(self, property_ref=''):
|
|
124
173
|
# Reformat using identified data types
|
|
125
174
|
pairs = []
|
|
126
175
|
for key, value in self.items():
|
|
127
|
-
pairs.append(f'{key.split(":")[0]}:{Properties._format_value(key, str(value))}')
|
|
176
|
+
pairs.append(f'{key.split(":")[0]}:{Properties._format_value(key, str(value), property_ref)}')
|
|
128
177
|
return '{' + ','.join(pairs) + '}'
|
|
129
178
|
|
|
130
179
|
def __str__(self) -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-eigen-ingenuity
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.6
|
|
4
4
|
Summary: A python library used to query data from the Eigen Ingenuity system
|
|
5
5
|
Home-page: https://www.eigen.co/
|
|
6
6
|
Author: Murray Callander
|
|
@@ -75,6 +75,11 @@ This library supports python 3.10 onwards. It may work for earlier versions of p
|
|
|
75
75
|
|
|
76
76
|
The python-eigen-ingenuity library contains 2 modules:
|
|
77
77
|
|
|
78
|
+
# Note <!-- omit in toc -->
|
|
79
|
+
This version of the library includes a CLI tool for building assetmodels on Eigen Systems (See [ModelBuilder Section](#asset-model-builder)). On some secured machines this cli tool may cause the library to fail to install, or raise an error.
|
|
80
|
+
|
|
81
|
+
if this occurs, install the version without the CLI tool [here](https://pypi.org/project/python-eigen-ingenuity-nocli/)
|
|
82
|
+
|
|
78
83
|
### 1. Eigen Ingenuity <!-- omit in toc -->
|
|
79
84
|
This module is used to query data from many of the databases in the Ingenuity Platform, including:
|
|
80
85
|
- timeseries historians (influx, PI, IP21, cognite)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
MANIFEST.in
|
|
2
|
+
README-nocli.md
|
|
2
3
|
README.md
|
|
3
4
|
pyproject.toml
|
|
4
5
|
requirements.txt
|
|
@@ -46,5 +47,6 @@ modelbuilder/src/queries/typedefs.py
|
|
|
46
47
|
python_eigen_ingenuity.egg-info/PKG-INFO
|
|
47
48
|
python_eigen_ingenuity.egg-info/SOURCES.txt
|
|
48
49
|
python_eigen_ingenuity.egg-info/dependency_links.txt
|
|
50
|
+
python_eigen_ingenuity.egg-info/entry_points.txt
|
|
49
51
|
python_eigen_ingenuity.egg-info/requires.txt
|
|
50
52
|
python_eigen_ingenuity.egg-info/top_level.txt
|
|
@@ -24,5 +24,10 @@ setup(
|
|
|
24
24
|
long_description_content_type="text/markdown",
|
|
25
25
|
packages=find_packages("."),
|
|
26
26
|
license='Apache License 2.0',
|
|
27
|
-
install_requires=[install_requires]
|
|
28
|
-
|
|
27
|
+
install_requires=[install_requires],
|
|
28
|
+
entry_points={
|
|
29
|
+
'console_scripts': [
|
|
30
|
+
'assetmodelbuilder=modelbuilder:__cli_entrypoint__',
|
|
31
|
+
],
|
|
32
|
+
}
|
|
33
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/core/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/eigeningenuity/historianmulti.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/csvcontentsmanager.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/fileanalyser.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/queries/__init__.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/queries/query.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity-0.5.5 → python_eigen_ingenuity-0.5.6}/modelbuilder/src/versionmanager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|