python-eigen-ingenuity 0.5.24b2__py3-none-any.whl → 0.5.25__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 +96 -76
- eigeningenuity/auth.py +4 -2
- eigeningenuity/commonmenu.py +82 -78
- eigeningenuity/elastic.py +20 -5
- eigeningenuity/events.py +91 -60
- eigeningenuity/historian.py +134 -28
- eigeningenuity/historianmulti.py +244 -152
- eigeningenuity/logformatter.py +46 -1
- eigeningenuity/settings.py +39 -27
- eigeningenuity/sql.py +83 -31
- python_eigen_ingenuity-0.5.25.dist-info/METADATA +252 -0
- {python_eigen_ingenuity-0.5.24b2.dist-info → python_eigen_ingenuity-0.5.25.dist-info}/RECORD +15 -15
- {python_eigen_ingenuity-0.5.24b2.dist-info → python_eigen_ingenuity-0.5.25.dist-info}/WHEEL +1 -1
- python_eigen_ingenuity-0.5.24b2.dist-info/METADATA +0 -901
- {python_eigen_ingenuity-0.5.24b2.dist-info → python_eigen_ingenuity-0.5.25.dist-info}/entry_points.txt +0 -0
- {python_eigen_ingenuity-0.5.24b2.dist-info → python_eigen_ingenuity-0.5.25.dist-info}/top_level.txt +0 -0
eigeningenuity/assetmodel.py
CHANGED
|
@@ -37,10 +37,22 @@ requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
class AssetModel(object):
|
|
40
|
-
"""
|
|
40
|
+
"""AssetModel client for Ingenuity Neo4j API endpoints."""
|
|
41
41
|
|
|
42
42
|
def __init__(self, baseurl, auth, instance="default"):
|
|
43
|
-
"""
|
|
43
|
+
"""Initialize AssetModel client.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
baseurl (str): Base URL of the AssetModel service (e.g. https://demo.eigen.co/ei-applet/).
|
|
47
|
+
auth: Authentication credentials or session.
|
|
48
|
+
instance (str, optional): Neo4j instance name. Defaults to "default".
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
None
|
|
52
|
+
|
|
53
|
+
Docs:
|
|
54
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-assetmodel
|
|
55
|
+
"""
|
|
44
56
|
self.baseurl = baseurl
|
|
45
57
|
if instance == "default":
|
|
46
58
|
self.instance = ""
|
|
@@ -50,7 +62,14 @@ class AssetModel(object):
|
|
|
50
62
|
self.auth = auth
|
|
51
63
|
|
|
52
64
|
def _testConnection(self):
|
|
53
|
-
"""
|
|
65
|
+
"""Verify that the AssetModel endpoint is reachable.
|
|
66
|
+
|
|
67
|
+
Raises:
|
|
68
|
+
ConnectionError: If the endpoint cannot be reached.
|
|
69
|
+
|
|
70
|
+
Docs:
|
|
71
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-assetmodel
|
|
72
|
+
"""
|
|
54
73
|
try:
|
|
55
74
|
status = requests.get(self.baseurl, verify=False).status_code
|
|
56
75
|
except (URLError, ConnectionError):
|
|
@@ -61,24 +80,37 @@ class AssetModel(object):
|
|
|
61
80
|
)
|
|
62
81
|
|
|
63
82
|
def _doNeo4jQueryRequest(self, data):
|
|
83
|
+
"""Execute a Neo4j query against the configured endpoint.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
data (dict): Payload containing query information.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
dict: API response JSON.
|
|
90
|
+
|
|
91
|
+
Docs:
|
|
92
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-assetmodel
|
|
93
|
+
"""
|
|
64
94
|
# self._testConnection()
|
|
65
95
|
|
|
66
96
|
url = f"{self.baseurl}neo4j/{self.instance}query"
|
|
67
97
|
return _do_eigen_post_request(url, data, self.auth)
|
|
68
98
|
|
|
69
99
|
def executeRawQuery(self, query: str, output: str = "json"):
|
|
70
|
-
"""
|
|
71
|
-
Executes a raw neo4j query against AssetModel via the AssetModel API.
|
|
100
|
+
"""Execute a raw Neo4j query via the AssetModel API.
|
|
72
101
|
|
|
73
102
|
Args:
|
|
74
|
-
query:
|
|
103
|
+
query (str): Cypher query string.
|
|
104
|
+
output (str, optional): Output format, either "json", "df", or "raw". Defaults to "json".
|
|
75
105
|
|
|
76
106
|
Returns:
|
|
77
|
-
|
|
107
|
+
list|pandas.DataFrame|dict: Query results in the requested format.
|
|
78
108
|
|
|
79
109
|
Raises:
|
|
80
|
-
|
|
110
|
+
EigenException: If query fails.
|
|
81
111
|
|
|
112
|
+
Docs:
|
|
113
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/execute-raw-query
|
|
82
114
|
"""
|
|
83
115
|
payload = {"q": query}
|
|
84
116
|
resp = self._doNeo4jQueryRequest(payload)
|
|
@@ -102,26 +134,22 @@ class AssetModel(object):
|
|
|
102
134
|
def getMeasurements(
|
|
103
135
|
self, nodes: str, prop: str = "code", measurement: str = "", output="json"
|
|
104
136
|
):
|
|
105
|
-
"""
|
|
106
|
-
Return all measurement nodes directly related to a given asset via the AssetModel API. For historian/timeseries metadata, use the commonmenu method instead.
|
|
137
|
+
"""Fetch measurement tags related to an asset node.
|
|
107
138
|
|
|
108
139
|
Args:
|
|
109
|
-
nodes:
|
|
110
|
-
prop (
|
|
111
|
-
measurement (
|
|
140
|
+
nodes (str|list): Node identifier(s) to query.
|
|
141
|
+
prop (str, optional): Property to match on. Defaults to "code".
|
|
142
|
+
measurement (str, optional): Measurement type filter. Defaults to all.
|
|
143
|
+
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
112
144
|
|
|
113
145
|
Returns:
|
|
114
|
-
|
|
115
|
-
[
|
|
116
|
-
{"code": "AssetCode",
|
|
117
|
-
"measurementName": "MeasurementType",
|
|
118
|
-
"tag": "TagCode"},
|
|
119
|
-
...
|
|
120
|
-
]
|
|
146
|
+
list|pandas.DataFrame|dict: Measurements data.
|
|
121
147
|
|
|
122
148
|
Raises:
|
|
123
|
-
EigenException:
|
|
149
|
+
EigenException: If query fails.
|
|
124
150
|
|
|
151
|
+
Docs:
|
|
152
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-measurements
|
|
125
153
|
"""
|
|
126
154
|
nodes_list = force_list(nodes)
|
|
127
155
|
|
|
@@ -174,24 +202,21 @@ class AssetModel(object):
|
|
|
174
202
|
)
|
|
175
203
|
|
|
176
204
|
def getDocuments(self, nodes: Union[str, list], match=None, output="json"):
|
|
177
|
-
"""
|
|
178
|
-
Return all Documents related to nodes via the AssetModel API.
|
|
205
|
+
"""Fetch documents related to specified asset nodes.
|
|
179
206
|
|
|
180
207
|
Args:
|
|
181
|
-
nodes
|
|
182
|
-
match (
|
|
183
|
-
output (
|
|
184
|
-
- "raw" - The raw json returned by the API;
|
|
185
|
-
- "json" - A processed version of the json response;
|
|
186
|
-
- "df" - A formatted pandas dataframe object;
|
|
208
|
+
nodes (str|list): Asset node identifier(s).
|
|
209
|
+
match (str, optional): Filter documents by filename/description substring.
|
|
210
|
+
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
187
211
|
|
|
188
212
|
Returns:
|
|
189
|
-
|
|
190
|
-
the format is dependent on the output parameter.
|
|
213
|
+
dict|pandas.DataFrame|dict: Documents grouped by node or in raw response format.
|
|
191
214
|
|
|
192
215
|
Raises:
|
|
193
|
-
EigenException:
|
|
216
|
+
EigenException: If query fails.
|
|
194
217
|
|
|
218
|
+
Docs:
|
|
219
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-documents
|
|
195
220
|
"""
|
|
196
221
|
nodes_list = force_list(nodes)
|
|
197
222
|
|
|
@@ -259,24 +284,20 @@ class AssetModel(object):
|
|
|
259
284
|
)
|
|
260
285
|
|
|
261
286
|
def getLabels(self, codes: Union[str, list] = None, output: str = "json"):
|
|
262
|
-
"""
|
|
263
|
-
List all labels used in an assetmodel instance, or the list of all labels of given nodes
|
|
287
|
+
"""Retrieve asset node labels.
|
|
264
288
|
|
|
265
289
|
Args:
|
|
266
|
-
codes (
|
|
267
|
-
|
|
268
|
-
output (Optional): The format in which to return the data. Accepts:
|
|
269
|
-
- "json" - A processed version of the response
|
|
270
|
-
- "raw" - The raw json returned by the API
|
|
271
|
-
- "df" - A formatted pandas dataframe object
|
|
290
|
+
codes (str|list, optional): Node codes to filter by. Defaults to None (all labels).
|
|
291
|
+
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
272
292
|
|
|
273
293
|
Returns:
|
|
274
|
-
|
|
275
|
-
If codes is provided: For single code - list of labels; For multiple codes -
|
|
276
|
-
structured data with nodeCode and labels for each node
|
|
294
|
+
list|pandas.DataFrame|dict: Node labels in requested format.
|
|
277
295
|
|
|
278
296
|
Raises:
|
|
279
|
-
EigenException:
|
|
297
|
+
EigenException: If query fails.
|
|
298
|
+
|
|
299
|
+
Docs:
|
|
300
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-labels
|
|
280
301
|
"""
|
|
281
302
|
if codes is None:
|
|
282
303
|
# Get all labels in the database
|
|
@@ -359,27 +380,26 @@ class AssetModel(object):
|
|
|
359
380
|
exact: bool = False,
|
|
360
381
|
output: str = "json",
|
|
361
382
|
):
|
|
362
|
-
"""
|
|
363
|
-
Return all properties of matching nodes via a neo4j query response
|
|
383
|
+
"""Find nodes in AssetModel matching given criteria.
|
|
364
384
|
|
|
365
385
|
Args:
|
|
366
|
-
criteria:
|
|
367
|
-
- "@labels":
|
|
368
|
-
- "@ids":
|
|
369
|
-
-
|
|
370
|
-
match_all (
|
|
371
|
-
exact (
|
|
372
|
-
output (
|
|
373
|
-
- "json" - A processed version of the response
|
|
374
|
-
- "raw" - The raw json returned by the API
|
|
375
|
-
- "df" - A formatted pandas dataframe object
|
|
386
|
+
criteria (dict): Filter criteria with optional special keys:
|
|
387
|
+
- "@labels" (str|list): Node labels to match.
|
|
388
|
+
- "@ids" (str|list): Node IDs to match.
|
|
389
|
+
- Any other property to match on node properties.
|
|
390
|
+
match_all (bool, optional): All conditions (AND) if True, else any (OR). Defaults to True.
|
|
391
|
+
exact (bool, optional): Exact match for strings if True; otherwise CONTAINS is used. Defaults to False.
|
|
392
|
+
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
376
393
|
|
|
377
394
|
Returns:
|
|
378
|
-
|
|
395
|
+
list|pandas.DataFrame|dict: Matching nodes in requested format.
|
|
379
396
|
|
|
380
397
|
Raises:
|
|
381
|
-
EigenException:
|
|
382
|
-
ValueError:
|
|
398
|
+
EigenException: If query fails.
|
|
399
|
+
ValueError: If criteria is empty or invalid.
|
|
400
|
+
|
|
401
|
+
Docs:
|
|
402
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-matching-nodes
|
|
383
403
|
"""
|
|
384
404
|
|
|
385
405
|
if not criteria:
|
|
@@ -490,25 +510,23 @@ class AssetModel(object):
|
|
|
490
510
|
relation: str = None,
|
|
491
511
|
output: str = "json",
|
|
492
512
|
):
|
|
493
|
-
"""
|
|
494
|
-
Return all assets directly related to given assets.
|
|
513
|
+
"""Fetch assets related to given source asset nodes.
|
|
495
514
|
|
|
496
515
|
Args:
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
exact
|
|
500
|
-
relation
|
|
501
|
-
output (
|
|
502
|
-
- "json" - A processed version of the response
|
|
503
|
-
- "raw" - The raw json returned by the API
|
|
504
|
-
- "df" - A formatted pandas dataframe object
|
|
516
|
+
nodes (str|list): Asset identifiers to match.
|
|
517
|
+
prop (str, optional): Property used for matching. Defaults to "code".
|
|
518
|
+
exact (bool, optional): Exact matching when True, partial otherwise. Defaults to False.
|
|
519
|
+
relation (str, optional): Relationship type filter. Defaults to None.
|
|
520
|
+
output (str, optional): Output format: "json", "df", or "raw". Defaults to "json".
|
|
505
521
|
|
|
506
522
|
Returns:
|
|
507
|
-
|
|
523
|
+
list|pandas.DataFrame|dict: Related assets.
|
|
508
524
|
|
|
509
525
|
Raises:
|
|
510
|
-
EigenException:
|
|
526
|
+
EigenException: If query fails.
|
|
511
527
|
|
|
528
|
+
Docs:
|
|
529
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-related-assets
|
|
512
530
|
"""
|
|
513
531
|
nodes_list = force_list(nodes)
|
|
514
532
|
|
|
@@ -560,15 +578,17 @@ class AssetModel(object):
|
|
|
560
578
|
def get_assetmodel(
|
|
561
579
|
eigenserver: EigenServer = None, instance: str = "default"
|
|
562
580
|
) -> AssetModel:
|
|
563
|
-
"""
|
|
564
|
-
Convenience function for querying data from the Ingenuity Neo4J Assetmodel
|
|
581
|
+
"""Convenience function to instantiate an AssetModel client.
|
|
565
582
|
|
|
566
583
|
Args:
|
|
567
|
-
(
|
|
568
|
-
(
|
|
584
|
+
eigenserver (EigenServer|str|None): EigenServer instance or base URL. Defaults to EIGENSERER env var if None.
|
|
585
|
+
instance (str, optional): Neo4j instance name (default "default").
|
|
569
586
|
|
|
570
587
|
Returns:
|
|
571
|
-
|
|
588
|
+
AssetModel: Initialized AssetModel client.
|
|
589
|
+
|
|
590
|
+
Docs:
|
|
591
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/asset-model/get-assetmodel
|
|
572
592
|
"""
|
|
573
593
|
if eigenserver is None:
|
|
574
594
|
eigenserver = get_default_server()
|
eigeningenuity/auth.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import os
|
|
1
|
+
import os
|
|
2
|
+
import msal
|
|
3
|
+
import atexit
|
|
4
|
+
import keyring
|
|
2
5
|
from cryptography.fernet import Fernet
|
|
3
6
|
from getpass import getuser
|
|
4
7
|
import eigeningenuity.settings as settings
|
|
@@ -123,7 +126,6 @@ def _authenticate_azure_user(baseurl):
|
|
|
123
126
|
'Content-Type': 'application/json'
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
|
|
127
129
|
def _backup_auth_azure_user(_uri):
|
|
128
130
|
global url
|
|
129
131
|
baseurl = url
|
eigeningenuity/commonmenu.py
CHANGED
|
@@ -27,32 +27,57 @@ from eigeningenuity.util import force_list
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class CommonMenu(object):
|
|
30
|
-
"""
|
|
30
|
+
"""CommonMenu client for Ingenuity Common Menu API."""
|
|
31
31
|
|
|
32
32
|
def __init__(self, baseurl, auth):
|
|
33
|
-
"""
|
|
33
|
+
"""Initialize CommonMenu client.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
baseurl (str): Base URL for Common Menu endpoint.
|
|
37
|
+
auth: Authentication credentials or session.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
None
|
|
41
|
+
|
|
42
|
+
Docs:
|
|
43
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-common-menu
|
|
44
|
+
"""
|
|
34
45
|
self.baseurl = baseurl
|
|
35
46
|
self.auth = auth
|
|
36
47
|
|
|
37
48
|
def _doCommonMenuRequest(self, index, params):
|
|
49
|
+
"""Send request to Common Menu API.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
index (str): CommonMenu API endpoint key (e.g., 'relatedAssets').
|
|
53
|
+
params (dict): Query parameters.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
dict: Response JSON.
|
|
57
|
+
|
|
58
|
+
Docs:
|
|
59
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-common-menu
|
|
60
|
+
"""
|
|
38
61
|
# self._testConnection()
|
|
39
62
|
url = self.baseurl + "commonmenu/asset/" + index + "?"
|
|
40
63
|
return _do_eigen_json_request(url, self.auth, **params)
|
|
41
64
|
|
|
42
65
|
def getRelatedAssets(self, node: str, output="json", filepath=None):
|
|
43
|
-
"""
|
|
44
|
-
Return all measurement tags directly related to a given asset via the Common Menu API.
|
|
66
|
+
"""Fetch related assets for a given node.
|
|
45
67
|
|
|
46
68
|
Args:
|
|
47
|
-
node:
|
|
48
|
-
output (
|
|
69
|
+
node (str): Node code to query.
|
|
70
|
+
output (str, optional): Output format: "json", "df", "raw", "file". Defaults to "json".
|
|
71
|
+
filepath (str, optional): File path to save output when output="file".
|
|
49
72
|
|
|
50
73
|
Returns:
|
|
51
|
-
|
|
74
|
+
list|pandas.DataFrame|dict: Related assets.
|
|
52
75
|
|
|
53
76
|
Raises:
|
|
54
|
-
KeyError:
|
|
77
|
+
KeyError: If API response is malformed or missing expected keys.
|
|
55
78
|
|
|
79
|
+
Docs:
|
|
80
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-related-assets
|
|
56
81
|
"""
|
|
57
82
|
args = {"asset": node}
|
|
58
83
|
|
|
@@ -89,30 +114,22 @@ class CommonMenu(object):
|
|
|
89
114
|
def getMeasurements(
|
|
90
115
|
self, node: str, source: str = "all", output: str = "json", filepath: str = None
|
|
91
116
|
):
|
|
92
|
-
"""
|
|
93
|
-
Return all measurement tags directly related to a given asset via the Common Menu API.
|
|
117
|
+
"""Get measurement timeseries for an asset.
|
|
94
118
|
|
|
95
119
|
Args:
|
|
96
|
-
node
|
|
97
|
-
source:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"{sourceName}" - Timeseries related via the {sourceName}. e.g. "graphapi" or "cognite";
|
|
101
|
-
(default: "all")
|
|
102
|
-
output (Optional): The format in which to return the data. Accepts one of:
|
|
103
|
-
"raw" - The raw json returned by the API;
|
|
104
|
-
"json" - A processed version of the json response;
|
|
105
|
-
"df" - A formatted pandas dataframe object;
|
|
106
|
-
"file" - Downloads the files to a local directory;
|
|
107
|
-
(Defaults to "json")
|
|
108
|
-
filepath (Optional): Name and path to the .json file that will be created/overwritten. If omitted, will create a file in the current directory with a generated name. Has no effect unless output is "file".
|
|
120
|
+
node (str): Node code to query.
|
|
121
|
+
source (str, optional): "all", "merged", or specific source name. Defaults to "all".
|
|
122
|
+
output (str, optional): Output format: "json", "df", "raw", "file". Defaults to "json".
|
|
123
|
+
filepath (str, optional): File path to save output for output="file".
|
|
109
124
|
|
|
110
125
|
Returns:
|
|
111
|
-
|
|
126
|
+
list|pandas.DataFrame|dict: Measurements result.
|
|
112
127
|
|
|
113
128
|
Raises:
|
|
114
|
-
KeyError:
|
|
129
|
+
KeyError: If API response is malformed or missing expected keys.
|
|
115
130
|
|
|
131
|
+
Docs:
|
|
132
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-measurements
|
|
116
133
|
"""
|
|
117
134
|
args = {}
|
|
118
135
|
args["asset"] = node
|
|
@@ -154,17 +171,16 @@ class CommonMenu(object):
|
|
|
154
171
|
f.write(json.dumps(timeseries, indent=4))
|
|
155
172
|
|
|
156
173
|
def getDrivers(self):
|
|
157
|
-
"""
|
|
158
|
-
Return all measurement tags directly related to a given asset via the Common Menu API.
|
|
159
|
-
|
|
160
|
-
Args:
|
|
174
|
+
"""Retrieve available measurement driver sources.
|
|
161
175
|
|
|
162
176
|
Returns:
|
|
163
|
-
|
|
177
|
+
list: Driver source names.
|
|
164
178
|
|
|
165
179
|
Raises:
|
|
166
|
-
KeyError:
|
|
180
|
+
KeyError: If expected API fields are missing.
|
|
167
181
|
|
|
182
|
+
Docs:
|
|
183
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-drivers
|
|
168
184
|
"""
|
|
169
185
|
args = {"asset": ""}
|
|
170
186
|
|
|
@@ -186,27 +202,24 @@ class CommonMenu(object):
|
|
|
186
202
|
output: str = "json",
|
|
187
203
|
filepath: str = None,
|
|
188
204
|
):
|
|
189
|
-
"""
|
|
190
|
-
Return all Events related to nodes via the Common Menu API.
|
|
205
|
+
"""Query events for one or more assets.
|
|
191
206
|
|
|
192
207
|
Args:
|
|
193
|
-
node:
|
|
194
|
-
start
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
"df" - A formatted pandas dataframe object;
|
|
200
|
-
"file" - Downloads the files to a local directory;
|
|
201
|
-
(Defaults to "json")
|
|
202
|
-
filepath (Optional): Name and path to the directory created/used for downloaded documents. If omitted, will download files to current directory. Has no effect unless output is "download".
|
|
208
|
+
node (str|list): Asset node(s) to query.
|
|
209
|
+
start (str|int|float|datetime, optional): Start time. Defaults "24 hours ago".
|
|
210
|
+
end (str|int|float|datetime, optional): End time. Defaults "now".
|
|
211
|
+
limit (int, optional): Max events per query. Defaults to 1000.
|
|
212
|
+
output (str, optional): Output format: "json", "df", "raw", "file". Defaults to "json".
|
|
213
|
+
filepath (str, optional): File path for output="file".
|
|
203
214
|
|
|
204
215
|
Returns:
|
|
205
|
-
|
|
216
|
+
list|pandas.DataFrame|dict: Events data.
|
|
206
217
|
|
|
207
218
|
Raises:
|
|
208
|
-
KeyError:
|
|
219
|
+
KeyError: If response is malformed.
|
|
209
220
|
|
|
221
|
+
Docs:
|
|
222
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-events
|
|
210
223
|
"""
|
|
211
224
|
nodes = force_list(node)
|
|
212
225
|
results = []
|
|
@@ -239,23 +252,22 @@ class CommonMenu(object):
|
|
|
239
252
|
def getProperties(
|
|
240
253
|
self, node: str, source="all", output="json", filepath: str = None
|
|
241
254
|
):
|
|
242
|
-
"""
|
|
243
|
-
Return all properties of a node via the Assetmodel API
|
|
255
|
+
"""Retrieve properties for a node.
|
|
244
256
|
|
|
245
257
|
Args:
|
|
246
|
-
node:
|
|
247
|
-
source:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
(default: "all")
|
|
251
|
-
output:
|
|
258
|
+
node (str): Node code to query.
|
|
259
|
+
source (str, optional): Property source ("all" or specific source). Defaults to "all".
|
|
260
|
+
output (str, optional): Output format: "json", "df", "raw", "file". Defaults to "json".
|
|
261
|
+
filepath (str, optional): File path for output="file".
|
|
252
262
|
|
|
253
263
|
Returns:
|
|
254
|
-
|
|
264
|
+
dict|pandas.DataFrame|dict: Properties data.
|
|
255
265
|
|
|
256
266
|
Raises:
|
|
257
|
-
KeyError:
|
|
267
|
+
KeyError: If response is malformed.
|
|
258
268
|
|
|
269
|
+
Docs:
|
|
270
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-properties
|
|
259
271
|
"""
|
|
260
272
|
|
|
261
273
|
properties = []
|
|
@@ -306,30 +318,22 @@ class CommonMenu(object):
|
|
|
306
318
|
def getDocuments(
|
|
307
319
|
self, node: str, document_type: str = "all", output="json", filepath: str = None
|
|
308
320
|
):
|
|
309
|
-
"""
|
|
310
|
-
Return all documents of a node via the Common Menu API
|
|
321
|
+
"""Get documents for a node.
|
|
311
322
|
|
|
312
323
|
Args:
|
|
313
|
-
node:
|
|
314
|
-
document_type
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
"{typeName}" - Documents of a specific type only. e.g. "P&ID", "Process Description", etc.;
|
|
318
|
-
(default: "all")
|
|
319
|
-
output (Optional): The format in which to return the data. Accepts one of:
|
|
320
|
-
"raw" - The raw json returned by the API;
|
|
321
|
-
"json" - A processed version of the json response;
|
|
322
|
-
"df" - A formatted pandas dataframe object;
|
|
323
|
-
"file" - Downloads the files to a local directory;
|
|
324
|
-
(Defaults to "json")
|
|
325
|
-
filepath (Optional): Name and path to the .json file that will be created/overwritten. If omitted, will create a file in the current directory with a generated name. Has no effect unless output is "file".
|
|
324
|
+
node (str): Node code to query.
|
|
325
|
+
document_type (str, optional): "all", "merged", or type name. Defaults "all".
|
|
326
|
+
output (str, optional): Output format: "json", "df", "raw", "file". Defaults "json".
|
|
327
|
+
filepath (str, optional): File path for output="file".
|
|
326
328
|
|
|
327
329
|
Returns:
|
|
328
|
-
|
|
330
|
+
dict|pandas.DataFrame|list: Documents result.
|
|
329
331
|
|
|
330
332
|
Raises:
|
|
331
|
-
KeyError:
|
|
333
|
+
KeyError: If response is malformed.
|
|
332
334
|
|
|
335
|
+
Docs:
|
|
336
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-documents
|
|
333
337
|
"""
|
|
334
338
|
args = {"asset": node}
|
|
335
339
|
|
|
@@ -386,16 +390,16 @@ class CommonMenu(object):
|
|
|
386
390
|
|
|
387
391
|
|
|
388
392
|
def get_common_menu(eigenserver: EigenServer = None):
|
|
389
|
-
"""
|
|
390
|
-
Convenience function to query value from a CommonMenu instance.
|
|
391
|
-
Includes metadata from multiple drivers, and multiple ingenuity databases.
|
|
392
|
-
Only allows querying a single asset at a time. For multiple assets, use the assetmodel module instead, at the expense of data from other sources.
|
|
393
|
+
"""Create a CommonMenu client.
|
|
393
394
|
|
|
394
395
|
Args:
|
|
395
|
-
eigenserver: EigenServer instance
|
|
396
|
+
eigenserver (EigenServer|str|None): EigenServer instance or URL. Defaults to EIGENSERVER env var.
|
|
396
397
|
|
|
397
398
|
Returns:
|
|
398
|
-
CommonMenu
|
|
399
|
+
CommonMenu: CommonMenu client.
|
|
400
|
+
|
|
401
|
+
Docs:
|
|
402
|
+
https://docs.eigeningenuity.co/developing-with-eigen/python-library/common-menu/get-common-menu
|
|
399
403
|
"""
|
|
400
404
|
if eigenserver is None:
|
|
401
405
|
eigenserver = get_default_server()
|