python-eigen-ingenuity-nocli 0.5.12b2__tar.gz → 0.5.13b1__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.
Files changed (53) hide show
  1. {python_eigen_ingenuity_nocli-0.5.12b2/python_eigen_ingenuity_nocli.egg-info → python_eigen_ingenuity_nocli-0.5.13b1}/PKG-INFO +1 -1
  2. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/historianmulti.py +154 -0
  3. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/csvcontentsmanager.py +1 -0
  4. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/fileanalyser.py +2 -2
  5. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/filemanager.py +15 -5
  6. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/property.py +2 -1
  7. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/queries/query.py +1 -1
  8. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1/python_eigen_ingenuity_nocli.egg-info}/PKG-INFO +1 -1
  9. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/MANIFEST.in +0 -0
  10. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/README-nocli.md +0 -0
  11. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/README.md +0 -0
  12. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/__init__.py +0 -0
  13. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/assetmodel.py +0 -0
  14. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/auth.py +0 -0
  15. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/core/__init__.py +0 -0
  16. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/elastic.py +0 -0
  17. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/events.py +0 -0
  18. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/historian.py +0 -0
  19. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/settings.py +0 -0
  20. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/smartdash.py +0 -0
  21. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/sql.py +0 -0
  22. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/eigeningenuity/util.py +0 -0
  23. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/__init__.py +0 -0
  24. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/__init__.py +0 -0
  25. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/assetmodelbuilder.py +0 -0
  26. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/assetmodelcsvwriter.py +0 -0
  27. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/assetmodelutilities.py +0 -0
  28. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/configmanager.py +0 -0
  29. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/connectors/__init__.py +0 -0
  30. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/connectors/boltconnector.py +0 -0
  31. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/connectors/dbconnectors.py +0 -0
  32. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/connectors/genericconnector.py +0 -0
  33. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/connectors/httpsconnector.py +0 -0
  34. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/csvwriter.py +0 -0
  35. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/messages.py +0 -0
  36. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/processors/__init__.py +0 -0
  37. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/processors/cypherfileprocessor.py +0 -0
  38. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/processors/labelmanager.py +0 -0
  39. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/processors/nodefileprocessor.py +0 -0
  40. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/processors/propertymanager.py +0 -0
  41. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/processors/relationshipfileprocessor.py +0 -0
  42. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/processors/relationshipmanager.py +0 -0
  43. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/queries/__init__.py +0 -0
  44. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/queries/cypherbuilder.py +0 -0
  45. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/modelbuilder/src/versionmanager.py +0 -0
  46. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/pyproject.toml +0 -0
  47. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/python_eigen_ingenuity_nocli.egg-info/SOURCES.txt +0 -0
  48. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/python_eigen_ingenuity_nocli.egg-info/dependency_links.txt +0 -0
  49. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/python_eigen_ingenuity_nocli.egg-info/requires.txt +0 -0
  50. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/python_eigen_ingenuity_nocli.egg-info/top_level.txt +0 -0
  51. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/requirements.txt +0 -0
  52. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/setup.cfg +0 -0
  53. {python_eigen_ingenuity_nocli-0.5.12b2 → python_eigen_ingenuity_nocli-0.5.13b1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: python-eigen-ingenuity-nocli
3
- Version: 0.5.12b2
3
+ Version: 0.5.13b1
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
@@ -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
@@ -10,6 +10,7 @@ class CSVContentsManager:
10
10
  def __init__(self, csv_data, header_mappings, alias_mappings, default_data_type):
11
11
  file_headers = next(csv_data)
12
12
  data_list = list(csv_data)
13
+ # self.data_list = [[j.replace('!nl!', '\n') for j in i] for i in data_list if len(i) > 0 and not i[0].startswith('#')]
13
14
  self.data_list = [i for i in data_list if len(i) > 0 and not i[0].startswith('#')]
14
15
  unmapped_keys = []
15
16
  mapped_keys = []
@@ -41,12 +41,12 @@ class FileAnalyser():
41
41
  match file_format:
42
42
  case 'csv':
43
43
  try:
44
- with open(file_name) as csv_file:
44
+ with open(file_name, encoding='utf-8') as csv_file:
45
45
  csv_data = csv.reader(csv_file, delimiter=self.separator)
46
46
  contents = CSVContentsManager(csv_data, self.header_mappings, self.alias_mappings, self.default_data_type)
47
47
  except:
48
48
  try:
49
- with open(file_name, encoding='utf-8') as csv_file:
49
+ with open(file_name) as csv_file:
50
50
  csv_data = csv.reader(csv_file, delimiter=self.separator)
51
51
  contents = CSVContentsManager(csv_data, self.header_mappings, self.alias_mappings, self.default_data_type)
52
52
  except:
@@ -168,7 +168,7 @@ class FileManager:
168
168
  a_file_split = a_file.split(',')
169
169
  for a_split_file in a_file_split:
170
170
  if a_split_file != '':
171
- self.analyse_a_file(a_split_file.strip(), None)
171
+ self.analyse_a_file(a_split_file.strip(), self.config_section)
172
172
 
173
173
  query_list = self.config_manager.get_inline_query_list()
174
174
  for a_query in query_list:
@@ -374,6 +374,9 @@ class FileManager:
374
374
  except:
375
375
  display_rate = 0
376
376
 
377
+ ## total_new_nodes = 0
378
+ ## total_new_relationships = 0
379
+
377
380
  if display_rate > 0:
378
381
  message(f'0 of {num_queries} queries processed at {amu.get_formatted_time_now()}', False)
379
382
 
@@ -394,10 +397,14 @@ class FileManager:
394
397
  if result.get_status() == 200:
395
398
 
396
399
  # Display info on how many of each batch were created
397
- # new_nodes = result.get_updates()['nodes created']
398
- # new_relationships = result.get_updates()['relationships created']
399
- # if (query.type == 'batch node' and new_nodes != query.batch_size) or (query.type == 'batch relationship' and new_relationships != query.batch_size):
400
- # info_message(f'Batch {query_count} contained {query.batch_size} updates: only {new_nodes+new_relationships} created')
400
+ ## new_nodes = result.get_updates()['nodes created']
401
+ ## total_new_nodes += new_nodes
402
+ ## new_relationships = result.get_updates()['relationships created']
403
+ ## total_new_relationships += new_relationships
404
+ ## if new_nodes > 0 or new_relationships > 0:
405
+ ## if (query.type == 'batch node' and new_nodes != query.batch_size) or (query.type == 'batch relationship' and new_relationships != query.batch_size):
406
+ ## info_message(f'Batch {query_count} contained {query.batch_size} updates: only {new_nodes+new_relationships} created')
407
+ ## print(query.text)
401
408
 
402
409
  if self.report_queries:
403
410
  result.print_results('Updates made: ')
@@ -433,6 +440,9 @@ class FileManager:
433
440
  if display_rate > 0 and not self.report_queries:
434
441
  if query_count % display_rate == 0 or query_count == num_queries:
435
442
  message(f'{query_count} of {num_queries} queries processed at {amu.get_formatted_time_now()} ({query_count / num_queries * 100:.2f}%)', False)
443
+ ## message(f'{query_count} of {num_queries} queries processed at {amu.get_formatted_time_now()} ({query_count / num_queries * 100:.2f}%) Nodes: {total_new_nodes}, Relationships: {total_new_relationships}', False)
444
+ ## total_new_nodes = 0
445
+ ## total_new_relationships = 0
436
446
  else:
437
447
  message_no_cr(f'{query_count} of {num_queries} queries processed ({batch_info}{query_count / num_queries * 100:.2f}%) {chr(13)}')
438
448
 
@@ -9,7 +9,8 @@ class Neo4jProperty():
9
9
 
10
10
  self.key = pm.validate_property(key)
11
11
  # Sanitise the value
12
- self.value = value.replace('\\', '\\\\').replace('\r', '\\r').replace('\n', '\\n').replace('"', '\\"')
12
+ # self.value = value.replace('\\', '\\\\').replace('\r', '\\r').replace('\n', '\\n').replace('"', '\\"')
13
+ self.value = value.replace('\\', '\\\\').replace('\r', '\\r').replace('"', '\\"')
13
14
 
14
15
  if self.value == "":
15
16
  if blank_override:
@@ -56,7 +56,7 @@ class Neo4jQuery():
56
56
 
57
57
  def __init__(self, type, text, time=None, labels=[], new_labels=[], primary_property=[], properties={}, batch_size=1, property_count=0, section='DEFAULT'):
58
58
  self.type = type
59
- self.text = text
59
+ self.text = text.replace('!nl!', '\n')
60
60
  self.time_now = time
61
61
  self.labels = labels
62
62
  self.new_labels = new_labels
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: python-eigen-ingenuity-nocli
3
- Version: 0.5.12b2
3
+ Version: 0.5.13b1
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