python-eigen-ingenuity 0.5.12b2__py3-none-any.whl → 0.5.12b3__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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: python-eigen-ingenuity
3
- Version: 0.5.12b2
3
+ Version: 0.5.12b3
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
@@ -4,7 +4,7 @@ eigeningenuity/auth.py,sha256=RjmtLBS6m4YhDZJa7RgB4RYWJDhE4zd-9tKeOz0iNug,7578
4
4
  eigeningenuity/elastic.py,sha256=WG4nlsJXNs_-m76jtj46UfgvLgWLvn6d6QW2dk7LBI4,6648
5
5
  eigeningenuity/events.py,sha256=wUc1TkT7047gduNuNfzkSO5tK13ErJdeI2K5cPXhNCY,3336
6
6
  eigeningenuity/historian.py,sha256=sWHOCYPPRV9nbIkLsSiJeJLpuX3CtrAFlU2l1CLn0B4,36337
7
- eigeningenuity/historianmulti.py,sha256=EoXxuCT5lNqoENC9mK1aHDnN_KDQK554ka_x73t4Jb8,20587
7
+ eigeningenuity/historianmulti.py,sha256=GlJufh6ZG3N8WD1v8Tx9b3amuRDaeQGBlFeV4X_58vw,27338
8
8
  eigeningenuity/settings.py,sha256=sCY7AONBrc0IWSa3D37Scu_JapQoEBfJbRbY7BdDoBM,4212
9
9
  eigeningenuity/smartdash.py,sha256=spzoRXO4tu7cDAd4cwbyxo9RBnYvjbJoXQq8zbXkMEw,3009
10
10
  eigeningenuity/sql.py,sha256=y-IMu1fdZjMGFcg7ue7Ubhr0-BDTiUW01x8I7tSR700,5059
@@ -38,8 +38,8 @@ modelbuilder/src/processors/relationshipmanager.py,sha256=lDtE_5AdKzL3boq7VD8Gmp
38
38
  modelbuilder/src/queries/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  modelbuilder/src/queries/cypherbuilder.py,sha256=VpUGuPo-Ba3skjCVBFjmxm4ORQBGgF5cDiQYnK67hLA,10418
40
40
  modelbuilder/src/queries/query.py,sha256=fEkGv49yxeL0Sz5bMmC3-Dt0_9qoZBz37hsTY8pQVIA,2568
41
- python_eigen_ingenuity-0.5.12b2.dist-info/METADATA,sha256=r23ZB9B3su76EEhT1pxudTAeb2zbLVg8ySOmIcaYqTs,38358
42
- python_eigen_ingenuity-0.5.12b2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
43
- python_eigen_ingenuity-0.5.12b2.dist-info/entry_points.txt,sha256=G3LjFQX5xKaN4mqtqCL8uaC-gRbP5T5x9r0gBTJTXXA,70
44
- python_eigen_ingenuity-0.5.12b2.dist-info/top_level.txt,sha256=lFiZ43CY_1bmdtRidIXbA6rrY2d92Rs-9tH8pcgI-XU,28
45
- python_eigen_ingenuity-0.5.12b2.dist-info/RECORD,,
41
+ python_eigen_ingenuity-0.5.12b3.dist-info/METADATA,sha256=52NPhCwZ67m9KBCLKOixkEQm9qum6VwVP3FEv80uGcg,38358
42
+ python_eigen_ingenuity-0.5.12b3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
43
+ python_eigen_ingenuity-0.5.12b3.dist-info/entry_points.txt,sha256=G3LjFQX5xKaN4mqtqCL8uaC-gRbP5T5x9r0gBTJTXXA,70
44
+ python_eigen_ingenuity-0.5.12b3.dist-info/top_level.txt,sha256=lFiZ43CY_1bmdtRidIXbA6rrY2d92Rs-9tH8pcgI-XU,28
45
+ python_eigen_ingenuity-0.5.12b3.dist-info/RECORD,,