python-eigen-ingenuity-nocli 0.5.11b2__tar.gz → 0.5.12__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_nocli-0.5.11b2/python_eigen_ingenuity_nocli.egg-info → python_eigen_ingenuity_nocli-0.5.12}/PKG-INFO +10 -2
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/historianmulti.py +154 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/assetmodelbuilder.py +2 -1
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/configmanager.py +37 -3
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/csvcontentsmanager.py +7 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/fileanalyser.py +11 -4
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/processors/relationshipfileprocessor.py +27 -6
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12/python_eigen_ingenuity_nocli.egg-info}/PKG-INFO +10 -2
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/MANIFEST.in +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/README-nocli.md +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/README.md +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/assetmodel.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/auth.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/core/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/elastic.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/events.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/historian.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/settings.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/smartdash.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/sql.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/util.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/assetmodelcsvwriter.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/assetmodelutilities.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/connectors/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/connectors/boltconnector.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/connectors/dbconnectors.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/connectors/genericconnector.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/connectors/httpsconnector.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/csvwriter.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/filemanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/messages.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/processors/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/processors/cypherfileprocessor.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/processors/labelmanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/processors/nodefileprocessor.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/processors/propertymanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/processors/relationshipmanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/property.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/queries/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/queries/cypherbuilder.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/queries/query.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/modelbuilder/src/versionmanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/pyproject.toml +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/python_eigen_ingenuity_nocli.egg-info/SOURCES.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/python_eigen_ingenuity_nocli.egg-info/dependency_links.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/python_eigen_ingenuity_nocli.egg-info/requires.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/python_eigen_ingenuity_nocli.egg-info/top_level.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/requirements.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/setup.cfg +0 -0
- {python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: python-eigen-ingenuity-nocli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.12
|
|
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
|
|
@@ -19,6 +19,14 @@ Requires-Dist: pyarrow
|
|
|
19
19
|
Requires-Dist: neo4j>=5.17.0
|
|
20
20
|
Requires-Dist: requests>=2.31.0
|
|
21
21
|
Requires-Dist: dateparser
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: description-content-type
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: license
|
|
28
|
+
Dynamic: requires-dist
|
|
29
|
+
Dynamic: summary
|
|
22
30
|
|
|
23
31
|
# About<a id="about"></a>
|
|
24
32
|
|
|
@@ -37,6 +37,7 @@ class HistorianMulti (object):
|
|
|
37
37
|
self.baseurl = baseurl
|
|
38
38
|
self.serverurl = baseurl + "multi/"
|
|
39
39
|
self.writeurl = baseurl + "write/points"
|
|
40
|
+
self.metaurl = baseurl + "metadata"
|
|
40
41
|
self.listurl = baseurl + "list"
|
|
41
42
|
self.searchurl = baseurl + "search"
|
|
42
43
|
|
|
@@ -55,6 +56,9 @@ class HistorianMulti (object):
|
|
|
55
56
|
except (URLError, ConnectionError):
|
|
56
57
|
raise ConnectionError ("Failed to connect to ingenuity instance at " + self.serverurl + ". Please check the url is correct and the instance is up.")
|
|
57
58
|
|
|
59
|
+
|
|
60
|
+
#SECTION Read Requests
|
|
61
|
+
|
|
58
62
|
def getCurrentDataPoints(self,tags: Union[str, list], output: str = "json"):
|
|
59
63
|
tags = force_list(tags)
|
|
60
64
|
body = {
|
|
@@ -346,6 +350,155 @@ class HistorianMulti (object):
|
|
|
346
350
|
|
|
347
351
|
return metadata
|
|
348
352
|
|
|
353
|
+
#SECTION - Tag Metadata Requests
|
|
354
|
+
|
|
355
|
+
def createTag(self, tag:str, description:str=None, units:str=None, stepped:bool=False, update_existing:bool=False):
|
|
356
|
+
"""Create a Tag With Metadata - Writing points to a new tag directly will also create it, but will not create metadata
|
|
357
|
+
|
|
358
|
+
Args:
|
|
359
|
+
tag: Name of the tag to create, either including datasource, or using datasource defined when instantiating historian multi object
|
|
360
|
+
description (Optional): A concise summary of the tags purpose/usage. Defaults to blank/null
|
|
361
|
+
units (Optional): The engineering unit recorded by the value. Defaults to blank/null
|
|
362
|
+
stepped (Optional): Classify whether the measurement is continuous or discrete. Defaults to false
|
|
363
|
+
update_existing (Optional): Whether this function should overwrite metadata of any existing tags referenced. Defaults to false
|
|
364
|
+
|
|
365
|
+
Returns:
|
|
366
|
+
A dict with keys "success" containing a bool, and "errors" that present any tags that failed to be created with metadata
|
|
367
|
+
|
|
368
|
+
Raises:
|
|
369
|
+
URLError: When no Ingenuity instance could be found at given EigenServer, or no internet connection is available
|
|
370
|
+
RemoteServerException: When the provided historian could not be found, or the API response contains an error
|
|
371
|
+
RunTimeError/HTTPError: No response from the API
|
|
372
|
+
"""
|
|
373
|
+
url = self.metaurl + "/create"
|
|
374
|
+
|
|
375
|
+
if "/" not in tag:
|
|
376
|
+
tag = self.historian + tag
|
|
377
|
+
|
|
378
|
+
metadata = {}
|
|
379
|
+
|
|
380
|
+
for key, value in [("description", description), ("units", units), ("stepped", stepped)]:
|
|
381
|
+
if value is not None:
|
|
382
|
+
metadata[key] = value
|
|
383
|
+
|
|
384
|
+
body = {
|
|
385
|
+
"entries": {
|
|
386
|
+
f"{tag}": metadata
|
|
387
|
+
},
|
|
388
|
+
"updateIfExists": update_existing
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
resp = _do_historian_multi_request(url,body,self.auth)
|
|
392
|
+
|
|
393
|
+
if len(resp["errors"].keys()):
|
|
394
|
+
success = False
|
|
395
|
+
else:
|
|
396
|
+
success = True
|
|
397
|
+
|
|
398
|
+
return {"success": success, "errors": resp["errors"]}
|
|
399
|
+
|
|
400
|
+
def updateTag(self, tag:str, description:str=None, units:str=None, stepped:bool=False, create_missing:bool=False):
|
|
401
|
+
"""Update or Create Metadata for an existing tag
|
|
402
|
+
|
|
403
|
+
Args:
|
|
404
|
+
tag: Name of the tag to amend, either including datasource, or using datasource defined when instantiating historian multi object
|
|
405
|
+
description (Optional): A concise summary of the tags purpose/usage. Defaults to blank/null
|
|
406
|
+
units (Optional): The engineering unit recorded by the value. Defaults to blank/null
|
|
407
|
+
stepped (Optional): Classify whether the measurement is continuous or discrete. Defaults to false
|
|
408
|
+
create_missing (Optional): Whether this function should create any non-existent tags referenced. Defaults to false
|
|
409
|
+
|
|
410
|
+
Returns:
|
|
411
|
+
A dict with keys "success" containing a bool, and "errors" that present any tags that failed to be created with metadata
|
|
412
|
+
|
|
413
|
+
Raises:
|
|
414
|
+
URLError: When no Ingenuity instance could be found at given EigenServer, or no internet connection is available
|
|
415
|
+
RemoteServerException: When the provided historian could not be found, or the API response contains an error
|
|
416
|
+
RunTimeError/HTTPError: No response from the API
|
|
417
|
+
"""
|
|
418
|
+
url = self.metaurl + "/update"
|
|
419
|
+
|
|
420
|
+
if "/" not in tag:
|
|
421
|
+
tag = self.historian + tag
|
|
422
|
+
|
|
423
|
+
metadata = {}
|
|
424
|
+
|
|
425
|
+
for key, value in [("description", description), ("units", units), ("stepped", stepped)]:
|
|
426
|
+
if value is not None:
|
|
427
|
+
metadata[key] = value
|
|
428
|
+
|
|
429
|
+
body = {
|
|
430
|
+
"entries": {
|
|
431
|
+
f"{tag}": metadata
|
|
432
|
+
},
|
|
433
|
+
"createIfMissing": create_missing
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
resp = _do_historian_multi_request(url,body,self.auth)
|
|
437
|
+
|
|
438
|
+
if len(resp["errors"].keys()):
|
|
439
|
+
success = False
|
|
440
|
+
else:
|
|
441
|
+
success = True
|
|
442
|
+
|
|
443
|
+
return {"success": success, "errors": resp["errors"]}
|
|
444
|
+
|
|
445
|
+
def createAndPopulateTag(self, tag:str, points: Union[dict, list], description:str=None, units:str=None, stepped:bool=False, update_existing:bool=True):
|
|
446
|
+
"""Create a Tag With Metadata, and batch import points in a single function
|
|
447
|
+
|
|
448
|
+
Args:
|
|
449
|
+
tag: Name of the tag to create, either including datasource, or using datasource defined when instantiating historian multi object
|
|
450
|
+
points: A dict, or list of dicts of the form {"value": x, "timestamp": y}. Where x is an int/double and y is a python datetime, iso datetime string, or epoch timestamp
|
|
451
|
+
description (Optional): A concise summary of the tags purpose/usage. Defaults to blank/null
|
|
452
|
+
units (Optional): The engineering unit recorded by the value. Defaults to blank/null
|
|
453
|
+
stepped (Optional): Classify whether the measurement is continuous or discrete. Defaults to false
|
|
454
|
+
update_existing (Optional): Whether this function should overwrite metadata of any existing tags referenced. Defaults to True
|
|
455
|
+
|
|
456
|
+
Returns:
|
|
457
|
+
A dict with keys "success" containing a bool, and "errors" that present any tags that failed to be created with metadata
|
|
458
|
+
|
|
459
|
+
Raises:
|
|
460
|
+
URLError: When no Ingenuity instance could be found at given EigenServer, or no internet connection is available
|
|
461
|
+
RemoteServerException: When the provided historian could not be found, or the API response contains an error
|
|
462
|
+
RunTimeError/HTTPError: No response from the API
|
|
463
|
+
"""
|
|
464
|
+
url = self.metaurl + "/create"
|
|
465
|
+
|
|
466
|
+
if "/" not in tag:
|
|
467
|
+
tag = self.historian + tag
|
|
468
|
+
|
|
469
|
+
metadata = {}
|
|
470
|
+
|
|
471
|
+
for key, value in [("description", description), ("units", units), ("stepped", stepped)]:
|
|
472
|
+
if value is not None:
|
|
473
|
+
metadata[key] = value
|
|
474
|
+
|
|
475
|
+
body = {
|
|
476
|
+
"entries": {
|
|
477
|
+
f"{tag}": metadata
|
|
478
|
+
},
|
|
479
|
+
"updateIfExists": update_existing
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
createResp = _do_historian_multi_request(url,body,self.auth)
|
|
483
|
+
|
|
484
|
+
if len(createResp["errors"].keys()):
|
|
485
|
+
createSuccess = False
|
|
486
|
+
else:
|
|
487
|
+
createSuccess = True
|
|
488
|
+
|
|
489
|
+
message = _do_historian_multi_request(self.writeurl,body,self.auth,True)
|
|
490
|
+
|
|
491
|
+
if message == 'All points written!':
|
|
492
|
+
writeSuccess = True
|
|
493
|
+
else:
|
|
494
|
+
ret = writeSuccess = True
|
|
495
|
+
|
|
496
|
+
return {"success": createSuccess and writeSuccess, "createTag": {"success": createSuccess, "errors": createResp["errors"]}, "writePoints": {"success": writeSuccess, "message": message}}
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
#SECTION - Write Requests
|
|
500
|
+
|
|
501
|
+
|
|
349
502
|
def writePoints(self, tag:str, points: Union[dict, list]):
|
|
350
503
|
"""Write one or more points to a single tag
|
|
351
504
|
|
|
@@ -436,6 +589,7 @@ class HistorianMulti (object):
|
|
|
436
589
|
|
|
437
590
|
return ret
|
|
438
591
|
|
|
592
|
+
#SECTION - Utility Functions
|
|
439
593
|
|
|
440
594
|
def createPoint(value:Union[int,float],timestamp:Union[int,str,datetime],status:str="OK"):
|
|
441
595
|
"""Quickly Create a dict of the format required to push data to historians
|
|
@@ -64,7 +64,7 @@ def _convert_sys_argv_(func):
|
|
|
64
64
|
def build(path:str='.', config:str='config.ini', configsection:str='', 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
66
|
no_duplicates:bool=False, allow_blanks:list=[], replace_blanks:str='', batch:int=0, auth:bool=False, order:str='qnrc', filetypes:str='qnrc', primary_property:str='',
|
|
67
|
-
required_labels:list=[], required_properties:list=[], database:str='0', verify:bool=False, summarise:bool=False, show_queries:bool=False, show_returns:bool=False,
|
|
67
|
+
required_labels:list=[], required_properties:list=[], required_relationship_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
|
|
@@ -100,6 +100,7 @@ def build(path:str='.', config:str='config.ini', configsection:str='', file:str=
|
|
|
100
100
|
primary_property: Primary property
|
|
101
101
|
required_labels: Required labels - appended to contents of config; use !Label to remove
|
|
102
102
|
required_properties: Required properties - appended to contents of config; use !property to remove
|
|
103
|
+
required_relationship_properties: Required relationship properties - appended to contents of config; use !property to remove
|
|
103
104
|
|
|
104
105
|
# What output is required
|
|
105
106
|
verify: Display the generated queries, but do not process them
|
|
@@ -50,7 +50,8 @@ class ConfigManager:
|
|
|
50
50
|
# Overrides... used to override values in the config file
|
|
51
51
|
parser.add_argument('-pp', '--primaryproperty', default='', help='Primary node_key')
|
|
52
52
|
parser.add_argument('-rl', '--requiredlabels', default='', help='Required labels - appended to contents of config; use !Label to remove')
|
|
53
|
-
parser.add_argument('-rp', '--requiredproperties', default='', help='Required properties - appended to contents of config; use !
|
|
53
|
+
parser.add_argument('-rp', '--requiredproperties', default='', help='Required properties - appended to contents of config; use !property to remove')
|
|
54
|
+
parser.add_argument('-rrp', '--requiredrelationshipproperties', default='', help='Required relationship properties - appended to contents of config; use !property to remove')
|
|
54
55
|
|
|
55
56
|
# And finally specify what output is required
|
|
56
57
|
parser.add_argument('-v', '--verify', action='store_true', help='Display the generated queries, but do not process them')
|
|
@@ -106,6 +107,7 @@ class ConfigManager:
|
|
|
106
107
|
self.primary_property_override = args.primaryproperty
|
|
107
108
|
self.required_labels_override = args.requiredlabels
|
|
108
109
|
self.required_properties_override = args.requiredproperties
|
|
110
|
+
self.required_relationship_properties_override = args.requiredrelationshipproperties
|
|
109
111
|
|
|
110
112
|
self.db_name = args.database
|
|
111
113
|
self.validation_mode = args.verify
|
|
@@ -148,8 +150,6 @@ class ConfigManager:
|
|
|
148
150
|
|
|
149
151
|
if self.auth:
|
|
150
152
|
settings.disable_azure_auth(False)
|
|
151
|
-
## settings.set_azure_client_id('74efa022-e6d6-42ad-bc15-edc76c525bdd')
|
|
152
|
-
## settings.set_azure_tenant_id('74efa022-e6d6-42ad-bc15-edc76c525bdf')
|
|
153
153
|
else:
|
|
154
154
|
settings.disable_azure_auth(True)
|
|
155
155
|
|
|
@@ -270,6 +270,10 @@ class ConfigManager:
|
|
|
270
270
|
self.required_properties_dict = {}
|
|
271
271
|
self.unrequired_properties_list = {}
|
|
272
272
|
|
|
273
|
+
self.required_relationship_properties_dict = {}
|
|
274
|
+
self.unrequired_relationship_properties_list = {}
|
|
275
|
+
self.required_relationships_dict = {}
|
|
276
|
+
|
|
273
277
|
self.no_system_properties = self.get_config_value(self.common_section, "SystemProperties", "on").lower() != 'on' or self.no_system_properties
|
|
274
278
|
if self.no_system_properties:
|
|
275
279
|
self.no_version = True
|
|
@@ -281,6 +285,8 @@ class ConfigManager:
|
|
|
281
285
|
|
|
282
286
|
for s in self.available_sections:
|
|
283
287
|
self.required_properties_dict[s], self.unrequired_properties_list[s] = pm.combine_required_properties(self.get_config_value_list(s, "RequiredProperties", ""), [self.required_properties_override], self.default_data_type[s])
|
|
288
|
+
self.required_relationship_properties_dict[s], self.unrequired_relationship_properties_list[s] = pm.combine_required_properties(self.get_config_value_list(s, "RequiredRelationshipProperties", ""), [self.required_relationship_properties_override], self.default_data_type[s])
|
|
289
|
+
self.required_relationships_dict[s] = self.get_config_value_dict(s, "RequiredRelationships", "")
|
|
284
290
|
|
|
285
291
|
try:
|
|
286
292
|
self.header_mappings_dict[s] = {i.replace('=', '->').split('->')[0].rstrip(): i.replace('=', '->').split('->')[1].lstrip() for i in header_mappings[s]}
|
|
@@ -312,6 +318,25 @@ class ConfigManager:
|
|
|
312
318
|
else:
|
|
313
319
|
return []
|
|
314
320
|
|
|
321
|
+
def get_config_value_dict(self, section, option, default=None):
|
|
322
|
+
# Get a node_value from the settings file, reporting an error if it's missing
|
|
323
|
+
try:
|
|
324
|
+
raw_value = self.config[section][option] or default
|
|
325
|
+
except:
|
|
326
|
+
if default is not None:
|
|
327
|
+
raw_value = default
|
|
328
|
+
else:
|
|
329
|
+
self.error_list += [f'No value found for {option} in the configuration file']
|
|
330
|
+
raw_value = ''
|
|
331
|
+
# Reformat from a single string of comma separated values to a Dictionary
|
|
332
|
+
# removing leading and trailing spaces while we're at it
|
|
333
|
+
if raw_value:
|
|
334
|
+
values = [(i.strip()+':').split(':') for i in raw_value.split(',')]
|
|
335
|
+
# If v[1] is blank, it means no key was provided, only a value (in v[0]), so use it for both key and value
|
|
336
|
+
return {v[0]: v[1] if v[1] != '' else v[0] for v in values}
|
|
337
|
+
else:
|
|
338
|
+
return {}
|
|
339
|
+
|
|
315
340
|
def get_config_value(self, section, option, default=None):
|
|
316
341
|
# Get a node_value from the settings file, reporting an error if it's missing
|
|
317
342
|
value_list = self.get_config_value_list(section, option, default)
|
|
@@ -417,6 +442,15 @@ class ConfigManager:
|
|
|
417
442
|
def get_unrequired_properties_list(self):
|
|
418
443
|
return self.unrequired_properties_list
|
|
419
444
|
|
|
445
|
+
def get_required_relationship_properties_dict(self):
|
|
446
|
+
return self.required_relationship_properties_dict
|
|
447
|
+
|
|
448
|
+
def get_unrequired_relationship_properties_list(self):
|
|
449
|
+
return self.unrequired_relationship_properties_list
|
|
450
|
+
|
|
451
|
+
def get_required_relationships_dict(self):
|
|
452
|
+
return self.required_relationships_dict
|
|
453
|
+
|
|
420
454
|
def get_unique_id_property(self):
|
|
421
455
|
return self.unique_id_property
|
|
422
456
|
|
|
@@ -118,6 +118,13 @@ class CSVContentsManager:
|
|
|
118
118
|
columns_list = [this_row[i] for i in column_numbers if len(this_row[i]) > 0]
|
|
119
119
|
return columns_list
|
|
120
120
|
|
|
121
|
+
def get_column_values_dict(self, row_number, column_numbers):
|
|
122
|
+
# Return the values in the given row, for the columns in the provided list (skips empty values)
|
|
123
|
+
# Returned as a List (of strings)
|
|
124
|
+
this_row = self.data_list[row_number]
|
|
125
|
+
columns_list = {self.mapped_keys[i]: this_row[i] for i in column_numbers if len(this_row[i]) > 0}
|
|
126
|
+
return columns_list
|
|
127
|
+
|
|
121
128
|
def get_column_values_list_with_formatted_keys(self, row_number, column_numbers):
|
|
122
129
|
# Return the values in the given row, for the columns in the provided list (skips empty values)
|
|
123
130
|
# Returned as a List (of strings)
|
|
@@ -21,6 +21,8 @@ class FileAnalyser():
|
|
|
21
21
|
self.relationship_alias = config.get_relationship_alias()[section]
|
|
22
22
|
self.ignore_nodes = config.get_ignore_nodes()
|
|
23
23
|
|
|
24
|
+
self.num_required_relationships = len(config.get_required_relationships_dict()[section])
|
|
25
|
+
|
|
24
26
|
self.node_types = amu.node_types
|
|
25
27
|
self.from_types = amu.from_types
|
|
26
28
|
self.to_types = amu.to_types
|
|
@@ -39,16 +41,21 @@ class FileAnalyser():
|
|
|
39
41
|
match file_format:
|
|
40
42
|
case 'csv':
|
|
41
43
|
try:
|
|
42
|
-
with open(file_name
|
|
44
|
+
with open(file_name) as csv_file:
|
|
43
45
|
csv_data = csv.reader(csv_file, delimiter=self.separator)
|
|
44
46
|
contents = CSVContentsManager(csv_data, self.header_mappings, self.alias_mappings, self.default_data_type)
|
|
45
47
|
except:
|
|
46
48
|
try:
|
|
47
|
-
with open(file_name) as csv_file:
|
|
49
|
+
with open(file_name, encoding='utf-8') as csv_file:
|
|
48
50
|
csv_data = csv.reader(csv_file, delimiter=self.separator)
|
|
49
51
|
contents = CSVContentsManager(csv_data, self.header_mappings, self.alias_mappings, self.default_data_type)
|
|
50
52
|
except:
|
|
51
|
-
|
|
53
|
+
try:
|
|
54
|
+
with open(file_name, encoding='iso-8859-1') as csv_file:
|
|
55
|
+
csv_data = csv.reader(csv_file, delimiter=self.separator)
|
|
56
|
+
contents = CSVContentsManager(csv_data, self.header_mappings, self.alias_mappings, self.default_data_type)
|
|
57
|
+
except:
|
|
58
|
+
return 'incorrect file format', contents, []
|
|
52
59
|
case _:
|
|
53
60
|
pass
|
|
54
61
|
|
|
@@ -71,7 +78,7 @@ class FileAnalyser():
|
|
|
71
78
|
|
|
72
79
|
# Check if there are at least one each of From, To and Relationship (including aliases) columns
|
|
73
80
|
# If so, this could be a Relationship file
|
|
74
|
-
if num_from_columns > 0 and num_to_columns > 0 and num_relation_columns > 0:
|
|
81
|
+
if num_from_columns > 0 and num_to_columns > 0 and num_relation_columns + self.num_required_relationships > 0:
|
|
75
82
|
could_be_relations = True
|
|
76
83
|
else:
|
|
77
84
|
could_be_relations = False
|
|
@@ -19,6 +19,9 @@ class RelationshipFileProcessor:
|
|
|
19
19
|
self.add_system_properties = not config.get_no_system_properties()
|
|
20
20
|
|
|
21
21
|
self.required_labels = config.get_required_labels()[section]
|
|
22
|
+
self.required_properties = config.get_required_relationship_properties_dict()[section]
|
|
23
|
+
self.unrequired_properties = config.get_unrequired_relationship_properties_list()[section]
|
|
24
|
+
self.required_relationships = config.get_required_relationships_dict()[section]
|
|
22
25
|
self.creation_time_property = config.get_creation_time_property()[section]
|
|
23
26
|
self.update_time_property = config.get_update_time_property()[section]
|
|
24
27
|
|
|
@@ -76,9 +79,17 @@ class RelationshipFileProcessor:
|
|
|
76
79
|
last_row = self.get_last_row(num_data_rows)
|
|
77
80
|
while this_row < last_row:
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
combined_relationships = {**self.required_relationships, **self.contents.get_column_values_dict(this_row, relation_columns)}
|
|
83
|
+
relationships = rm.validate_relationships(list(combined_relationships.values()))
|
|
84
|
+
|
|
85
|
+
row_properties = self.contents.get_property_values_dict(this_row, property_columns, self.blank_property_list, blank_override=self.blank_property_override)
|
|
86
|
+
properties = pm.combine_properties(self.required_properties, row_properties)
|
|
87
|
+
for unwanted in self.unrequired_properties:
|
|
88
|
+
temp = properties.pop(unwanted, None)
|
|
89
|
+
|
|
90
|
+
# Split out those properties that are dependent on others, so that we can add them in the right order
|
|
91
|
+
explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
|
|
80
92
|
|
|
81
|
-
properties = self.contents.get_property_values_dict(this_row, property_columns, self.blank_property_list, blank_override=self.blank_property_override)
|
|
82
93
|
# If there are multiple From or To nodes, create a relationship query for each combination
|
|
83
94
|
for from_node in self.contents.get_property_values_list(this_row, from_columns, self.primary_property, self.primary_property):
|
|
84
95
|
validated_csv_from_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, from_label_columns))
|
|
@@ -110,8 +121,11 @@ class RelationshipFileProcessor:
|
|
|
110
121
|
update_time = relation_ref_dot + self.update_time_property + '=datetime("' + time_now + '")'
|
|
111
122
|
query_text = query_text.on_create().set_literal(create_time).set_literal(update_time)
|
|
112
123
|
|
|
113
|
-
if len(
|
|
114
|
-
query_text = query_text.set(properties=
|
|
124
|
+
if len(explicit_properties) > 0:
|
|
125
|
+
query_text = query_text.set(properties=explicit_properties, property_ref=relation_ref_dot)
|
|
126
|
+
if len(calculated_properties) > 0:
|
|
127
|
+
query_text = query_text.set(properties=calculated_properties, property_ref=relation_ref_dot)
|
|
128
|
+
|
|
115
129
|
query_text = query_text.toStr()
|
|
116
130
|
query = Neo4jQuery('relationship', query_text, time_now)
|
|
117
131
|
|
|
@@ -164,8 +178,15 @@ class RelationshipFileProcessor:
|
|
|
164
178
|
this_row = self.start_from-1
|
|
165
179
|
last_row = self.get_last_row(num_data_rows)
|
|
166
180
|
while this_row < last_row:
|
|
167
|
-
|
|
168
|
-
|
|
181
|
+
|
|
182
|
+
combined_relationships = {**self.required_relationships, **self.contents.get_column_values_dict(this_row, relation_columns)}
|
|
183
|
+
relationships = rm.validate_relationships(list(combined_relationships.values()))
|
|
184
|
+
|
|
185
|
+
row_properties = self.contents.get_property_values_dict(this_row, property_columns, self.blank_property_list, blank_override=self.blank_property_override)
|
|
186
|
+
properties = pm.combine_properties(self.required_properties, row_properties)
|
|
187
|
+
for unwanted in self.unrequired_properties:
|
|
188
|
+
temp = properties.pop(unwanted, None)
|
|
189
|
+
|
|
169
190
|
# If there are multiple From or To nodes, create a relationship query for each combination
|
|
170
191
|
for from_node in self.contents.get_property_values_list(this_row, from_columns, self.primary_property, self.primary_property):
|
|
171
192
|
validated_csv_from_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, from_label_columns))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: python-eigen-ingenuity-nocli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.12
|
|
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
|
|
@@ -19,6 +19,14 @@ Requires-Dist: pyarrow
|
|
|
19
19
|
Requires-Dist: neo4j>=5.17.0
|
|
20
20
|
Requires-Dist: requests>=2.31.0
|
|
21
21
|
Requires-Dist: dateparser
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: description-content-type
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: license
|
|
28
|
+
Dynamic: requires-dist
|
|
29
|
+
Dynamic: summary
|
|
22
30
|
|
|
23
31
|
# About<a id="about"></a>
|
|
24
32
|
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/README-nocli.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/auth.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/sql.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/eigeningenuity/util.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
|
|
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_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/pyproject.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.11b2 → python_eigen_ingenuity_nocli-0.5.12}/requirements.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|