python-eigen-ingenuity 0.5.25b2__py3-none-any.whl → 0.5.26__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.
- eigeningenuity/assetmodel.py +5 -5
- eigeningenuity/commonmenu.py +5 -5
- eigeningenuity/core/__init__.py +9 -3
- eigeningenuity/events.py +2 -2
- eigeningenuity/historianmulti.py +7 -7
- eigeningenuity/logformatter.py +40 -7
- eigeningenuity/util.py +142 -0
- {python_eigen_ingenuity-0.5.25b2.dist-info → python_eigen_ingenuity-0.5.26.dist-info}/METADATA +1 -1
- {python_eigen_ingenuity-0.5.25b2.dist-info → python_eigen_ingenuity-0.5.26.dist-info}/RECORD +12 -12
- {python_eigen_ingenuity-0.5.25b2.dist-info → python_eigen_ingenuity-0.5.26.dist-info}/WHEEL +0 -0
- {python_eigen_ingenuity-0.5.25b2.dist-info → python_eigen_ingenuity-0.5.26.dist-info}/entry_points.txt +0 -0
- {python_eigen_ingenuity-0.5.25b2.dist-info → python_eigen_ingenuity-0.5.26.dist-info}/top_level.txt +0 -0
eigeningenuity/assetmodel.py
CHANGED
|
@@ -104,7 +104,7 @@ class AssetModel(object):
|
|
|
104
104
|
output (str, optional): Output format, either "json", "df", or "raw". Defaults to "json".
|
|
105
105
|
|
|
106
106
|
Returns:
|
|
107
|
-
list|pandas.DataFrame|dict: Query results in the requested format.
|
|
107
|
+
list|pandas.DataFrame|dict|None: Query results in the requested format. Returns None if output="file".
|
|
108
108
|
|
|
109
109
|
Raises:
|
|
110
110
|
EigenException: If query fails.
|
|
@@ -143,7 +143,7 @@ class AssetModel(object):
|
|
|
143
143
|
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
144
144
|
|
|
145
145
|
Returns:
|
|
146
|
-
list|pandas.DataFrame|dict: Measurements data.
|
|
146
|
+
list|pandas.DataFrame|dict|None: Measurements data. Returns None if output="file".
|
|
147
147
|
|
|
148
148
|
Raises:
|
|
149
149
|
EigenException: If query fails.
|
|
@@ -291,7 +291,7 @@ class AssetModel(object):
|
|
|
291
291
|
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
292
292
|
|
|
293
293
|
Returns:
|
|
294
|
-
list|pandas.DataFrame|dict: Node labels in requested format.
|
|
294
|
+
list|pandas.DataFrame|dict|None: Node labels in requested format. Returns None if output="file".
|
|
295
295
|
|
|
296
296
|
Raises:
|
|
297
297
|
EigenException: If query fails.
|
|
@@ -392,7 +392,7 @@ class AssetModel(object):
|
|
|
392
392
|
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
393
393
|
|
|
394
394
|
Returns:
|
|
395
|
-
list|pandas.DataFrame|dict: Matching nodes in requested format.
|
|
395
|
+
list|pandas.DataFrame|dict|None: Matching nodes in requested format. Returns None if output="file".
|
|
396
396
|
|
|
397
397
|
Raises:
|
|
398
398
|
EigenException: If query fails.
|
|
@@ -520,7 +520,7 @@ class AssetModel(object):
|
|
|
520
520
|
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
521
521
|
|
|
522
522
|
Returns:
|
|
523
|
-
list|pandas.DataFrame|dict: Related assets.
|
|
523
|
+
list|pandas.DataFrame|dict|None: Related assets. Returns None if output="file".
|
|
524
524
|
|
|
525
525
|
Raises:
|
|
526
526
|
EigenException: If query fails.
|
eigeningenuity/commonmenu.py
CHANGED
|
@@ -71,7 +71,7 @@ class CommonMenu(object):
|
|
|
71
71
|
filepath (str, optional): File path to save output when output="file".
|
|
72
72
|
|
|
73
73
|
Returns:
|
|
74
|
-
list|pandas.DataFrame|dict: Related assets.
|
|
74
|
+
list|pandas.DataFrame|dict|None: Related assets. Returns None if output="file".
|
|
75
75
|
|
|
76
76
|
Raises:
|
|
77
77
|
KeyError: If API response is malformed or missing expected keys.
|
|
@@ -123,7 +123,7 @@ class CommonMenu(object):
|
|
|
123
123
|
filepath (str, optional): File path to save output for output="file".
|
|
124
124
|
|
|
125
125
|
Returns:
|
|
126
|
-
list|pandas.DataFrame|dict: Measurements result.
|
|
126
|
+
list|pandas.DataFrame|dict|None: Measurements result. Returns None if output="file".
|
|
127
127
|
|
|
128
128
|
Raises:
|
|
129
129
|
KeyError: If API response is malformed or missing expected keys.
|
|
@@ -213,7 +213,7 @@ class CommonMenu(object):
|
|
|
213
213
|
filepath (str, optional): File path for output="file".
|
|
214
214
|
|
|
215
215
|
Returns:
|
|
216
|
-
list|pandas.DataFrame|dict: Events data.
|
|
216
|
+
list|pandas.DataFrame|dict|None: Events data. Returns None if output="file".
|
|
217
217
|
|
|
218
218
|
Raises:
|
|
219
219
|
KeyError: If response is malformed.
|
|
@@ -261,7 +261,7 @@ class CommonMenu(object):
|
|
|
261
261
|
filepath (str, optional): File path for output="file".
|
|
262
262
|
|
|
263
263
|
Returns:
|
|
264
|
-
dict|pandas.DataFrame|
|
|
264
|
+
dict|pandas.DataFrame|None: Properties data. Returns None if output="file".
|
|
265
265
|
|
|
266
266
|
Raises:
|
|
267
267
|
KeyError: If response is malformed.
|
|
@@ -327,7 +327,7 @@ class CommonMenu(object):
|
|
|
327
327
|
filepath (str, optional): File path for output="file".
|
|
328
328
|
|
|
329
329
|
Returns:
|
|
330
|
-
dict|pandas.DataFrame|list: Documents result.
|
|
330
|
+
dict|pandas.DataFrame|list|None: Documents result. Returns None if output="file".
|
|
331
331
|
|
|
332
332
|
Raises:
|
|
333
333
|
KeyError: If response is malformed.
|
eigeningenuity/core/__init__.py
CHANGED
|
@@ -22,6 +22,7 @@ import warnings
|
|
|
22
22
|
from eigeningenuity.util import (
|
|
23
23
|
_do_eigen_json_request,
|
|
24
24
|
EigenException,
|
|
25
|
+
_construct_trace_headers,
|
|
25
26
|
)
|
|
26
27
|
import eigeningenuity.settings as settings
|
|
27
28
|
|
|
@@ -59,13 +60,16 @@ class EigenServer(object):
|
|
|
59
60
|
baseurl = "http://localhost:8080/"
|
|
60
61
|
|
|
61
62
|
if settings._azure_auth_enabled_:
|
|
62
|
-
|
|
63
|
+
|
|
64
|
+
headers = _construct_trace_headers({}, preflight=True)
|
|
65
|
+
preflight = requests.get(baseurl + "/historian/list", verify=False, headers=headers)
|
|
63
66
|
|
|
64
67
|
# Old Method, not sure if any servers still use this and cant use the new one, but backwards compatibility
|
|
65
68
|
if preflight.status_code != 200:
|
|
66
69
|
preflight = requests.get(
|
|
67
70
|
baseurl + "historian-servlet/jsonbridge/calc?cmd=LISTHISTORIANS",
|
|
68
71
|
verify=False,
|
|
72
|
+
headers=headers,
|
|
69
73
|
)
|
|
70
74
|
|
|
71
75
|
if preflight.status_code != 200:
|
|
@@ -89,10 +93,12 @@ class EigenServer(object):
|
|
|
89
93
|
return self.__baseurl
|
|
90
94
|
|
|
91
95
|
def listDataSources(self):
|
|
92
|
-
|
|
96
|
+
headers = _construct_trace_headers({}, preflight=True)
|
|
97
|
+
return _do_eigen_json_request(self.__baseurl + "historian/list", headers)
|
|
93
98
|
|
|
94
99
|
def listWritableDataSources(self):
|
|
95
|
-
|
|
100
|
+
headers = _construct_trace_headers({}, preflight=True)
|
|
101
|
+
return _do_eigen_json_request(self.__baseurl + "historian/listwritable", headers)
|
|
96
102
|
|
|
97
103
|
def getHistorian(self, *args, **kwargs):
|
|
98
104
|
warnings.warn(
|
eigeningenuity/events.py
CHANGED
|
@@ -284,7 +284,7 @@ class EventLog(object):
|
|
|
284
284
|
eventlog (str, optional): Eventlog name to query. Defaults to "default".
|
|
285
285
|
|
|
286
286
|
Returns:
|
|
287
|
-
dict
|
|
287
|
+
dict|bool: Success status and any errors.
|
|
288
288
|
|
|
289
289
|
Raises:
|
|
290
290
|
ValueError: If event_ids is not provided.
|
|
@@ -328,7 +328,7 @@ class EventLog(object):
|
|
|
328
328
|
events (Union[dict, list]): Single event dict, list of dicts, or filepath to file containing events.
|
|
329
329
|
|
|
330
330
|
Returns:
|
|
331
|
-
bool
|
|
331
|
+
bool|dict: True if all events succeeded, else dict with errors.
|
|
332
332
|
|
|
333
333
|
Raises:
|
|
334
334
|
URLError: If no Ingenuity instance can be reached or no internet connection is available.
|
eigeningenuity/historianmulti.py
CHANGED
|
@@ -80,7 +80,7 @@ class HistorianMulti(object):
|
|
|
80
80
|
output (str, optional): Output format selector. Accepts "json", "df", "raw", "string". Defaults to "json".
|
|
81
81
|
|
|
82
82
|
Returns:
|
|
83
|
-
dict
|
|
83
|
+
dict|list|pandas.DataFrame|str: Latest values for the tags. Format depends on output parameter.
|
|
84
84
|
|
|
85
85
|
Raises:
|
|
86
86
|
ValueError: When invalid Output Type is given
|
|
@@ -124,7 +124,7 @@ class HistorianMulti(object):
|
|
|
124
124
|
output (str, optional): Output format selector. Accepts "json", "df", "raw", "string". Defaults to "json".
|
|
125
125
|
|
|
126
126
|
Returns:
|
|
127
|
-
dict
|
|
127
|
+
dict|list|pandas.DataFrame|str: Interpolated values at the specified timestamps. Format depends on output parameter.
|
|
128
128
|
|
|
129
129
|
Raises:
|
|
130
130
|
ValueError: When invalid Output Type is given
|
|
@@ -180,7 +180,7 @@ class HistorianMulti(object):
|
|
|
180
180
|
output (str, optional): Output format selector. Accepts "json", "df", "raw", "string". Defaults to "json".
|
|
181
181
|
|
|
182
182
|
Returns:
|
|
183
|
-
dict
|
|
183
|
+
dict|list|pandas.DataFrame|str: Evenly spaced interpolated points. Format depends on output parameter.
|
|
184
184
|
|
|
185
185
|
Raises:
|
|
186
186
|
ValueError: When invalid Output Type is given
|
|
@@ -237,7 +237,7 @@ class HistorianMulti(object):
|
|
|
237
237
|
output (str, optional): Output format selector. Accepts "json", "df", "raw", "string". Defaults to "json".
|
|
238
238
|
|
|
239
239
|
Returns:
|
|
240
|
-
dict
|
|
240
|
+
dict|list|pandas.DataFrame|str: Raw stored points. Format depends on output parameter.
|
|
241
241
|
|
|
242
242
|
Raises:
|
|
243
243
|
ValueError: When invalid Output Type is given
|
|
@@ -292,7 +292,7 @@ class HistorianMulti(object):
|
|
|
292
292
|
output (str, optional): Output format selector. Accepts "json", "df", "raw", "string". Defaults to "json".
|
|
293
293
|
|
|
294
294
|
Returns:
|
|
295
|
-
dict
|
|
295
|
+
dict|list|pandas.DataFrame|str: Closest raw points to the timestamps. Format depends on output parameter.
|
|
296
296
|
|
|
297
297
|
Raises:
|
|
298
298
|
ValueError: When invalid Output Type is given
|
|
@@ -366,7 +366,7 @@ class HistorianMulti(object):
|
|
|
366
366
|
output (str, optional): Output format selector. Accepts "json", "df", "raw", "string". Defaults to "json".
|
|
367
367
|
|
|
368
368
|
Returns:
|
|
369
|
-
dict
|
|
369
|
+
dict|list|pandas.DataFrame|str: Aggregate statistics. Format depends on output parameter.
|
|
370
370
|
|
|
371
371
|
Raises:
|
|
372
372
|
ValueError: When invalid Output Type is given
|
|
@@ -457,7 +457,7 @@ class HistorianMulti(object):
|
|
|
457
457
|
output (str, optional): Output format selector. Accepts "json", "df", "raw", "string". Defaults to "json".
|
|
458
458
|
|
|
459
459
|
Returns:
|
|
460
|
-
dict
|
|
460
|
+
dict|list|pandas.DataFrame|str: Aggregates split into intervals. Format depends on output parameter.
|
|
461
461
|
|
|
462
462
|
Raises:
|
|
463
463
|
ValueError: When invalid Output Type is given or invalid interval_size format.
|
eigeningenuity/logformatter.py
CHANGED
|
@@ -2,7 +2,7 @@ import datetime
|
|
|
2
2
|
import traceback
|
|
3
3
|
import sys
|
|
4
4
|
import logging
|
|
5
|
-
|
|
5
|
+
from eigeningenuity.util import _get_external_callsite
|
|
6
6
|
|
|
7
7
|
# Function to add the filename to each line of the traceback
|
|
8
8
|
def format_traceback(exc_type, exc_value, exc_traceback, filename, configfile):
|
|
@@ -74,22 +74,45 @@ def exception_formatter(exc_type, exc_value, exc_traceback, filename, configfile
|
|
|
74
74
|
sys.excepthook = exception_formatter
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
def
|
|
77
|
+
def _resolve_log_level(log_level):
|
|
78
|
+
"""Resolve string/int log levels into a logging module level integer."""
|
|
79
|
+
if isinstance(log_level, int):
|
|
80
|
+
return log_level
|
|
81
|
+
|
|
82
|
+
if isinstance(log_level, str):
|
|
83
|
+
level_name = log_level.strip().upper()
|
|
84
|
+
resolved = logging.getLevelName(level_name)
|
|
85
|
+
if isinstance(resolved, int):
|
|
86
|
+
return resolved
|
|
87
|
+
|
|
88
|
+
raise ValueError(
|
|
89
|
+
"Invalid log level. Use an int or one of: DEBUG, INFO, WARNING, ERROR, CRITICAL"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def log_handler(filename, configfile="", log_level=logging.INFO):
|
|
78
94
|
"""Configure root logger to output formatted messages to stdout.
|
|
79
95
|
|
|
80
96
|
Args:
|
|
81
97
|
filename (str): Base filename context for log entries.
|
|
82
98
|
configfile (str, optional): Configfile suffix. Defaults to "".
|
|
83
99
|
|
|
100
|
+
Args:
|
|
101
|
+
filename (str): Base filename context for log entries.
|
|
102
|
+
configfile (str, optional): Configfile suffix. Defaults to "".
|
|
103
|
+
log_level (Union[int, str], optional): Logging level. Defaults to logging.INFO.
|
|
104
|
+
|
|
84
105
|
Returns:
|
|
85
106
|
None
|
|
86
107
|
"""
|
|
108
|
+
resolved_level = _resolve_log_level(log_level)
|
|
109
|
+
|
|
87
110
|
if configfile != "":
|
|
88
111
|
configfile = ":" + configfile
|
|
89
112
|
stream_handler = logging.StreamHandler(
|
|
90
113
|
sys.stdout
|
|
91
114
|
) # By default, it logs to sys.stderr, but you can specify stdout.
|
|
92
|
-
stream_handler.setLevel(
|
|
115
|
+
stream_handler.setLevel(resolved_level)
|
|
93
116
|
stream_formatter = logging.Formatter(
|
|
94
117
|
f"%(asctime)s - {filename}{configfile} - %(levelname)s - %(message)s"
|
|
95
118
|
)
|
|
@@ -97,11 +120,11 @@ def log_handler(filename, configfile=""):
|
|
|
97
120
|
|
|
98
121
|
# Get the root logger and add the stream handler to it
|
|
99
122
|
root_logger = logging.getLogger()
|
|
100
|
-
root_logger.setLevel(
|
|
123
|
+
root_logger.setLevel(resolved_level)
|
|
101
124
|
root_logger.addHandler(stream_handler)
|
|
102
125
|
|
|
103
126
|
|
|
104
|
-
def setup_logging(filename, configfile=""):
|
|
127
|
+
def setup_logging(filename="", configfile="", log_level=logging.INFO, level=None):
|
|
105
128
|
"""Initialize logging, warning, and exception handlers. Fomratted to include timestamps and script filename.
|
|
106
129
|
|
|
107
130
|
This function is for use in scripts that run on containers, where the only logging output is stdout, and the filename context is important for distinguishing log entries.
|
|
@@ -111,6 +134,8 @@ def setup_logging(filename, configfile=""):
|
|
|
111
134
|
Args:
|
|
112
135
|
filename (str): Base filename context for log entries.
|
|
113
136
|
configfile (str, optional): Configfile suffix. Defaults to "".
|
|
137
|
+
log_level (Union[int, str], optional): Logging level. Defaults to logging.INFO.
|
|
138
|
+
level (Union[int, str], optional): Backward-compatible alias for log_level.
|
|
114
139
|
|
|
115
140
|
Returns:
|
|
116
141
|
None
|
|
@@ -118,7 +143,11 @@ def setup_logging(filename, configfile=""):
|
|
|
118
143
|
import warnings
|
|
119
144
|
import os
|
|
120
145
|
import atexit
|
|
121
|
-
|
|
146
|
+
|
|
147
|
+
if filename == "":
|
|
148
|
+
caller = _get_external_callsite()
|
|
149
|
+
filename = caller["file"] if caller and "file" in caller else "unknown"
|
|
150
|
+
|
|
122
151
|
# Extract just the filename if a full path is provided
|
|
123
152
|
if "/" in filename or "\\" in filename:
|
|
124
153
|
filename = os.path.basename(filename)
|
|
@@ -126,8 +155,12 @@ def setup_logging(filename, configfile=""):
|
|
|
126
155
|
if "/" in configfile or "\\" in configfile:
|
|
127
156
|
configfile = os.path.basename(configfile)
|
|
128
157
|
|
|
158
|
+
# Backward-compatible alias support for existing callers.
|
|
159
|
+
if level is not None:
|
|
160
|
+
log_level = level
|
|
161
|
+
|
|
129
162
|
# Set up logging handler
|
|
130
|
-
log_handler(filename, configfile)
|
|
163
|
+
log_handler(filename, configfile, log_level=log_level)
|
|
131
164
|
|
|
132
165
|
# Set up custom warning handler
|
|
133
166
|
def custom_warning_handler(
|
eigeningenuity/util.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import re
|
|
3
3
|
import time
|
|
4
|
+
import os
|
|
5
|
+
import inspect
|
|
6
|
+
import socket
|
|
4
7
|
import requests
|
|
5
8
|
import csv
|
|
6
9
|
import logging
|
|
@@ -38,6 +41,8 @@ def _do_eigen_json_request(requesturl, auth, **params):
|
|
|
38
41
|
if settings._api_token_value_:
|
|
39
42
|
headers["X-Api-Key"] = settings._api_token_value_
|
|
40
43
|
|
|
44
|
+
headers.update(_construct_trace_headers(headers))
|
|
45
|
+
|
|
41
46
|
if params:
|
|
42
47
|
# Build parameter list, handling multiple values per key
|
|
43
48
|
param_list = []
|
|
@@ -101,6 +106,8 @@ def _do_eigen_post_request(requesturl, payload, auth):
|
|
|
101
106
|
|
|
102
107
|
if settings._api_token_value_:
|
|
103
108
|
headers["X-Api-Key"] = settings._api_token_value_
|
|
109
|
+
|
|
110
|
+
headers.update(_construct_trace_headers(headers))
|
|
104
111
|
|
|
105
112
|
resp = requests.post(requesturl, json=payload, headers=headers, verify=False)
|
|
106
113
|
|
|
@@ -132,6 +139,8 @@ def _do_chunked_eigen_post_request(requesturl, data, label, auth):
|
|
|
132
139
|
|
|
133
140
|
if settings._api_token_value_:
|
|
134
141
|
headers["X-Api-Key"] = settings._api_token_value_
|
|
142
|
+
|
|
143
|
+
headers.update(_construct_trace_headers(headers))
|
|
135
144
|
|
|
136
145
|
chunks = list(divide_chunks(data, 500))
|
|
137
146
|
failures = []
|
|
@@ -585,6 +594,137 @@ def update_keys(my_dict, historian):
|
|
|
585
594
|
}
|
|
586
595
|
|
|
587
596
|
|
|
597
|
+
def _get_external_callsite(package_root=None):
|
|
598
|
+
"""Return the first non-library callsite from the current stack.
|
|
599
|
+
|
|
600
|
+
This helps us attribute requests to user code (filename/line/function)
|
|
601
|
+
without requiring every public API method to pass explicit metadata.
|
|
602
|
+
"""
|
|
603
|
+
if package_root is None:
|
|
604
|
+
package_root = os.path.dirname(__file__)
|
|
605
|
+
|
|
606
|
+
package_root = os.path.normcase(os.path.abspath(package_root))
|
|
607
|
+
frame = inspect.currentframe()
|
|
608
|
+
|
|
609
|
+
try:
|
|
610
|
+
# Skip this helper and its immediate caller.
|
|
611
|
+
frame = frame.f_back
|
|
612
|
+
if frame is not None:
|
|
613
|
+
frame = frame.f_back
|
|
614
|
+
|
|
615
|
+
while frame is not None:
|
|
616
|
+
filename = os.path.normcase(os.path.abspath(frame.f_code.co_filename))
|
|
617
|
+
if not filename.startswith(package_root):
|
|
618
|
+
function_name = frame.f_code.co_name
|
|
619
|
+
if function_name == "<module>":
|
|
620
|
+
function_name = "module"
|
|
621
|
+
frame_info = inspect.getframeinfo(frame)
|
|
622
|
+
source_line = ""
|
|
623
|
+
if frame_info.code_context:
|
|
624
|
+
source_line = frame_info.code_context[0].strip()
|
|
625
|
+
return {
|
|
626
|
+
"file": os.path.basename(frame.f_code.co_filename),
|
|
627
|
+
"line": frame.f_lineno,
|
|
628
|
+
"function": function_name,
|
|
629
|
+
"source": source_line,
|
|
630
|
+
}
|
|
631
|
+
frame = frame.f_back
|
|
632
|
+
finally:
|
|
633
|
+
# Avoid reference cycles with frame objects.
|
|
634
|
+
del frame
|
|
635
|
+
|
|
636
|
+
return None
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
def _get_library_api_callsite(package_name="eigeningenuity", exclude_modules=None):
|
|
640
|
+
"""Return the user-facing library API frame as class/method metadata.
|
|
641
|
+
|
|
642
|
+
Walks outward through stack frames and prefers the outermost public method
|
|
643
|
+
(method name not starting with "_") in the first contiguous package call
|
|
644
|
+
chain. Falls back to the outermost package frame when only internal helpers
|
|
645
|
+
are present.
|
|
646
|
+
"""
|
|
647
|
+
if exclude_modules is None:
|
|
648
|
+
exclude_modules = {"eigeningenuity.util"}
|
|
649
|
+
|
|
650
|
+
frame = inspect.currentframe()
|
|
651
|
+
|
|
652
|
+
try:
|
|
653
|
+
# Skip this helper and its immediate caller.
|
|
654
|
+
frame = frame.f_back
|
|
655
|
+
if frame is not None:
|
|
656
|
+
frame = frame.f_back
|
|
657
|
+
|
|
658
|
+
latest_public = None
|
|
659
|
+
latest_any = None
|
|
660
|
+
saw_package_chain = False
|
|
661
|
+
|
|
662
|
+
while frame is not None:
|
|
663
|
+
module_name = frame.f_globals.get("__name__", "")
|
|
664
|
+
|
|
665
|
+
# Skip excluded modules (e.g., util internals) without breaking chain detection.
|
|
666
|
+
if module_name in exclude_modules:
|
|
667
|
+
frame = frame.f_back
|
|
668
|
+
continue
|
|
669
|
+
|
|
670
|
+
if module_name.startswith(package_name):
|
|
671
|
+
saw_package_chain = True
|
|
672
|
+
method_name = frame.f_code.co_name
|
|
673
|
+
instance = frame.f_locals.get("self")
|
|
674
|
+
class_name = type(instance).__name__ if instance is not None else None
|
|
675
|
+
|
|
676
|
+
candidate = {
|
|
677
|
+
"module": module_name,
|
|
678
|
+
"class": class_name,
|
|
679
|
+
"method": method_name,
|
|
680
|
+
"api": f"{class_name}.{method_name}" if class_name else method_name,
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
latest_any = candidate
|
|
684
|
+
if not method_name.startswith("_"):
|
|
685
|
+
latest_public = candidate
|
|
686
|
+
|
|
687
|
+
elif saw_package_chain:
|
|
688
|
+
# We left the package call chain; use the outermost public API if possible.
|
|
689
|
+
break
|
|
690
|
+
|
|
691
|
+
frame = frame.f_back
|
|
692
|
+
|
|
693
|
+
return latest_public or latest_any
|
|
694
|
+
finally:
|
|
695
|
+
del frame
|
|
696
|
+
|
|
697
|
+
return None
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
def _get_machine_name():
|
|
701
|
+
"""Return the current machine/host name."""
|
|
702
|
+
return socket.gethostname()
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
def _construct_trace_headers(headers={},preflight=False):
|
|
706
|
+
"""Construct trace headers for a request based on callsite and auth context."""
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
caller = _get_external_callsite()
|
|
710
|
+
api_caller = _get_library_api_callsite()
|
|
711
|
+
machine_name = _get_machine_name()
|
|
712
|
+
api_class = api_caller["class"] if api_caller else ""
|
|
713
|
+
api_method = api_caller["method"] if api_caller else ""
|
|
714
|
+
|
|
715
|
+
if preflight:
|
|
716
|
+
headers["X-Trace-Source"] = f"traceSource={machine_name},traceScript=preflightCheck,traceClass={api_class}"
|
|
717
|
+
elif caller:
|
|
718
|
+
headers["X-Trace-Source"] = (
|
|
719
|
+
f"traceSource={machine_name},traceScript={caller['file']},traceLine={caller['line']},traceClass={api_class},traceMethod={api_method}"
|
|
720
|
+
)
|
|
721
|
+
logging.debug(
|
|
722
|
+
"Trace source: %s",
|
|
723
|
+
headers["X-Trace-Source"],
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
return headers
|
|
727
|
+
|
|
588
728
|
def _do_historian_multi_request(
|
|
589
729
|
url, body, auth, write_request=False, get_request=False, timestamp_format="iso"
|
|
590
730
|
):
|
|
@@ -601,6 +741,8 @@ def _do_historian_multi_request(
|
|
|
601
741
|
if settings._api_token_value_:
|
|
602
742
|
headers["X-Api-Key"] = settings._api_token_value_
|
|
603
743
|
|
|
744
|
+
headers.update(_construct_trace_headers(headers))
|
|
745
|
+
|
|
604
746
|
if get_request:
|
|
605
747
|
resp = requests.get(url, verify=False, headers=headers).json()
|
|
606
748
|
|
{python_eigen_ingenuity-0.5.25b2.dist-info → python_eigen_ingenuity-0.5.26.dist-info}/RECORD
RENAMED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
eigeningenuity/__init__.py,sha256=l-BMaS4ab9x7o1VRmA5MaAtto2aFLIIGGPMAfnYFSg0,2022
|
|
2
|
-
eigeningenuity/assetmodel.py,sha256=
|
|
2
|
+
eigeningenuity/assetmodel.py,sha256=UHyHRdM0BKAhE5EDs2lAnmmrZ3mfjROOV_1D42CYukU,21425
|
|
3
3
|
eigeningenuity/auth.py,sha256=cI8HX_8hNUKsj2_E4GiXusPNzVVI1pYr7P8NRaJJK2A,7595
|
|
4
|
-
eigeningenuity/commonmenu.py,sha256=
|
|
4
|
+
eigeningenuity/commonmenu.py,sha256=iewhtyN83fVNVXMrhhu4sd2FSLtqPrg8bSlidhvl-rc,14153
|
|
5
5
|
eigeningenuity/elastic.py,sha256=HwHyRHLw71v6wDl1VDercCRn6m0Lrh-4RzHSQxqTTJw,7960
|
|
6
|
-
eigeningenuity/events.py,sha256=
|
|
6
|
+
eigeningenuity/events.py,sha256=zo4dO23PeNBw5bt9O_F56qHIEQw5YgRrFi3yA5hYA44,13929
|
|
7
7
|
eigeningenuity/historian.py,sha256=urJzCUF3OwOlXY-FZvl0tVzi3KICfptYigmf3gIklOU,43518
|
|
8
|
-
eigeningenuity/historianmulti.py,sha256=
|
|
9
|
-
eigeningenuity/logformatter.py,sha256=
|
|
8
|
+
eigeningenuity/historianmulti.py,sha256=Q65J1XGiCfEkzTXvwnp7l9YwGNFs8sqBkdlQOcF6N4M,35934
|
|
9
|
+
eigeningenuity/logformatter.py,sha256=Xy-fLbYp58XXerRKsswzquyke9ujbNYNEHivRLlet9w,6291
|
|
10
10
|
eigeningenuity/settings.py,sha256=rnx4tzDN3yMQUfga-jdDoJCYhcCxa2lWSGfEAPiWdD0,3406
|
|
11
11
|
eigeningenuity/sql.py,sha256=I3NwAeOT61Cnsr5e6QxDYCrwsVJ-0h3j0VxUA6uiyGc,6165
|
|
12
|
-
eigeningenuity/util.py,sha256=
|
|
13
|
-
eigeningenuity/core/__init__.py,sha256=
|
|
12
|
+
eigeningenuity/util.py,sha256=r1JY5dVLkr_X19Z0yJTkwbOVYx4WaccOn9lM5e7ZqE8,27534
|
|
13
|
+
eigeningenuity/core/__init__.py,sha256=Js2b00QM3otnghSt7xr7Q5G54rX4aAW9efeBmkUayRk,4807
|
|
14
14
|
local-tests/__init__.py,sha256=oe1wRdOprjUbn027t5ybBBo5T9_byi-burZFgv64ND4,149
|
|
15
15
|
local-tests/common.py,sha256=dIMBplH4P4T-BlhODjD5_RLhK2uA18MxEesiIMslsG0,1766
|
|
16
16
|
local-tests/config.py,sha256=Xb2CWtmwAKOxK3abFISWa-fANRMwA4GqeO1l-F9gsZQ,767
|
|
@@ -87,8 +87,8 @@ regressiontests/eigeningenuity/historian-multi/test_getRawDatapoints.py,sha256=f
|
|
|
87
87
|
regressiontests/eigeningenuity/historian-multi/test_listDataTags.py,sha256=TcceNSjCKoiK5SJcgTH2JXfKLYxIHdQdwZWlkpGnEVM,2006
|
|
88
88
|
regressiontests/eigeningenuity/historian-multi/test_tagManagement.py,sha256=ylInBt453d1RaSih1eTTxGPZmb60UK4vMwI3UW-U1JY,4830
|
|
89
89
|
regressiontests/eigeningenuity/historian-multi/test_writePoints.py,sha256=51tfUSLUqLKcCKJ1EyhjfzoC_4OP6n1oL3zgTSkXu4s,2696
|
|
90
|
-
python_eigen_ingenuity-0.5.
|
|
91
|
-
python_eigen_ingenuity-0.5.
|
|
92
|
-
python_eigen_ingenuity-0.5.
|
|
93
|
-
python_eigen_ingenuity-0.5.
|
|
94
|
-
python_eigen_ingenuity-0.5.
|
|
90
|
+
python_eigen_ingenuity-0.5.26.dist-info/METADATA,sha256=l5-ozBVcmOeSXb7-AI2G6fAslR5Z9yi33ZLFaBg2e3c,8122
|
|
91
|
+
python_eigen_ingenuity-0.5.26.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
92
|
+
python_eigen_ingenuity-0.5.26.dist-info/entry_points.txt,sha256=G3LjFQX5xKaN4mqtqCL8uaC-gRbP5T5x9r0gBTJTXXA,70
|
|
93
|
+
python_eigen_ingenuity-0.5.26.dist-info/top_level.txt,sha256=oDWOSmlNPKNBlIEKP8_JaV01O60jTcUIt2tDkq3OD18,56
|
|
94
|
+
python_eigen_ingenuity-0.5.26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity-0.5.25b2.dist-info → python_eigen_ingenuity-0.5.26.dist-info}/top_level.txt
RENAMED
|
File without changes
|