python-eigen-ingenuity 0.5.22b1__tar.gz → 0.5.23__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.22b1/python_eigen_ingenuity.egg-info → python_eigen_ingenuity-0.5.23}/PKG-INFO +1 -1
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/__init__.py +3 -2
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/historianmulti.py +174 -2
- python_eigen_ingenuity-0.5.23/eigeningenuity/logformatter.py +96 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/util.py +45 -8
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23/python_eigen_ingenuity.egg-info}/PKG-INFO +1 -1
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/python_eigen_ingenuity.egg-info/SOURCES.txt +1 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/MANIFEST.in +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/README-nocli.md +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/README.md +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/assetmodel.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/auth.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/commonmenu.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/core/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/elastic.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/events.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/historian.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/settings.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/sql.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/common.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/config.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/demo.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/test_getCurrentDataPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/test_getInterpolatedPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/test_getInterpolatedRange.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/test_getMetaData.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/test_getRawDataPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/test_listDataTags.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/test_writePoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/common_multi.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_getClosestRawPoint.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_getCurrentDataPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_getInterpolatedPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_getInterpolatedRange.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_getMetaData.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_getRawDatapoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_listDataTags.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_tagManagement.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historianmulti/test_writePoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/run_tests.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/assetmodelbuilder.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/assetmodelcsvwriter.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/assetmodelutilities.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/configmanager.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/connectors/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/connectors/boltconnector.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/connectors/dbconnectors.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/connectors/genericconnector.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/connectors/httpsconnector.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/csvcontentsmanager.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/csvwriter.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/fileanalyser.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/filemanager.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/messages.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/processors/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/processors/cypherfileprocessor.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/processors/labelmanager.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/processors/nodefileprocessor.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/processors/propertymanager.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/processors/relationshipfileprocessor.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/processors/relationshipmanager.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/property.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/queries/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/queries/cypherbuilder.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/queries/query.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/versionmanager.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/pyproject.toml +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/python_eigen_ingenuity.egg-info/dependency_links.txt +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/python_eigen_ingenuity.egg-info/entry_points.txt +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/python_eigen_ingenuity.egg-info/requires.txt +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/python_eigen_ingenuity.egg-info/top_level.txt +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/common.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/common_multi.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/common.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/test_getCurrentDataPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/test_getInterpolatedPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/test_getInterpolatedRange.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/test_getMetaData.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/test_getRawDataPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/test_listDataTags.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian/test_writePoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/__init__.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/common_multi.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_getClosestRawPoint.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_getCurrentDataPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_getInterpolatedPoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_getInterpolatedRange.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_getMetaData.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_getRawDatapoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_listDataTags.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_tagManagement.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/eigeningenuity/historian-multi/test_writePoints.py +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/requirements.txt +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/setup.cfg +0 -0
- {python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/setup.py +0 -0
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/__init__.py
RENAMED
|
@@ -13,8 +13,6 @@ h = get_historian("instancename")
|
|
|
13
13
|
h.listDataTags()
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
17
|
-
|
|
18
16
|
try:
|
|
19
17
|
from importlib.metadata import version, PackageNotFoundError
|
|
20
18
|
except ImportError:
|
|
@@ -45,6 +43,7 @@ from eigeningenuity.settings import (
|
|
|
45
43
|
set_auth_scope,
|
|
46
44
|
)
|
|
47
45
|
from eigeningenuity.util import EigenException
|
|
46
|
+
from eigeningenuity.logformatter import log_handler
|
|
48
47
|
|
|
49
48
|
__all__ = [
|
|
50
49
|
"get_historian",
|
|
@@ -68,7 +67,9 @@ __all__ = [
|
|
|
68
67
|
"set_api_token",
|
|
69
68
|
"set_auth_scope",
|
|
70
69
|
"EigenException",
|
|
70
|
+
"log_handler",
|
|
71
71
|
]
|
|
72
|
+
|
|
72
73
|
try:
|
|
73
74
|
__version__ = version("python-eigen-ingenuity")
|
|
74
75
|
except PackageNotFoundError:
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/historianmulti.py
RENAMED
|
@@ -18,6 +18,7 @@ eigeningenuity.core) or a full URL to a JSON Bridge Historian instance.
|
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
import requests
|
|
21
|
+
import re
|
|
21
22
|
from typing import Union
|
|
22
23
|
from datetime import datetime
|
|
23
24
|
|
|
@@ -309,6 +310,179 @@ class HistorianMulti(object):
|
|
|
309
310
|
output, items, tags, timestamps, timestamp_format=self.timestamp_format
|
|
310
311
|
)
|
|
311
312
|
|
|
313
|
+
# SECTION - Tag Aggregation Requests
|
|
314
|
+
|
|
315
|
+
def getAggregates(
|
|
316
|
+
self,
|
|
317
|
+
tags: Union[str, list],
|
|
318
|
+
start: Union[int, float, str, datetime],
|
|
319
|
+
end: Union[int, float, str, datetime],
|
|
320
|
+
intervals: int = 1,
|
|
321
|
+
aggregates: Union[str, list] = None,
|
|
322
|
+
output: str = "json",
|
|
323
|
+
):
|
|
324
|
+
"""Get aggregates/statistics for one or more tags over a time range
|
|
325
|
+
|
|
326
|
+
Args:
|
|
327
|
+
tags: A datatag, or list of datatags
|
|
328
|
+
start: Start of the time range. Accepts epoch milliseconds, python datetime objects, or strings of format dd-mm-YYYYTHH:MM:DD
|
|
329
|
+
end: End of the time range. Accepts epoch milliseconds, python datetime objects, or strings of format dd-mm-YYYYTHH:MM:DD
|
|
330
|
+
intervals (Optional): Number of equal time intervals to split the time range into. One aggregate will be returned per interval. Defaults to 1
|
|
331
|
+
aggregates (Optional): A string, or list of strings of the aggregates to return. Allowed values are: "FIRST", "AVG", "NUMGOOD", "MAX", "LAST", "VAR", "MEDIAN", "NUMBAD", "MIN", "COUNT", "STDDEV". Defaults to all aggregates.
|
|
332
|
+
output (Optional): The format in which to return the data. Accepts one of:
|
|
333
|
+
- "raw" - The raw json returned by the API
|
|
334
|
+
- "json" - A processed version of the json response
|
|
335
|
+
- "df" - A formatted pandas dataframe object. Defaults to "json".
|
|
336
|
+
Returns:
|
|
337
|
+
An Object that can be used to query historian data.
|
|
338
|
+
"""
|
|
339
|
+
body = {"requests": {}}
|
|
340
|
+
allowed_aggregates = [
|
|
341
|
+
"FIRST",
|
|
342
|
+
"AVG",
|
|
343
|
+
"NUMGOOD",
|
|
344
|
+
"MAX",
|
|
345
|
+
"LAST",
|
|
346
|
+
"VAR",
|
|
347
|
+
"MEDIAN",
|
|
348
|
+
"NUMBAD",
|
|
349
|
+
"MIN",
|
|
350
|
+
"COUNT",
|
|
351
|
+
"STDDEV",
|
|
352
|
+
]
|
|
353
|
+
|
|
354
|
+
if aggregates is None:
|
|
355
|
+
aggregates = allowed_aggregates
|
|
356
|
+
aggregates = list(map(lambda x: x.upper(), aggregates))
|
|
357
|
+
aggregates = list(filter(lambda x: x in allowed_aggregates, aggregates))
|
|
358
|
+
|
|
359
|
+
if aggregates == []:
|
|
360
|
+
raise EigenException(
|
|
361
|
+
"No valid aggregates provided. Allowed aggregates are: "
|
|
362
|
+
+ ", ".join(allowed_aggregates)
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
tags = force_list(tags)
|
|
366
|
+
aggregates = force_list(aggregates)
|
|
367
|
+
|
|
368
|
+
for tag in tags:
|
|
369
|
+
fulltag = tag
|
|
370
|
+
if "/" not in tag:
|
|
371
|
+
fulltag = self.historian + tag
|
|
372
|
+
request = {
|
|
373
|
+
"type": "MULTIPLE_AGGREGATED_POINTS",
|
|
374
|
+
"tag": fulltag,
|
|
375
|
+
"details": {
|
|
376
|
+
"from": time_to_epoch_millis(start),
|
|
377
|
+
"to": time_to_epoch_millis(end),
|
|
378
|
+
"aggregates": aggregates,
|
|
379
|
+
"count": intervals,
|
|
380
|
+
},
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
body["requests"][tag] = request
|
|
384
|
+
|
|
385
|
+
response = _do_historian_multi_request(self.serverurl, body, self.auth)
|
|
386
|
+
|
|
387
|
+
return format_output(
|
|
388
|
+
output,
|
|
389
|
+
response,
|
|
390
|
+
tags,
|
|
391
|
+
timestamp_format=self.timestamp_format,
|
|
392
|
+
is_aggregate=True,
|
|
393
|
+
aggregates=aggregates,
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
def getAggregateIntervals(
|
|
397
|
+
self,
|
|
398
|
+
tags: Union[str, list],
|
|
399
|
+
start: Union[int, float, str, datetime],
|
|
400
|
+
end: Union[int, float, str, datetime],
|
|
401
|
+
interval_size: str = None,
|
|
402
|
+
aggregates: Union[str, list] = None,
|
|
403
|
+
final_interval_behavior: str = "EXCLUDE",
|
|
404
|
+
output: str = "json",
|
|
405
|
+
):
|
|
406
|
+
"""Get aggregates/statistics for one or more tags, split into specified time intervals, over a time range
|
|
407
|
+
|
|
408
|
+
Args:
|
|
409
|
+
tags: A datatag, or list of datatags
|
|
410
|
+
start: Start of the time range. Accepts epoch milliseconds, python datetime objects, or strings of format dd-mm-YYYYTHH:MM:DD
|
|
411
|
+
end: End of the time range. Accepts epoch milliseconds, python datetime objects, or strings of format dd-mm-YYYYTHH:MM:DD
|
|
412
|
+
interval_size (Optional): Duration of each sub time interval to calculate aggregates for. Format like e.g. ["1s", "1m", "1h", "1w", "1y"]. Defaults to the entire time range
|
|
413
|
+
final_interval_behavior (Optional): Behavior for the final interval if it would extend beyond the total window. Options include "INCLUDE", "EXCLUDE", etc. Defaults to "EXCLUDE".
|
|
414
|
+
aggregates (Optional): A string, or list of strings of the aggregates to return. Allowed values are: "FIRST", "AVG", "NUMGOOD", "MAX", "LAST", "VAR", "MEDIAN", "NUMBAD", "MIN", "COUNT", "STDDEV". Defaults to all aggregates.
|
|
415
|
+
output (Optional): The format in which to return the data. Accepts one of:
|
|
416
|
+
- "raw" - The raw json returned by the API
|
|
417
|
+
- "json" - A processed version of the json response
|
|
418
|
+
- "df" - A formatted pandas dataframe object. Defaults to "json".
|
|
419
|
+
Returns:
|
|
420
|
+
An Object that can be used to query historian data.
|
|
421
|
+
"""
|
|
422
|
+
start_ms = time_to_epoch_millis(start)
|
|
423
|
+
end_ms = time_to_epoch_millis(end)
|
|
424
|
+
|
|
425
|
+
allowed_final_interval_behaviors = ["INCLUDE", "EXCLUDE"]
|
|
426
|
+
final_interval_behavior = final_interval_behavior.upper()
|
|
427
|
+
if final_interval_behavior not in allowed_final_interval_behaviors:
|
|
428
|
+
raise EigenException(
|
|
429
|
+
f"final_interval_behavior must be one of: {', '.join(allowed_final_interval_behaviors)}"
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
# Calculate window duration in ms
|
|
433
|
+
window_duration_ms = end_ms - start_ms
|
|
434
|
+
|
|
435
|
+
# Parse interval_size (e.g., "1h", "30m", "5s")
|
|
436
|
+
match = re.match(r"(\d+)(s|m|h|d|w|y)", interval_size)
|
|
437
|
+
if not match:
|
|
438
|
+
raise ValueError(f"Invalid interval_size format: {interval_size}")
|
|
439
|
+
|
|
440
|
+
amount, unit = int(match.group(1)), match.group(2)
|
|
441
|
+
|
|
442
|
+
# Convert interval to milliseconds
|
|
443
|
+
unit_to_ms = {
|
|
444
|
+
"s": 1000,
|
|
445
|
+
"m": 60 * 1000,
|
|
446
|
+
"h": 60 * 60 * 1000,
|
|
447
|
+
"d": 24 * 60 * 60 * 1000,
|
|
448
|
+
"w": 7 * 24 * 60 * 60 * 1000,
|
|
449
|
+
"y": 365 * 24 * 60 * 60 * 1000, # approximate
|
|
450
|
+
}
|
|
451
|
+
interval_ms = amount * unit_to_ms[unit]
|
|
452
|
+
|
|
453
|
+
# Calculate number of intervals
|
|
454
|
+
num_intervals = window_duration_ms / interval_ms
|
|
455
|
+
|
|
456
|
+
# Adjust based on final_interval_behavior
|
|
457
|
+
if final_interval_behavior == "INCLUDE":
|
|
458
|
+
num_intervals = int(num_intervals) + (
|
|
459
|
+
1 if num_intervals % 1 > 0 else 0
|
|
460
|
+
) # Ceiling
|
|
461
|
+
elif final_interval_behavior == "EXCLUDE":
|
|
462
|
+
num_intervals = int(num_intervals) # Floor
|
|
463
|
+
|
|
464
|
+
adjusted_end_ms = start_ms + (num_intervals * interval_ms)
|
|
465
|
+
|
|
466
|
+
if num_intervals <= 0:
|
|
467
|
+
raise EigenException(
|
|
468
|
+
"Calculated number of intervals is zero or negative. Please check the interval_size and time range."
|
|
469
|
+
)
|
|
470
|
+
elif num_intervals > 1000:
|
|
471
|
+
raise EigenException(
|
|
472
|
+
f"Calculated number of intervals exceeds maximum limit of 1,000 ({num_intervals}). Please increase interval_size or reduce time range."
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
return self.getAggregates(
|
|
476
|
+
tags,
|
|
477
|
+
start_ms,
|
|
478
|
+
adjusted_end_ms,
|
|
479
|
+
intervals=num_intervals,
|
|
480
|
+
aggregates=aggregates,
|
|
481
|
+
output=output,
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
# SECTION - Tag Metadata Requests
|
|
485
|
+
|
|
312
486
|
def listDataTags(self, historian: str = None, limit: int = 100, match: str = ""):
|
|
313
487
|
"""List all tags in a historian, or those matching a wildcard
|
|
314
488
|
|
|
@@ -389,8 +563,6 @@ class HistorianMulti(object):
|
|
|
389
563
|
|
|
390
564
|
return metadata
|
|
391
565
|
|
|
392
|
-
# SECTION - Tag Metadata Requests
|
|
393
|
-
|
|
394
566
|
def createTag(
|
|
395
567
|
self,
|
|
396
568
|
tag: str,
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import traceback
|
|
3
|
+
import sys
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Function to add the filename to each line of the traceback
|
|
8
|
+
def format_traceback(exc_type, exc_value, exc_traceback, filename, configfile):
|
|
9
|
+
tb_lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
|
10
|
+
tb_lines2 = []
|
|
11
|
+
tb_lines2.append(
|
|
12
|
+
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
|
|
13
|
+
+ " - "
|
|
14
|
+
+ filename
|
|
15
|
+
+ configfile
|
|
16
|
+
+ " - ERROR - An Error Occurred\n"
|
|
17
|
+
)
|
|
18
|
+
for line in tb_lines:
|
|
19
|
+
x = line.split("\n")
|
|
20
|
+
for y in x:
|
|
21
|
+
if y != "":
|
|
22
|
+
tb_lines2.append(
|
|
23
|
+
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
|
|
24
|
+
+ " - "
|
|
25
|
+
+ filename
|
|
26
|
+
+ configfile
|
|
27
|
+
+ " - ERROR - "
|
|
28
|
+
+ y
|
|
29
|
+
+ "\n"
|
|
30
|
+
)
|
|
31
|
+
tb_lines2.append(
|
|
32
|
+
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
|
|
33
|
+
+ " - "
|
|
34
|
+
+ filename
|
|
35
|
+
+ configfile
|
|
36
|
+
+ " - ERROR - Finished Executing\n"
|
|
37
|
+
)
|
|
38
|
+
return "".join(tb_lines2)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def exception_formatter(exc_type, exc_value, exc_traceback, filename, configfile=""):
|
|
42
|
+
if configfile != "":
|
|
43
|
+
configfile = ":" + configfile
|
|
44
|
+
tb_formatted = format_traceback(
|
|
45
|
+
exc_type, exc_value, exc_traceback, filename, configfile
|
|
46
|
+
)
|
|
47
|
+
print(tb_formatted)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
sys.excepthook = exception_formatter
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def log_handler(filename, configfile=""):
|
|
54
|
+
if configfile != "":
|
|
55
|
+
configfile = ":" + configfile
|
|
56
|
+
stream_handler = logging.StreamHandler(
|
|
57
|
+
sys.stdout
|
|
58
|
+
) # By default, it logs to sys.stderr, but you can specify stdout.
|
|
59
|
+
stream_handler.setLevel(logging.INFO) # Set the log level for the stream handler
|
|
60
|
+
stream_formatter = logging.Formatter(
|
|
61
|
+
f"%(asctime)s - {filename}{configfile} - %(levelname)s - %(message)s"
|
|
62
|
+
)
|
|
63
|
+
stream_handler.setFormatter(stream_formatter)
|
|
64
|
+
|
|
65
|
+
# Get the root logger and add the stream handler to it
|
|
66
|
+
root_logger = logging.getLogger()
|
|
67
|
+
root_logger.setLevel(logging.INFO)
|
|
68
|
+
root_logger.addHandler(stream_handler)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def setup_logging(filename, configfile=""):
|
|
72
|
+
"""Set up all logging, warning, and exception handling in one call."""
|
|
73
|
+
import warnings
|
|
74
|
+
import os
|
|
75
|
+
|
|
76
|
+
# Extract just the filename if a full path is provided
|
|
77
|
+
if "/" in filename or "\\" in filename:
|
|
78
|
+
filename = os.path.basename(filename)
|
|
79
|
+
|
|
80
|
+
# Set up logging handler
|
|
81
|
+
log_handler(filename, configfile)
|
|
82
|
+
|
|
83
|
+
# Set up custom warning handler
|
|
84
|
+
def custom_warning_handler(
|
|
85
|
+
message, category, warn_filename, lineno, file=None, line=None
|
|
86
|
+
):
|
|
87
|
+
logging.warning(f"{message}\n")
|
|
88
|
+
|
|
89
|
+
warnings.filterwarnings("always", category=Warning, append=True)
|
|
90
|
+
warnings.showwarning = custom_warning_handler
|
|
91
|
+
|
|
92
|
+
# Set up custom exception handler
|
|
93
|
+
def custom_exception_handler(exc_type, exc_value, exc_traceback):
|
|
94
|
+
exception_formatter(exc_type, exc_value, exc_traceback, filename, configfile)
|
|
95
|
+
|
|
96
|
+
sys.excepthook = custom_exception_handler
|
|
@@ -166,7 +166,7 @@ def number_to_string(n):
|
|
|
166
166
|
|
|
167
167
|
def time_to_epoch_millis(t):
|
|
168
168
|
if type(t) == datetime:
|
|
169
|
-
epochmillis = t.timestamp()
|
|
169
|
+
epochmillis = t.timestamp() * 1000
|
|
170
170
|
elif type(t) == int or type(t) == float:
|
|
171
171
|
if t > 100000000000:
|
|
172
172
|
epochmillis = int(t)
|
|
@@ -613,7 +613,9 @@ def _do_historian_multi_request(
|
|
|
613
613
|
return resp
|
|
614
614
|
|
|
615
615
|
|
|
616
|
-
def _reformat_multi_response(original_dict):
|
|
616
|
+
def _reformat_multi_response(original_dict, is_aggregate=False):
|
|
617
|
+
if is_aggregate:
|
|
618
|
+
return original_dict
|
|
617
619
|
reformatted_dict = {}
|
|
618
620
|
|
|
619
621
|
for key, value in original_dict.items():
|
|
@@ -625,15 +627,37 @@ def _reformat_multi_response(original_dict):
|
|
|
625
627
|
continue
|
|
626
628
|
else:
|
|
627
629
|
# Extract the list of data points from either 'dataPoints' or 'dataPoint' key
|
|
628
|
-
data_points =
|
|
630
|
+
data_points = (
|
|
631
|
+
value.get("dataPoints", None) or value.get("dataPoint", None) or value
|
|
632
|
+
)
|
|
629
633
|
# Assign the data points list directly to the top-level key
|
|
630
634
|
reformatted_dict[key] = data_points
|
|
631
635
|
|
|
632
636
|
return reformatted_dict
|
|
633
637
|
|
|
634
638
|
|
|
635
|
-
def format_output(
|
|
636
|
-
|
|
639
|
+
def format_output(
|
|
640
|
+
output,
|
|
641
|
+
response,
|
|
642
|
+
tags,
|
|
643
|
+
timestamps=False,
|
|
644
|
+
timestamp_format="iso",
|
|
645
|
+
is_aggregate=False,
|
|
646
|
+
aggregates=[],
|
|
647
|
+
):
|
|
648
|
+
if is_aggregate:
|
|
649
|
+
items = {}
|
|
650
|
+
aggregates_lower = [agg.lower() for agg in aggregates]
|
|
651
|
+
for tag, data in response["results"].items():
|
|
652
|
+
items[tag] = []
|
|
653
|
+
for agg in data["aggregates"]:
|
|
654
|
+
filtered_agg = {
|
|
655
|
+
k: v
|
|
656
|
+
for k, v in agg.items()
|
|
657
|
+
if k.lower() in ["from", "to", "tag", *aggregates_lower]
|
|
658
|
+
}
|
|
659
|
+
items[tag].append(filtered_agg)
|
|
660
|
+
elif not timestamps:
|
|
637
661
|
items = response["results"]
|
|
638
662
|
else:
|
|
639
663
|
items = response
|
|
@@ -642,19 +666,32 @@ def format_output(output, response, tags, timestamps=False, timestamp_format="is
|
|
|
642
666
|
return response
|
|
643
667
|
elif output == "json":
|
|
644
668
|
if len(tags) == 1 and (not timestamps or len(timestamps) == 1):
|
|
645
|
-
return _reformat_multi_response(items[tags[0]])
|
|
669
|
+
return _reformat_multi_response(items[tags[0]], is_aggregate)
|
|
646
670
|
else:
|
|
647
|
-
return _reformat_multi_response(items)
|
|
671
|
+
return _reformat_multi_response(items, is_aggregate)
|
|
648
672
|
elif output == "string":
|
|
649
673
|
return json.dumps(items, indent=4)
|
|
650
674
|
elif output == "df":
|
|
651
|
-
|
|
675
|
+
if is_aggregate:
|
|
676
|
+
return aggregate_response_to_df(items)
|
|
677
|
+
else:
|
|
678
|
+
return multi_response_to_df(items)
|
|
652
679
|
|
|
653
680
|
raise EigenException(
|
|
654
681
|
"Unrecognised Output Type. Must be one of ['raw','json','string','df']"
|
|
655
682
|
)
|
|
656
683
|
|
|
657
684
|
|
|
685
|
+
def aggregate_response_to_df(items):
|
|
686
|
+
rows = []
|
|
687
|
+
for tag, data in items.items():
|
|
688
|
+
data = force_list(data)
|
|
689
|
+
for entry in data:
|
|
690
|
+
rows.append({"tag": tag, **entry})
|
|
691
|
+
df = pd.DataFrame(rows).set_index("tag")
|
|
692
|
+
return df
|
|
693
|
+
|
|
694
|
+
|
|
658
695
|
class EigenException(Exception):
|
|
659
696
|
pass
|
|
660
697
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/assetmodel.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/commonmenu.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/core/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/historian.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/eigeningenuity/settings.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.22b1 → python_eigen_ingenuity-0.5.23}/local-tests/historian/__init__.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
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/configmanager.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-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/csvwriter.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/fileanalyser.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/filemanager.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/messages.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
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/property.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/queries/query.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity-0.5.22b1 → python_eigen_ingenuity-0.5.23}/modelbuilder/src/versionmanager.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.22b1 → python_eigen_ingenuity-0.5.23}/regressiontests/__init__.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|