naeural-client 2.0.0__py3-none-any.whl → 2.0.2__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.
- naeural_client/_ver.py +1 -1
- naeural_client/base/generic_session.py +11 -1
- naeural_client/base/plugin_template.py +1160 -751
- naeural_client/base/transaction.py +1 -1
- naeural_client/code_cheker/base.py +29 -2
- naeural_client/default/instance/custom_web_app_01_plugin.py +50 -17
- naeural_client/logging/base_logger.py +1 -1
- naeural_client/logging/logger_mixins/class_instance_mixin.py +2 -2
- naeural_client/logging/logger_mixins/datetime_mixin.py +3 -3
- naeural_client/logging/logger_mixins/download_mixin.py +2 -2
- naeural_client/logging/logger_mixins/general_serialization_mixin.py +2 -2
- naeural_client/logging/logger_mixins/json_serialization_mixin.py +2 -2
- naeural_client/logging/logger_mixins/pickle_serialization_mixin.py +2 -2
- naeural_client/logging/logger_mixins/process_mixin.py +2 -2
- naeural_client/logging/logger_mixins/resource_size_mixin.py +2 -2
- naeural_client/logging/logger_mixins/timers_mixin.py +2 -2
- naeural_client/logging/logger_mixins/upload_mixin.py +2 -2
- naeural_client/logging/logger_mixins/utils_mixin.py +2 -2
- {naeural_client-2.0.0.dist-info → naeural_client-2.0.2.dist-info}/METADATA +11 -11
- {naeural_client-2.0.0.dist-info → naeural_client-2.0.2.dist-info}/RECORD +22 -22
- {naeural_client-2.0.0.dist-info → naeural_client-2.0.2.dist-info}/WHEEL +0 -0
- {naeural_client-2.0.0.dist-info → naeural_client-2.0.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,37 @@
|
|
1
|
+
"""
|
2
|
+
CustomPluginTemplate
|
3
|
+
====================
|
4
|
+
|
5
|
+
The `CustomPluginTemplate` class provides an interface to the on-edge `BasePluginExecutor`, facilitating the creation of custom plugins within the Neural Edge Protocol framework system.
|
6
|
+
It exposes all methods and properties defined on the target edge nodes, allowing developers to access any functionality needed for their custom plugins.
|
7
|
+
This interface supports code completion and documentation features, enhancing the development experience.
|
8
|
+
|
9
|
+
Note that code using this class will be executed in a dedicated thread on the edge node during the plugin execution cycle.
|
10
|
+
|
11
|
+
**Example Usage:**
|
12
|
+
|
13
|
+
```python
|
14
|
+
def some_custom_code(plugin: CustomPluginTemplate):
|
15
|
+
plugin.P("Hello World") # Log a message on the edge node
|
16
|
+
obj = plugin.obj_cache.get('MyDict')
|
17
|
+
if obj is None:
|
18
|
+
obj = {
|
19
|
+
'counter': 0,
|
20
|
+
'some_data': 'some_value'
|
21
|
+
}
|
22
|
+
plugin.obj_cache['MyDict'] = obj
|
23
|
+
|
24
|
+
obj['counter'] += 1
|
25
|
+
plugin.P(f"Counter: {obj['counter']}") # Log the counter value
|
26
|
+
# Finally, send a payload from the edge node to the client
|
27
|
+
return obj
|
28
|
+
```
|
29
|
+
"""
|
30
|
+
|
31
|
+
|
1
32
|
class CustomPluginTemplate:
|
2
33
|
@property
|
3
|
-
def BytesIO():
|
34
|
+
def BytesIO(self):
|
4
35
|
"""
|
5
36
|
provides access to BytesIO class from io package
|
6
37
|
"""
|
@@ -11,23 +42,23 @@ class CustomPluginTemplate:
|
|
11
42
|
|
12
43
|
def DefaultDotDict(self, args):
|
13
44
|
"""
|
14
|
-
Returns a `DefaultDotDict` object that is a `dict` where you can use keys with dot
|
45
|
+
Returns a `DefaultDotDict` object that is a `dict` where you can use keys with dot
|
15
46
|
using the default initialization
|
16
|
-
|
47
|
+
|
17
48
|
Inputs
|
18
49
|
------
|
19
|
-
|
50
|
+
|
20
51
|
pass a `lambda: <type>` always
|
21
|
-
|
52
|
+
|
22
53
|
Returns
|
23
54
|
-------
|
24
55
|
DefaultDotDict : class
|
25
|
-
|
56
|
+
|
26
57
|
Example
|
27
58
|
-------
|
28
59
|
```
|
29
60
|
dct_dot = self.DefaultDotDict(lambda: str)
|
30
|
-
dct_dot.test1 = "test"
|
61
|
+
dct_dot.test1 = "test"
|
31
62
|
print(dct_dot.test1)
|
32
63
|
print(dct_dot.test2)
|
33
64
|
```
|
@@ -35,62 +66,80 @@ class CustomPluginTemplate:
|
|
35
66
|
raise NotImplementedError
|
36
67
|
|
37
68
|
@property
|
38
|
-
def ElementTree():
|
69
|
+
def ElementTree(self):
|
39
70
|
"""
|
40
71
|
provides access to ElementTree class from xml.etree package
|
41
72
|
"""
|
42
73
|
raise NotImplementedError
|
43
74
|
|
75
|
+
def LogReader(self, buff_reader, size):
|
76
|
+
"""
|
77
|
+
Returns a `LogReader` object that is used to read from a buffer reader.
|
78
|
+
|
79
|
+
Parameters
|
80
|
+
----------
|
81
|
+
buff_reader : BufferedReader
|
82
|
+
the buffer from where to read
|
83
|
+
size : int, optional
|
84
|
+
the size of the buffer. The default is 100.
|
85
|
+
|
86
|
+
Returns
|
87
|
+
-------
|
88
|
+
LogReader : class
|
89
|
+
the log reader object.
|
90
|
+
"""
|
91
|
+
raise NotImplementedError
|
92
|
+
|
44
93
|
def NestedDefaultDotDict(self, args):
|
45
94
|
"""
|
46
95
|
Returns a `NestedDefaultDotDict` object that is a `defaultdict(dict)` where you can use keys with dot
|
47
|
-
|
96
|
+
|
48
97
|
Returns
|
49
98
|
-------
|
50
99
|
defaultdict : class
|
51
|
-
|
100
|
+
|
52
101
|
Example
|
53
102
|
-------
|
54
103
|
```
|
55
104
|
dct_dot1 = self.NestedDefaultDotDict()
|
56
|
-
dct_dot1.test.a = "test"
|
105
|
+
dct_dot1.test.a = "test"
|
57
106
|
print(dct_dot1.test.a)
|
58
|
-
|
107
|
+
|
59
108
|
dct_dot2 = self.NestedDefaultDotDict({'test' : {'a' : 100, 'b' : {'c' : 200}}})
|
60
109
|
print(dct_dot2.test.a)
|
61
110
|
print(dct_dot2.test.b.c)
|
62
111
|
print(dct_dot2.test.b.unk)
|
63
|
-
|
112
|
+
|
64
113
|
"""
|
65
114
|
raise NotImplementedError
|
66
115
|
|
67
116
|
def NestedDotDict(self, args):
|
68
117
|
"""
|
69
118
|
Returns a `NestedDotDict` object that is a `dict` where you can use keys with dot
|
70
|
-
|
119
|
+
|
71
120
|
Returns
|
72
121
|
-------
|
73
122
|
defaultdict : class
|
74
|
-
|
123
|
+
|
75
124
|
Example
|
76
125
|
-------
|
77
126
|
```
|
78
127
|
dct_dot = self.NestedDotDict({'test' : {'a' : 100}})
|
79
|
-
dct_dot.test.a = "test"
|
128
|
+
dct_dot.test.a = "test"
|
80
129
|
print(dct_dot.test.a)
|
81
130
|
"""
|
82
131
|
raise NotImplementedError
|
83
132
|
|
84
133
|
@property
|
85
|
-
def OrderedDict():
|
134
|
+
def OrderedDict(self):
|
86
135
|
"""
|
87
136
|
Returns the definition for `OrderedDict`
|
88
|
-
|
137
|
+
|
89
138
|
Returns
|
90
139
|
-------
|
91
140
|
OrderedDict : class
|
92
141
|
`OrderedDict` from standard python `collections` package.
|
93
|
-
|
142
|
+
|
94
143
|
Example
|
95
144
|
-------
|
96
145
|
```
|
@@ -104,14 +153,14 @@ class CustomPluginTemplate:
|
|
104
153
|
raise NotImplementedError
|
105
154
|
|
106
155
|
@property
|
107
|
-
def PIL():
|
156
|
+
def PIL(self):
|
108
157
|
"""
|
109
158
|
provides access to PIL package
|
110
159
|
"""
|
111
160
|
raise NotImplementedError
|
112
161
|
|
113
162
|
@property
|
114
|
-
def actual_plugin_resolution():
|
163
|
+
def actual_plugin_resolution(self):
|
115
164
|
raise NotImplementedError
|
116
165
|
|
117
166
|
def add_alerter_observation(self, value, alerter):
|
@@ -123,7 +172,7 @@ class CustomPluginTemplate:
|
|
123
172
|
def add_debug_info(self, value, key):
|
124
173
|
"""
|
125
174
|
Add debug info to the witness. The information will be stored in a new line.
|
126
|
-
|
175
|
+
|
127
176
|
Parameters
|
128
177
|
----------
|
129
178
|
value : Any
|
@@ -146,12 +195,12 @@ class CustomPluginTemplate:
|
|
146
195
|
"""
|
147
196
|
Adds a payload in the plugin instance output queue. If used inside plugins
|
148
197
|
plese do NOT return the payload from _process as the payload will be duplicated
|
149
|
-
|
198
|
+
|
150
199
|
Parameters
|
151
200
|
----------
|
152
201
|
payload : GeneralPayload or dict
|
153
202
|
the payload
|
154
|
-
|
203
|
+
|
155
204
|
Returns
|
156
205
|
-------
|
157
206
|
None.
|
@@ -164,11 +213,11 @@ class CustomPluginTemplate:
|
|
164
213
|
on a already created payload object.
|
165
214
|
If used inside plugins plese do NOT return the payload from _process as the payload
|
166
215
|
will be duplicated
|
167
|
-
|
216
|
+
|
168
217
|
Parameters
|
169
218
|
----------
|
170
219
|
**kwargs : dict
|
171
|
-
|
220
|
+
|
172
221
|
Returns
|
173
222
|
-------
|
174
223
|
None.
|
@@ -193,7 +242,7 @@ class CustomPluginTemplate:
|
|
193
242
|
def alerter_add_observation(self, value, alerter):
|
194
243
|
"""
|
195
244
|
Add a new numerical value observation to the given alerter state machine instance
|
196
|
-
|
245
|
+
|
197
246
|
Parameters
|
198
247
|
----------
|
199
248
|
value : float
|
@@ -201,7 +250,7 @@ class CustomPluginTemplate:
|
|
201
250
|
that has been given via "ALERT_MODE".
|
202
251
|
alerter : str, optional
|
203
252
|
The identifier of the given alerter state machine. The default is 'default'.
|
204
|
-
|
253
|
+
|
205
254
|
Returns
|
206
255
|
-------
|
207
256
|
TYPE
|
@@ -209,26 +258,27 @@ class CustomPluginTemplate:
|
|
209
258
|
"""
|
210
259
|
raise NotImplementedError
|
211
260
|
|
212
|
-
def alerter_create(self, alerter, raise_time, lower_time, value_count, raise_thr, lower_thr, alert_mode,
|
261
|
+
def alerter_create(self, alerter, raise_time, lower_time, value_count, raise_thr, lower_thr, alert_mode,
|
262
|
+
alert_mode_lower, reduce_value, reduce_threshold, show_version):
|
213
263
|
raise NotImplementedError
|
214
264
|
|
215
265
|
def alerter_get_current_frame_state(self, observation, alerter):
|
216
266
|
"""
|
217
267
|
This function returns the possible next alerter position based on the current alerter state and the current observation.
|
218
|
-
|
268
|
+
|
219
269
|
If the current observation can change the alerter state from A to B, the function returns the position of the state B.
|
220
270
|
(this ensures that an alertable observation will be saved to the alertable state, no matter the current alerter state)
|
221
|
-
|
271
|
+
|
222
272
|
If the current observation cannot change the alerter state from A to B, the function returns the position of the state A.
|
223
|
-
|
273
|
+
|
224
274
|
Parameters
|
225
275
|
----------
|
226
276
|
observation : float
|
227
277
|
The current observation
|
228
|
-
|
278
|
+
|
229
279
|
alerter : str, optional
|
230
280
|
The alerter name, by default 'default'
|
231
|
-
|
281
|
+
|
232
282
|
Returns
|
233
283
|
-------
|
234
284
|
int
|
@@ -238,8 +288,8 @@ class CustomPluginTemplate:
|
|
238
288
|
|
239
289
|
def alerter_get_last_alert_duration(self, alerter):
|
240
290
|
"""
|
241
|
-
|
242
|
-
|
291
|
+
|
292
|
+
|
243
293
|
"""
|
244
294
|
raise NotImplementedError
|
245
295
|
|
@@ -258,12 +308,12 @@ class CustomPluginTemplate:
|
|
258
308
|
def alerter_is_alert(self, alerter):
|
259
309
|
"""
|
260
310
|
Returns `True` if the current state of the given `alerter` state machine is "raised"
|
261
|
-
|
311
|
+
|
262
312
|
Parameters
|
263
313
|
----------
|
264
314
|
alerter : str, optional
|
265
315
|
Identifier of the given alerter instance. The default is 'default'.
|
266
|
-
|
316
|
+
|
267
317
|
Returns
|
268
318
|
-------
|
269
319
|
TYPE
|
@@ -274,12 +324,12 @@ class CustomPluginTemplate:
|
|
274
324
|
def alerter_is_new_alert(self, alerter):
|
275
325
|
"""
|
276
326
|
Returns `True` if the current state of the given `alerter` state machine has just changed from "lowered" to "raised"
|
277
|
-
|
327
|
+
|
278
328
|
Parameters
|
279
329
|
----------
|
280
330
|
alerter : str, optional
|
281
331
|
Identifier of the given alerter instance. The default is 'default'.
|
282
|
-
|
332
|
+
|
283
333
|
Returns
|
284
334
|
-------
|
285
335
|
TYPE
|
@@ -290,12 +340,12 @@ class CustomPluginTemplate:
|
|
290
340
|
def alerter_is_new_lower(self, alerter):
|
291
341
|
"""
|
292
342
|
Returns `True` if the current state of the given `alerter` state machine has just changed from "raised" to "lowered"
|
293
|
-
|
343
|
+
|
294
344
|
Parameters
|
295
345
|
----------
|
296
346
|
alerter : str, optional
|
297
347
|
Identifier of the given alerter instance. The default is 'default'.
|
298
|
-
|
348
|
+
|
299
349
|
Returns
|
300
350
|
-------
|
301
351
|
TYPE
|
@@ -306,12 +356,12 @@ class CustomPluginTemplate:
|
|
306
356
|
def alerter_is_new_raise(self, alerter):
|
307
357
|
"""
|
308
358
|
Returns `True` if the current state of the given `alerter` state machine has just changed from "lowered" to "raised"
|
309
|
-
|
359
|
+
|
310
360
|
Parameters
|
311
361
|
----------
|
312
362
|
alerter : str, optional
|
313
363
|
Identifier of the given alerter instance. The default is 'default'.
|
314
|
-
|
364
|
+
|
315
365
|
Returns
|
316
366
|
-------
|
317
367
|
TYPE
|
@@ -325,15 +375,15 @@ class CustomPluginTemplate:
|
|
325
375
|
def alerter_maybe_force_lower(self, max_raised_time, alerter):
|
326
376
|
"""
|
327
377
|
Forces the given alerter to reset to "lowered" status if the current state is "raised"
|
328
|
-
|
378
|
+
|
329
379
|
Parameters
|
330
380
|
----------
|
331
381
|
alerter : str, optional
|
332
382
|
Identifier of the given alerter instance. The default is 'default'.
|
333
|
-
|
383
|
+
|
334
384
|
max_raised_time: float, optional
|
335
385
|
The number of seconds after the raised alerter is forced to lower its status
|
336
|
-
|
386
|
+
|
337
387
|
Returns
|
338
388
|
-------
|
339
389
|
TYPE
|
@@ -347,12 +397,12 @@ class CustomPluginTemplate:
|
|
347
397
|
def alerter_status_changed(self, alerter):
|
348
398
|
"""
|
349
399
|
Returns `True` if the current state of the given `alerter` state machine has just changed
|
350
|
-
|
400
|
+
|
351
401
|
Parameters
|
352
402
|
----------
|
353
403
|
alerter : str, optional
|
354
404
|
Identifier of the given alerter instance. The default is 'default'.
|
355
|
-
|
405
|
+
|
356
406
|
Returns
|
357
407
|
-------
|
358
408
|
TYPE
|
@@ -366,12 +416,12 @@ class CustomPluginTemplate:
|
|
366
416
|
def alerter_time_from_last_change(self, alerter):
|
367
417
|
"""
|
368
418
|
Returns the number of seconds from the last change of the given alerter state machine
|
369
|
-
|
419
|
+
|
370
420
|
Parameters
|
371
421
|
----------
|
372
422
|
alerter : str, optional
|
373
423
|
Identifier of the given alerter instance. The default is 'default'.
|
374
|
-
|
424
|
+
|
375
425
|
Returns
|
376
426
|
-------
|
377
427
|
TYPE
|
@@ -380,21 +430,21 @@ class CustomPluginTemplate:
|
|
380
430
|
raise NotImplementedError
|
381
431
|
|
382
432
|
@property
|
383
|
-
def alerters_names():
|
433
|
+
def alerters_names(self):
|
384
434
|
raise NotImplementedError
|
385
435
|
|
386
436
|
def archive_config_keys(self, keys, defaults):
|
387
437
|
"""
|
388
438
|
Method that allows resetting of a list of keys and saving the current value as `_LAST` keys
|
389
|
-
|
439
|
+
|
390
440
|
Parameters
|
391
441
|
----------
|
392
442
|
keys : list
|
393
443
|
List of keys to be archived.
|
394
|
-
|
444
|
+
|
395
445
|
defaults: list
|
396
446
|
List of default values for all keys. Default is None
|
397
|
-
|
447
|
+
|
398
448
|
Returns
|
399
449
|
-------
|
400
450
|
None.
|
@@ -416,18 +466,31 @@ class CustomPluginTemplate:
|
|
416
466
|
def base64_to_code(self, b64code, decompress):
|
417
467
|
raise NotImplementedError
|
418
468
|
|
469
|
+
def base64_to_img(self, b64):
|
470
|
+
"""
|
471
|
+
Transforms a base64 encoded image into a np.ndarray
|
472
|
+
Parameters
|
473
|
+
----------
|
474
|
+
b64 : str
|
475
|
+
the base64 image
|
476
|
+
Returns
|
477
|
+
-------
|
478
|
+
np.ndarray: the decoded image
|
479
|
+
"""
|
480
|
+
raise NotImplementedError
|
481
|
+
|
419
482
|
def base64_to_str(self, b64, decompress):
|
420
483
|
"""
|
421
484
|
Transforms a base64 encoded string into a normal string
|
422
|
-
|
485
|
+
|
423
486
|
Parameters
|
424
487
|
----------
|
425
488
|
b64 : str
|
426
489
|
the base64 encoded string
|
427
|
-
|
490
|
+
|
428
491
|
decompress : bool, optional
|
429
492
|
if True, the string will be decompressed after decoding. The default is False.
|
430
|
-
|
493
|
+
|
431
494
|
Returns
|
432
495
|
-------
|
433
496
|
str: the decoded string
|
@@ -437,7 +500,7 @@ class CustomPluginTemplate:
|
|
437
500
|
def basic_ts_create(self, series_min, train_hist, train_periods):
|
438
501
|
"""
|
439
502
|
Returns a basic time-series prediction model instance
|
440
|
-
|
503
|
+
|
441
504
|
Parameters
|
442
505
|
----------
|
443
506
|
series_min : int, optional
|
@@ -446,12 +509,12 @@ class CustomPluginTemplate:
|
|
446
509
|
The training window size. The default is None.
|
447
510
|
train_periods : int, optional
|
448
511
|
how many windows to use. The default is None.
|
449
|
-
|
512
|
+
|
450
513
|
Returns
|
451
514
|
-------
|
452
515
|
BasicSeriesModel() object
|
453
|
-
|
454
|
-
|
516
|
+
|
517
|
+
|
455
518
|
Example
|
456
519
|
-------
|
457
520
|
```
|
@@ -464,21 +527,21 @@ class CustomPluginTemplate:
|
|
464
527
|
def basic_ts_fit_predict(self, data, steps):
|
465
528
|
"""
|
466
529
|
Takes a list of values and directly returns predictions using a basic AR model
|
467
|
-
|
468
|
-
|
530
|
+
|
531
|
+
|
469
532
|
Parameters
|
470
533
|
----------
|
471
534
|
data : list
|
472
535
|
list of float values.
|
473
536
|
steps : int
|
474
537
|
number of prediction steps.
|
475
|
-
|
538
|
+
|
476
539
|
Returns
|
477
540
|
-------
|
478
541
|
yh : list
|
479
542
|
the `steps` predicted values.
|
480
|
-
|
481
|
-
|
543
|
+
|
544
|
+
|
482
545
|
Example
|
483
546
|
-------
|
484
547
|
```
|
@@ -488,17 +551,37 @@ class CustomPluginTemplate:
|
|
488
551
|
"""
|
489
552
|
raise NotImplementedError
|
490
553
|
|
554
|
+
@property
|
555
|
+
def bs4(self):
|
556
|
+
"""
|
557
|
+
Provides access to the bs4 library
|
558
|
+
|
559
|
+
Returns
|
560
|
+
-------
|
561
|
+
package
|
562
|
+
|
563
|
+
|
564
|
+
Example
|
565
|
+
-------
|
566
|
+
```
|
567
|
+
|
568
|
+
response = self.requests.get(url)
|
569
|
+
soup = self.bs4.BeautifulSoup(response.text, "html.parser")
|
570
|
+
```
|
571
|
+
"""
|
572
|
+
raise NotImplementedError
|
573
|
+
|
491
574
|
def cacheapi_load_json(self, default, verbose):
|
492
575
|
"""
|
493
576
|
Loads object json from the current plugin instance cache folder
|
494
|
-
|
577
|
+
|
495
578
|
Parameters
|
496
579
|
----------
|
497
580
|
default : any, optional
|
498
581
|
default value, by default {}
|
499
582
|
verbose : bool, optional
|
500
583
|
show information during process, by default True
|
501
|
-
|
584
|
+
|
502
585
|
Returns
|
503
586
|
-------
|
504
587
|
any
|
@@ -509,14 +592,14 @@ class CustomPluginTemplate:
|
|
509
592
|
def cacheapi_load_pickle(self, default, verbose):
|
510
593
|
"""
|
511
594
|
Loads object from the current plugin instance cache folder
|
512
|
-
|
595
|
+
|
513
596
|
Parameters
|
514
597
|
----------
|
515
598
|
default : any, optional
|
516
599
|
default value, by default None
|
517
600
|
verbose : bool, optional
|
518
601
|
show information during process, by default True
|
519
|
-
|
602
|
+
|
520
603
|
Returns
|
521
604
|
-------
|
522
605
|
any
|
@@ -527,12 +610,12 @@ class CustomPluginTemplate:
|
|
527
610
|
def cacheapi_save_json(self, obj, verbose):
|
528
611
|
"""
|
529
612
|
Save object json to the current plugin instance cache folder
|
530
|
-
|
613
|
+
|
531
614
|
Parameters
|
532
615
|
----------
|
533
616
|
obj : any
|
534
617
|
the json-able object to be saved
|
535
|
-
|
618
|
+
|
536
619
|
verbose : bool, optional
|
537
620
|
show information during process, by default True
|
538
621
|
"""
|
@@ -541,7 +624,7 @@ class CustomPluginTemplate:
|
|
541
624
|
def cacheapi_save_pickle(self, obj, verbose):
|
542
625
|
"""
|
543
626
|
Save object to the current plugin instance cache folder
|
544
|
-
|
627
|
+
|
545
628
|
Parameters
|
546
629
|
----------
|
547
630
|
obj : any
|
@@ -552,42 +635,42 @@ class CustomPluginTemplate:
|
|
552
635
|
raise NotImplementedError
|
553
636
|
|
554
637
|
@property
|
555
|
-
def cfg_alert_tracker_maxlen():
|
638
|
+
def cfg_alert_tracker_maxlen(self):
|
556
639
|
raise NotImplementedError
|
557
640
|
|
558
641
|
@property
|
559
|
-
def cfg_audit_dump_time():
|
642
|
+
def cfg_audit_dump_time(self):
|
560
643
|
raise NotImplementedError
|
561
644
|
|
562
645
|
@property
|
563
|
-
def cfg_cancel_witness():
|
646
|
+
def cfg_cancel_witness(self):
|
564
647
|
raise NotImplementedError
|
565
648
|
|
566
649
|
@property
|
567
|
-
def cfg_collect_payloads_until_seconds_export():
|
650
|
+
def cfg_collect_payloads_until_seconds_export(self):
|
568
651
|
raise NotImplementedError
|
569
652
|
|
570
653
|
@property
|
571
|
-
def cfg_demo_mode():
|
654
|
+
def cfg_demo_mode(self):
|
572
655
|
raise NotImplementedError
|
573
656
|
|
574
657
|
@property
|
575
|
-
def cfg_email_config():
|
658
|
+
def cfg_email_config(self):
|
576
659
|
raise NotImplementedError
|
577
660
|
|
578
661
|
@property
|
579
|
-
def cfg_interval_aggregation_seconds():
|
662
|
+
def cfg_interval_aggregation_seconds(self):
|
580
663
|
raise NotImplementedError
|
581
664
|
|
582
665
|
@property
|
583
|
-
def cfg_send_all_alerts():
|
666
|
+
def cfg_send_all_alerts(self):
|
584
667
|
raise NotImplementedError
|
585
668
|
|
586
669
|
def chatapi_ask(self, question, persona, user, set_witness, personas_folder):
|
587
670
|
"""
|
588
671
|
Simple single-function API for accessing chat backend. Provides statefullness based on
|
589
672
|
provided `user` for the caller plugin instance.
|
590
|
-
|
673
|
+
|
591
674
|
Parameters
|
592
675
|
----------
|
593
676
|
question : str
|
@@ -598,13 +681,13 @@ class CustomPluginTemplate:
|
|
598
681
|
A user name for tracking your session.
|
599
682
|
set_witness : bool, optional
|
600
683
|
If `True` then a witness will be generated. The default is True.
|
601
|
-
|
684
|
+
|
602
685
|
Returns
|
603
686
|
-------
|
604
687
|
result : str
|
605
688
|
The response.
|
606
|
-
|
607
|
-
|
689
|
+
|
690
|
+
|
608
691
|
Example
|
609
692
|
-------
|
610
693
|
```
|
@@ -612,7 +695,7 @@ class CustomPluginTemplate:
|
|
612
695
|
question="Who are you?",
|
613
696
|
persona='codegen',
|
614
697
|
user="John Doe",
|
615
|
-
)
|
698
|
+
)
|
616
699
|
```
|
617
700
|
"""
|
618
701
|
raise NotImplementedError
|
@@ -633,7 +716,7 @@ class CustomPluginTemplate:
|
|
633
716
|
----------
|
634
717
|
data - dictionary
|
635
718
|
mandatory_keys - list of mandatory keys
|
636
|
-
|
719
|
+
|
637
720
|
Returns
|
638
721
|
-------
|
639
722
|
"""
|
@@ -642,12 +725,12 @@ class CustomPluginTemplate:
|
|
642
725
|
def cmdapi_archive_all_pipelines(self, node_address):
|
643
726
|
"""
|
644
727
|
Stop all active pipelines on destination Execution Engine
|
645
|
-
|
728
|
+
|
646
729
|
Parameters
|
647
730
|
----------
|
648
731
|
node_address : str, optional
|
649
732
|
Address of the target E2 instance. The default is `None` and will run on local E2.
|
650
|
-
|
733
|
+
|
651
734
|
Returns
|
652
735
|
-------
|
653
736
|
None.
|
@@ -663,15 +746,15 @@ class CustomPluginTemplate:
|
|
663
746
|
def cmdapi_archive_pipeline(self, node_address, name):
|
664
747
|
"""
|
665
748
|
Stop and archive a active pipeline on destination Execution Engine
|
666
|
-
|
749
|
+
|
667
750
|
Parameters
|
668
751
|
----------
|
669
752
|
node_address : str, optional
|
670
753
|
destination Execution Engine, `None` will default to local Execution Engine. The default is None.
|
671
754
|
name : str, optional
|
672
|
-
Name of the pipeline. The default is `None` and will point to current pipeline where the plugin instance
|
755
|
+
Name of the pipeline. The default is `None` and will point to current pipeline where the plugin instance
|
673
756
|
is executed.
|
674
|
-
|
757
|
+
|
675
758
|
Returns
|
676
759
|
-------
|
677
760
|
None.
|
@@ -684,22 +767,22 @@ class CustomPluginTemplate:
|
|
684
767
|
def cmdapi_batch_update_instance_config(self, lst_updates, node_address):
|
685
768
|
"""
|
686
769
|
Send a batch of updates for multiple plugin instances within their individual pipelines
|
687
|
-
|
770
|
+
|
688
771
|
Parameters
|
689
772
|
----------
|
690
773
|
lst_updates : list of dicts
|
691
774
|
The list of updates for multiple plugin instances within their individual pipelines
|
692
|
-
|
775
|
+
|
693
776
|
node_address : str, optional
|
694
777
|
Destination node, by default None
|
695
|
-
|
778
|
+
|
696
779
|
Returns
|
697
780
|
-------
|
698
781
|
None.
|
699
|
-
|
782
|
+
|
700
783
|
Example
|
701
784
|
-------
|
702
|
-
|
785
|
+
|
703
786
|
```python
|
704
787
|
# in this example we are modifying the config for 2 instances of the same plugin `A_PLUGIN_01`
|
705
788
|
# within the same pipeline `test123`
|
@@ -722,7 +805,7 @@ class CustomPluginTemplate:
|
|
722
805
|
"PARAM2" : "value2",
|
723
806
|
}
|
724
807
|
},
|
725
|
-
]
|
808
|
+
]
|
726
809
|
plugin.cmdapi_batch_update_instance_config(lst_updates=lst_updates, node_address=None)
|
727
810
|
```
|
728
811
|
"""
|
@@ -740,19 +823,19 @@ class CustomPluginTemplate:
|
|
740
823
|
def cmdapi_register_command(self, node_address, command_type, command_content):
|
741
824
|
"""
|
742
825
|
Send a command to a particular Execution Engine
|
743
|
-
|
826
|
+
|
744
827
|
Parameters
|
745
828
|
----------
|
746
829
|
node_address : str
|
747
830
|
target Execution Engine.
|
748
831
|
command_type : st
|
749
|
-
type of the command - can be one of 'RESTART','STATUS', 'STOP', 'UPDATE_CONFIG',
|
750
|
-
'DELETE_CONFIG', 'ARCHIVE_CONFIG', 'DELETE_CONFIG_ALL', 'ARCHIVE_CONFIG_ALL', 'ACTIVE_PLUGINS',
|
832
|
+
type of the command - can be one of 'RESTART','STATUS', 'STOP', 'UPDATE_CONFIG',
|
833
|
+
'DELETE_CONFIG', 'ARCHIVE_CONFIG', 'DELETE_CONFIG_ALL', 'ARCHIVE_CONFIG_ALL', 'ACTIVE_PLUGINS',
|
751
834
|
'RELOAD_CONFIG_FROM_DISK', 'FULL_HEARTBEAT', 'TIMERS_ONLY_HEARTBEAT', 'SIMPLE_HEARTBEAT',
|
752
835
|
'UPDATE_PIPELINE_INSTANCE', etc.
|
753
836
|
command_content : dict
|
754
837
|
the actual content - can be None for some commands.
|
755
|
-
|
838
|
+
|
756
839
|
Returns
|
757
840
|
-------
|
758
841
|
None.
|
@@ -768,33 +851,33 @@ class CustomPluginTemplate:
|
|
768
851
|
def cmdapi_send_instance_command(self, pipeline, signature, instance_id, instance_command, node_address):
|
769
852
|
"""
|
770
853
|
Sends a INSTANCE_COMMAND for a particular plugin instance in a given box/pipeline
|
771
|
-
|
854
|
+
|
772
855
|
Parameters
|
773
856
|
----------
|
774
857
|
pipeline : str
|
775
|
-
Name of the pipeline.
|
776
|
-
|
858
|
+
Name of the pipeline.
|
859
|
+
|
777
860
|
instance_id: str
|
778
861
|
Name of the instance
|
779
|
-
|
862
|
+
|
780
863
|
signature: str
|
781
|
-
Name (signature) of the plugin
|
782
|
-
|
864
|
+
Name (signature) of the plugin
|
865
|
+
|
783
866
|
instance_command: any
|
784
867
|
The configuration for the given box/pipeline/plugin/instance. Can be a string, dict, etc
|
785
|
-
|
868
|
+
|
786
869
|
node_address : str, optional
|
787
870
|
destination Execution Engine, `None` will default to local Execution Engine. The default is None.
|
788
|
-
|
789
|
-
|
871
|
+
|
872
|
+
|
790
873
|
Returns
|
791
874
|
-------
|
792
875
|
None.
|
793
|
-
|
876
|
+
|
794
877
|
Example:
|
795
878
|
--------
|
796
|
-
|
797
|
-
|
879
|
+
|
880
|
+
|
798
881
|
```
|
799
882
|
pipeline = "test123"
|
800
883
|
signature = "A_PLUGIN_01"
|
@@ -811,33 +894,33 @@ class CustomPluginTemplate:
|
|
811
894
|
node_address=None,
|
812
895
|
)
|
813
896
|
```
|
814
|
-
|
897
|
+
|
815
898
|
"""
|
816
899
|
raise NotImplementedError
|
817
900
|
|
818
901
|
def cmdapi_send_pipeline_command(self, command, node_address, pipeline_name):
|
819
902
|
"""
|
820
903
|
Sends a command to a particular pipeline on a particular destination E2 instance
|
821
|
-
|
904
|
+
|
822
905
|
Parameters
|
823
906
|
----------
|
824
907
|
command : any
|
825
908
|
the command content
|
826
|
-
|
909
|
+
|
827
910
|
node_address : str, optional
|
828
911
|
name of the destination e2, by default None (self)
|
829
|
-
|
912
|
+
|
830
913
|
pipeline_name : str, optional
|
831
914
|
name of the pipeline, by default None (self)
|
832
|
-
|
833
|
-
|
915
|
+
|
916
|
+
|
834
917
|
Returns
|
835
918
|
-------
|
836
919
|
None.
|
837
|
-
|
920
|
+
|
838
921
|
Example
|
839
922
|
-------
|
840
|
-
|
923
|
+
|
841
924
|
```
|
842
925
|
# send a command directly to the current pipeline
|
843
926
|
plugin.cmdapi_send_pipeline_command(
|
@@ -858,21 +941,21 @@ class CustomPluginTemplate:
|
|
858
941
|
def cmdapi_start_pipeline(self, config, node_address):
|
859
942
|
"""
|
860
943
|
Sends a start pipeline to a particular destination Execution Engine
|
861
|
-
|
944
|
+
|
862
945
|
Parameters
|
863
946
|
----------
|
864
947
|
node_address : str, optional
|
865
948
|
destination Execution Engine, `None` will default to local Execution Engine. The default is None
|
866
949
|
.
|
867
950
|
config : dict
|
868
|
-
the pipeline configuration.
|
869
|
-
|
951
|
+
the pipeline configuration.
|
952
|
+
|
870
953
|
Returns
|
871
954
|
-------
|
872
955
|
None.
|
873
|
-
|
956
|
+
|
874
957
|
Example:
|
875
|
-
|
958
|
+
|
876
959
|
```
|
877
960
|
config = {
|
878
961
|
"NAME" : "test123",
|
@@ -884,50 +967,51 @@ class CustomPluginTemplate:
|
|
884
967
|
"""
|
885
968
|
raise NotImplementedError
|
886
969
|
|
887
|
-
def cmdapi_start_pipeline_by_params(self, name, pipeline_type, node_address, url, reconnectable, live_feed, plugins,
|
970
|
+
def cmdapi_start_pipeline_by_params(self, name, pipeline_type, node_address, url, reconnectable, live_feed, plugins,
|
971
|
+
stream_config_metadata, cap_resolution, kwargs):
|
888
972
|
"""
|
889
973
|
Start a pipeline by defining specific pipeline params
|
890
|
-
|
974
|
+
|
891
975
|
Parameters
|
892
976
|
----------
|
893
977
|
name : str
|
894
978
|
Name of the pipeline.
|
895
|
-
|
979
|
+
|
896
980
|
pipeline_type : str
|
897
981
|
type of the pipeline. Will point the E2 instance to a particular Data Capture Thread plugin
|
898
|
-
|
982
|
+
|
899
983
|
node_address : str, optional
|
900
984
|
Address of the target E2 instance. The default is `None` and will run on local E2.
|
901
|
-
|
985
|
+
|
902
986
|
url : str, optional
|
903
987
|
The optional URL that can be used by the DCT to acquire data. The default is None.
|
904
|
-
|
988
|
+
|
905
989
|
reconnectable : str, optional
|
906
990
|
Attempts to reconnect after data stops if 'YES'. 'KEEP_ALIVE' will not reconnect to
|
907
|
-
data source but will leave the DCT in a "zombie" state waiting for external pipeline
|
991
|
+
data source but will leave the DCT in a "zombie" state waiting for external pipeline
|
908
992
|
close command.
|
909
993
|
The default is 'YES'.
|
910
|
-
|
994
|
+
|
911
995
|
live_feed : bool, optional
|
912
996
|
Will always try to generate the real-time datapoint (no queued data). The default is False.
|
913
|
-
|
997
|
+
|
914
998
|
plugins : list of dicts, optional
|
915
999
|
Lists all the business plugins with their respective individual instances. The default is None.
|
916
|
-
|
1000
|
+
|
917
1001
|
stream_config_metadata : dict, optional
|
918
1002
|
Options (custom) for current DCT. The default is None.
|
919
|
-
|
1003
|
+
|
920
1004
|
cap_resolution : float, optional
|
921
1005
|
Desired frequency (in Hz) of the DCT data reading cycles. The default is None.
|
922
|
-
|
923
|
-
|
1006
|
+
|
1007
|
+
|
924
1008
|
Returns
|
925
1009
|
-------
|
926
1010
|
None (actually)
|
927
|
-
|
1011
|
+
|
928
1012
|
Example
|
929
1013
|
-------
|
930
|
-
|
1014
|
+
|
931
1015
|
```
|
932
1016
|
name = "test123"
|
933
1017
|
pipeline_type = "Void"
|
@@ -944,8 +1028,8 @@ class CustomPluginTemplate:
|
|
944
1028
|
}
|
945
1029
|
]
|
946
1030
|
plugin.cmdapi_start_pipeline_by_params(
|
947
|
-
name=name,
|
948
|
-
pipeline_type=pipeline_type,
|
1031
|
+
name=name,
|
1032
|
+
pipeline_type=pipeline_type,
|
949
1033
|
plugins=plugins,
|
950
1034
|
)
|
951
1035
|
```
|
@@ -955,38 +1039,38 @@ class CustomPluginTemplate:
|
|
955
1039
|
def cmdapi_start_simple_custom_pipeline(self, base64code, node_address, name, instance_config, kwargs):
|
956
1040
|
"""
|
957
1041
|
Starts a CUSTOM_EXEC_01 plugin on a Void pipeline
|
958
|
-
|
959
|
-
|
1042
|
+
|
1043
|
+
|
960
1044
|
Parameters
|
961
1045
|
----------
|
962
1046
|
base64code : str
|
963
1047
|
The base64 encoded string that will be used as custom exec plugin.
|
964
|
-
|
1048
|
+
|
965
1049
|
node_address : str, optional
|
966
1050
|
The destination processing node. The default is None and will point to current node.
|
967
|
-
|
1051
|
+
|
968
1052
|
name : str, optional
|
969
1053
|
Name of the pipeline. The default is None and will be uuid generated.
|
970
|
-
|
1054
|
+
|
971
1055
|
instance_config / kwargs: dict
|
972
1056
|
Dict with params for the instance that can be given either as a dict or as kwargs
|
973
|
-
|
974
|
-
|
1057
|
+
|
1058
|
+
|
975
1059
|
Returns
|
976
1060
|
-------
|
977
1061
|
name : str
|
978
1062
|
returns the name of the pipeline.
|
979
|
-
|
980
|
-
|
1063
|
+
|
1064
|
+
|
981
1065
|
Example
|
982
1066
|
-------
|
983
|
-
|
1067
|
+
|
984
1068
|
```
|
985
1069
|
worker = plugin.cfg_destination # destination worker received in plugin json command
|
986
|
-
worker_code = plugin.cfg_worker_code # base64 code that will be executed
|
1070
|
+
worker_code = plugin.cfg_worker_code # base64 code that will be executed
|
987
1071
|
custom_code_param = plugin.cfg_custom_code_param # a special param expected by the custom code
|
988
1072
|
pipeline_name = plugin.cmdapi_start_simple_custom_pipeline(
|
989
|
-
base64code=worker_code,
|
1073
|
+
base64code=worker_code,
|
990
1074
|
node_address=worker,
|
991
1075
|
custom_code_param=pcustom_code_param,
|
992
1076
|
)
|
@@ -1000,10 +1084,12 @@ class CustomPluginTemplate:
|
|
1000
1084
|
def cmdapi_start_stream_by_config_on_other_box(self, node_address, config_stream):
|
1001
1085
|
raise NotImplementedError
|
1002
1086
|
|
1003
|
-
def cmdapi_start_stream_by_params_on_current_box(self, name, stream_type, url, reconnectable, live_feed, plugins,
|
1087
|
+
def cmdapi_start_stream_by_params_on_current_box(self, name, stream_type, url, reconnectable, live_feed, plugins,
|
1088
|
+
stream_config_metadata, cap_resolution, kwargs):
|
1004
1089
|
raise NotImplementedError
|
1005
1090
|
|
1006
|
-
def cmdapi_start_stream_by_params_on_other_box(self, node_address, name, stream_type, url, reconnectable, live_feed,
|
1091
|
+
def cmdapi_start_stream_by_params_on_other_box(self, node_address, name, stream_type, url, reconnectable, live_feed,
|
1092
|
+
plugins, stream_config_metadata, cap_resolution, kwargs):
|
1007
1093
|
raise NotImplementedError
|
1008
1094
|
|
1009
1095
|
def cmdapi_stop_current_box(self):
|
@@ -1030,40 +1116,40 @@ class CustomPluginTemplate:
|
|
1030
1116
|
def cmdapi_update_instance_config(self, pipeline, signature, instance_id, instance_config, node_address):
|
1031
1117
|
"""
|
1032
1118
|
Sends update config for a particular plugin instance in a given box/pipeline
|
1033
|
-
|
1034
|
-
|
1119
|
+
|
1120
|
+
|
1035
1121
|
Parameters
|
1036
1122
|
----------
|
1037
|
-
|
1123
|
+
|
1038
1124
|
pipeline : str
|
1039
|
-
Name of the pipeline.
|
1040
|
-
|
1125
|
+
Name of the pipeline.
|
1126
|
+
|
1041
1127
|
signature: str
|
1042
|
-
Name (signature) of the plugin
|
1043
|
-
|
1128
|
+
Name (signature) of the plugin
|
1129
|
+
|
1044
1130
|
instance_id: str
|
1045
1131
|
Name of the instance
|
1046
|
-
|
1132
|
+
|
1047
1133
|
instance_config: dict
|
1048
1134
|
The configuration for the given box/pipeline/plugin/instance
|
1049
|
-
|
1135
|
+
|
1050
1136
|
node_address : str, optional
|
1051
1137
|
destination Execution Engine, `None` will default to local Execution Engine. The default is None.
|
1052
|
-
|
1138
|
+
|
1053
1139
|
Returns
|
1054
1140
|
-------
|
1055
1141
|
None.
|
1056
1142
|
"""
|
1057
1143
|
raise NotImplementedError
|
1058
1144
|
|
1059
|
-
def code_to_base64(self, code, verbose, compress):
|
1145
|
+
def code_to_base64(self, code, verbose, compress, return_errors):
|
1060
1146
|
raise NotImplementedError
|
1061
1147
|
|
1062
1148
|
@property
|
1063
|
-
def const():
|
1149
|
+
def const(self):
|
1064
1150
|
"""
|
1065
1151
|
Provides access to E2 constants
|
1066
|
-
|
1152
|
+
|
1067
1153
|
Returns
|
1068
1154
|
-------
|
1069
1155
|
ct : package
|
@@ -1072,10 +1158,10 @@ class CustomPluginTemplate:
|
|
1072
1158
|
raise NotImplementedError
|
1073
1159
|
|
1074
1160
|
@property
|
1075
|
-
def consts():
|
1161
|
+
def consts(self):
|
1076
1162
|
"""
|
1077
1163
|
Provides access to E2 constants
|
1078
|
-
|
1164
|
+
|
1079
1165
|
Returns
|
1080
1166
|
-------
|
1081
1167
|
ct : package
|
@@ -1086,14 +1172,14 @@ class CustomPluginTemplate:
|
|
1086
1172
|
def convert_size(self, size, unit):
|
1087
1173
|
"""
|
1088
1174
|
Given a size and a unit, it returns the size in the given unit
|
1089
|
-
|
1175
|
+
|
1090
1176
|
Parameters
|
1091
1177
|
----------
|
1092
1178
|
size : int
|
1093
1179
|
value to be converted
|
1094
1180
|
unit : str
|
1095
1181
|
one of the following: 'KB', 'MB', 'GB'
|
1096
|
-
|
1182
|
+
|
1097
1183
|
Returns
|
1098
1184
|
-------
|
1099
1185
|
_type_
|
@@ -1112,11 +1198,11 @@ class CustomPluginTemplate:
|
|
1112
1198
|
Creates a payload and sends it to the output queue.
|
1113
1199
|
If used inside plugins plese do NOT return the payload from _process as the payload
|
1114
1200
|
will be duplicated
|
1115
|
-
|
1201
|
+
|
1116
1202
|
Parameters
|
1117
1203
|
----------
|
1118
1204
|
**kwargs : dict
|
1119
|
-
|
1205
|
+
|
1120
1206
|
Returns
|
1121
1207
|
-------
|
1122
1208
|
None.
|
@@ -1126,7 +1212,7 @@ class CustomPluginTemplate:
|
|
1126
1212
|
def create_basic_ts_model(self, series_min, train_hist, train_periods):
|
1127
1213
|
"""
|
1128
1214
|
Returns a basic time-series prediction model instance
|
1129
|
-
|
1215
|
+
|
1130
1216
|
Parameters
|
1131
1217
|
----------
|
1132
1218
|
series_min : int, optional
|
@@ -1135,12 +1221,12 @@ class CustomPluginTemplate:
|
|
1135
1221
|
The training window size. The default is None.
|
1136
1222
|
train_periods : int, optional
|
1137
1223
|
how many windows to use. The default is None.
|
1138
|
-
|
1224
|
+
|
1139
1225
|
Returns
|
1140
1226
|
-------
|
1141
1227
|
BasicSeriesModel() object
|
1142
|
-
|
1143
|
-
|
1228
|
+
|
1229
|
+
|
1144
1230
|
Example
|
1145
1231
|
-------
|
1146
1232
|
```
|
@@ -1155,12 +1241,12 @@ class CustomPluginTemplate:
|
|
1155
1241
|
|
1156
1242
|
def create_numpy_shared_memory_object(self, mem_name, mem_size, np_shape, np_type, create, is_buffer, kwargs):
|
1157
1243
|
"""
|
1158
|
-
Create a shared memory for numpy arrays.
|
1244
|
+
Create a shared memory for numpy arrays.
|
1159
1245
|
This method returns a `NumpySharedMemory` object that can be used to read/write numpy arrays from/to shared memory.
|
1160
1246
|
Use this method instead of creating the object directly, as it requires the logger to be set.
|
1161
|
-
|
1247
|
+
|
1162
1248
|
For a complete set of parameters, check the `NumpySharedMemory` class from `core.utils.system_shared_memory`
|
1163
|
-
|
1249
|
+
|
1164
1250
|
Parameters
|
1165
1251
|
----------
|
1166
1252
|
mem_name : str
|
@@ -1175,8 +1261,8 @@ class CustomPluginTemplate:
|
|
1175
1261
|
create the shared memory if it does not exist, by default False
|
1176
1262
|
is_buffer : bool, optional
|
1177
1263
|
if True, the shared memory will be used as a buffer, by default False
|
1178
|
-
|
1179
|
-
|
1264
|
+
|
1265
|
+
|
1180
1266
|
Returns
|
1181
1267
|
-------
|
1182
1268
|
NumPySharedMemory
|
@@ -1195,24 +1281,24 @@ class CustomPluginTemplate:
|
|
1195
1281
|
def create_sre(self, kwargs):
|
1196
1282
|
"""
|
1197
1283
|
Returns a Statefull Rule Engine instance
|
1198
|
-
|
1199
|
-
|
1284
|
+
|
1285
|
+
|
1200
1286
|
Returns
|
1201
1287
|
-------
|
1202
1288
|
SRE()
|
1203
|
-
|
1204
|
-
|
1289
|
+
|
1290
|
+
|
1205
1291
|
Example
|
1206
1292
|
-------
|
1207
1293
|
```
|
1208
|
-
eng = self.create_sre()
|
1294
|
+
eng = self.create_sre()
|
1209
1295
|
# add a data stream
|
1210
1296
|
eng.add_entity(
|
1211
|
-
entity_id='dev_test_1',
|
1297
|
+
entity_id='dev_test_1',
|
1212
1298
|
entity_props=['f1','f2','f3'],
|
1213
1299
|
entity_rules=['state.f1.val == 0 and state.f2.val == 0 and prev.f2.val==1'],
|
1214
1300
|
)
|
1215
|
-
|
1301
|
+
|
1216
1302
|
```
|
1217
1303
|
"""
|
1218
1304
|
raise NotImplementedError
|
@@ -1220,33 +1306,33 @@ class CustomPluginTemplate:
|
|
1220
1306
|
def create_statefull_rule_engine(self, kwargs):
|
1221
1307
|
"""
|
1222
1308
|
Returns a Statefull Rule Engine instance
|
1223
|
-
|
1224
|
-
|
1309
|
+
|
1310
|
+
|
1225
1311
|
Returns
|
1226
1312
|
-------
|
1227
1313
|
SRE()
|
1228
|
-
|
1229
|
-
|
1314
|
+
|
1315
|
+
|
1230
1316
|
Example
|
1231
1317
|
-------
|
1232
1318
|
```
|
1233
|
-
eng = self.create_statefull_rule_engine()
|
1319
|
+
eng = self.create_statefull_rule_engine()
|
1234
1320
|
# add a data stream
|
1235
1321
|
eng.add_entity(
|
1236
|
-
entity_id='dev_test_1',
|
1322
|
+
entity_id='dev_test_1',
|
1237
1323
|
entity_props=['f1','f2','f3'],
|
1238
1324
|
entity_rules=['state.f1.val == 0 and state.f2.val == 0 and prev.f2.val==1'],
|
1239
1325
|
)
|
1240
|
-
|
1326
|
+
|
1241
1327
|
```
|
1242
1328
|
"""
|
1243
1329
|
raise NotImplementedError
|
1244
1330
|
|
1245
1331
|
@property
|
1246
|
-
def ct():
|
1332
|
+
def ct(self):
|
1247
1333
|
"""
|
1248
1334
|
Provides access to E2 constants
|
1249
|
-
|
1335
|
+
|
1250
1336
|
Returns
|
1251
1337
|
-------
|
1252
1338
|
ct : package
|
@@ -1255,21 +1341,27 @@ class CustomPluginTemplate:
|
|
1255
1341
|
raise NotImplementedError
|
1256
1342
|
|
1257
1343
|
@property
|
1258
|
-
def current_exec_iteration():
|
1344
|
+
def current_exec_iteration(self):
|
1259
1345
|
"""
|
1260
1346
|
Returns the current loop exec iteration
|
1261
1347
|
"""
|
1262
1348
|
raise NotImplementedError
|
1263
1349
|
|
1264
1350
|
@property
|
1265
|
-
def current_process_iteration():
|
1351
|
+
def current_process_iteration(self):
|
1266
1352
|
"""
|
1267
1353
|
Returns the current process iteration
|
1268
1354
|
"""
|
1269
1355
|
raise NotImplementedError
|
1270
1356
|
|
1357
|
+
def custom_print(self, print_queue, args, kwargs):
|
1358
|
+
"""
|
1359
|
+
Custom print function that will be used in the plugin code.
|
1360
|
+
"""
|
1361
|
+
raise NotImplementedError
|
1362
|
+
|
1271
1363
|
@property
|
1272
|
-
def cv2():
|
1364
|
+
def cv2(self):
|
1273
1365
|
"""
|
1274
1366
|
provides access to computer vision library
|
1275
1367
|
"""
|
@@ -1278,7 +1370,7 @@ class CustomPluginTemplate:
|
|
1278
1370
|
def dataapi_all_metadata(self):
|
1279
1371
|
"""
|
1280
1372
|
API for accessing the concatenated stream metadata and metadata from all inputs
|
1281
|
-
|
1373
|
+
|
1282
1374
|
Returns
|
1283
1375
|
-------
|
1284
1376
|
dict
|
@@ -1301,7 +1393,7 @@ class CustomPluginTemplate:
|
|
1301
1393
|
[{'TLBR_POS' : ...}, {'TLBR_POS' : ...}, {'TLBR_POS' : ...}],
|
1302
1394
|
[{'TLBR_POS' : ...}]
|
1303
1395
|
],
|
1304
|
-
|
1396
|
+
|
1305
1397
|
'anomaly_detection_model' : [
|
1306
1398
|
'True/False'
|
1307
1399
|
]
|
@@ -1318,22 +1410,22 @@ class CustomPluginTemplate:
|
|
1318
1410
|
"""
|
1319
1411
|
API for accessing the first image in the 'INPUTS' list
|
1320
1412
|
(shortcut for `dataapi_specific_image`, most of the cases will have a single image on a stream)
|
1321
|
-
|
1413
|
+
|
1322
1414
|
Parameters
|
1323
1415
|
----------
|
1324
1416
|
full : bool, optional
|
1325
1417
|
Passed to `dataapi_specific_image`
|
1326
1418
|
The default value is False
|
1327
|
-
|
1419
|
+
|
1328
1420
|
raise_if_error : bool, optional
|
1329
1421
|
Passed to `dataapi_specific_image`
|
1330
1422
|
The default value is False
|
1331
|
-
|
1423
|
+
|
1332
1424
|
Returns
|
1333
1425
|
-------
|
1334
1426
|
dict (if full==True) / np.ndarray (if full==False)
|
1335
1427
|
Returned by `dataapi_specific_image`
|
1336
|
-
|
1428
|
+
|
1337
1429
|
Raises
|
1338
1430
|
------
|
1339
1431
|
IndexError
|
@@ -1345,22 +1437,22 @@ class CustomPluginTemplate:
|
|
1345
1437
|
"""
|
1346
1438
|
API for accessing the first image global inferences
|
1347
1439
|
(shortcut for `dataapi_specific_image_global_inferences`, most of the cases will have a single image on a stream)
|
1348
|
-
|
1440
|
+
|
1349
1441
|
Parameters
|
1350
1442
|
----------
|
1351
1443
|
how : str, optional
|
1352
1444
|
Passed to `dataapi_specific_image_global_inferences`
|
1353
1445
|
The default value is None
|
1354
|
-
|
1446
|
+
|
1355
1447
|
raise_if_error : bool, optional
|
1356
1448
|
Passed to `dataapi_specific_image_global_inferences`
|
1357
1449
|
The default value is False
|
1358
|
-
|
1450
|
+
|
1359
1451
|
Returns
|
1360
1452
|
-------
|
1361
1453
|
dict (if how == 'dict') or list (if how == 'list')
|
1362
1454
|
returned by `dataapi_specific_image_global_inferences`
|
1363
|
-
|
1455
|
+
|
1364
1456
|
Raises
|
1365
1457
|
------
|
1366
1458
|
IndexError
|
@@ -1372,26 +1464,26 @@ class CustomPluginTemplate:
|
|
1372
1464
|
"""
|
1373
1465
|
API for accessing the first image inferences
|
1374
1466
|
(shortcut for `dataapi_specific_image_inferences`, most of the cases will have a single image on a stream)
|
1375
|
-
|
1467
|
+
|
1376
1468
|
Parameters
|
1377
1469
|
----------
|
1378
1470
|
how : str, optional
|
1379
1471
|
Passed to `dataapi_specific_image_inferences`
|
1380
1472
|
The default value is None
|
1381
|
-
|
1473
|
+
|
1382
1474
|
mode : str, optional
|
1383
1475
|
Passed to `dataapi_specific_image_inferences`
|
1384
1476
|
The default value is None
|
1385
|
-
|
1477
|
+
|
1386
1478
|
raise_if_error : bool, optional
|
1387
1479
|
Passed to `dataapi_specific_image_inferences`
|
1388
1480
|
The default value is False
|
1389
|
-
|
1481
|
+
|
1390
1482
|
Returns
|
1391
1483
|
-------
|
1392
1484
|
dict (if how == 'dict') or list (if how == 'list')
|
1393
1485
|
returned by `dataapi_specific_image_inferences`
|
1394
|
-
|
1486
|
+
|
1395
1487
|
Raises
|
1396
1488
|
------
|
1397
1489
|
IndexError
|
@@ -1403,22 +1495,22 @@ class CustomPluginTemplate:
|
|
1403
1495
|
"""
|
1404
1496
|
API for accessing the first image instance inferences
|
1405
1497
|
(shortcut for `dataapi_specific_image_instance_inferences`, most of the cases will have a single image on a stream)
|
1406
|
-
|
1498
|
+
|
1407
1499
|
Parameters
|
1408
1500
|
----------
|
1409
1501
|
how : str, optional
|
1410
1502
|
Passed to `dataapi_specific_image_instance_inferences`
|
1411
1503
|
The default value is None ('list')
|
1412
|
-
|
1504
|
+
|
1413
1505
|
raise_if_error : bool, optional
|
1414
1506
|
Passed to `dataapi_specific_image_instance_inferences`
|
1415
1507
|
The default value is False
|
1416
|
-
|
1508
|
+
|
1417
1509
|
Returns
|
1418
1510
|
-------
|
1419
1511
|
dict (if how == 'dict') or list (if how == 'list')
|
1420
1512
|
returned by `dataapi_specific_image_instance_inferences`
|
1421
|
-
|
1513
|
+
|
1422
1514
|
Raises
|
1423
1515
|
------
|
1424
1516
|
IndexError
|
@@ -1430,22 +1522,22 @@ class CustomPluginTemplate:
|
|
1430
1522
|
"""
|
1431
1523
|
API for accessing the first image plugin inferences
|
1432
1524
|
(shortcut for `dataapi_specific_image_plugin_inferences`, most of the cases will have a single image on a stream)
|
1433
|
-
|
1525
|
+
|
1434
1526
|
Parameters
|
1435
1527
|
----------
|
1436
1528
|
how : str, optional
|
1437
1529
|
Passed to `dataapi_specific_image_plugin_inferences`
|
1438
1530
|
The default value is None
|
1439
|
-
|
1531
|
+
|
1440
1532
|
raise_if_error : bool, optional
|
1441
1533
|
Passed to `dataapi_specific_image_plugin_inferences`
|
1442
1534
|
The default value is False
|
1443
|
-
|
1535
|
+
|
1444
1536
|
Returns
|
1445
1537
|
-------
|
1446
1538
|
dict (if how == 'dict') or list (if how == 'list')
|
1447
1539
|
returned by `dataapi_specific_image_plugin_inferences`
|
1448
|
-
|
1540
|
+
|
1449
1541
|
Raises
|
1450
1542
|
------
|
1451
1543
|
IndexError
|
@@ -1457,22 +1549,22 @@ class CustomPluginTemplate:
|
|
1457
1549
|
"""
|
1458
1550
|
API for accessing the first image plugin positional inferences
|
1459
1551
|
(shortcut for `dataapi_specific_image_plugin_positional_inferences`, most of the cases will have a single image on a stream)
|
1460
|
-
|
1552
|
+
|
1461
1553
|
Parameters
|
1462
1554
|
----------
|
1463
1555
|
how : str, optional
|
1464
1556
|
Passed to `dataapi_specific_image_plugin_positional_inferences`
|
1465
1557
|
The default value is None
|
1466
|
-
|
1558
|
+
|
1467
1559
|
raise_if_error : bool, optional
|
1468
1560
|
Passed to `dataapi_specific_image_plugin_positional_inferences`
|
1469
1561
|
The default value is False
|
1470
|
-
|
1562
|
+
|
1471
1563
|
Returns
|
1472
1564
|
-------
|
1473
1565
|
dict (if how == 'dict') or list (if how == 'list')
|
1474
1566
|
returned by `dataapi_specific_image_plugin_positional_inferences`
|
1475
|
-
|
1567
|
+
|
1476
1568
|
Raises
|
1477
1569
|
------
|
1478
1570
|
IndexError
|
@@ -1488,7 +1580,7 @@ class CustomPluginTemplate:
|
|
1488
1580
|
full : bool, optional
|
1489
1581
|
Specifies whether the images are returned full (the whole input dictionary) or not (just the value of 'IMG' in the input dictionary)
|
1490
1582
|
The default value is False
|
1491
|
-
|
1583
|
+
|
1492
1584
|
Returns
|
1493
1585
|
-------
|
1494
1586
|
dict{int : dict} (if full==True) / dict{int : np.ndarray} (if full=False)
|
@@ -1502,7 +1594,7 @@ class CustomPluginTemplate:
|
|
1502
1594
|
'TYPE' : 'IMG',
|
1503
1595
|
'METADATA' : {Dictionary with current input metadata}
|
1504
1596
|
},
|
1505
|
-
|
1597
|
+
|
1506
1598
|
1 : {
|
1507
1599
|
'IMG' : np.ndarray(2),
|
1508
1600
|
'STRUCT_DATA' : None,
|
@@ -1511,9 +1603,9 @@ class CustomPluginTemplate:
|
|
1511
1603
|
'METADATA' : {Dictionary with current input metadata}
|
1512
1604
|
}
|
1513
1605
|
} if full==True
|
1514
|
-
|
1606
|
+
|
1515
1607
|
or
|
1516
|
-
|
1608
|
+
|
1517
1609
|
{
|
1518
1610
|
0 : np.ndarray(1),
|
1519
1611
|
1 : np.ndarray(2)
|
@@ -1534,7 +1626,7 @@ class CustomPluginTemplate:
|
|
1534
1626
|
"""
|
1535
1627
|
API for accessing just the images inferences.
|
1536
1628
|
Filters the output of `dataapi_inferences`, keeping only the AI engines that run on images
|
1537
|
-
|
1629
|
+
|
1538
1630
|
Returns
|
1539
1631
|
-------
|
1540
1632
|
dict{str:list}
|
@@ -1547,7 +1639,7 @@ class CustomPluginTemplate:
|
|
1547
1639
|
API for accessing the images inferences, filtered by confidence threshold, object types and target zone.
|
1548
1640
|
More specifically, all the instance inferences are the plugin inferences that intersects (based on PRC_INTERSECT)
|
1549
1641
|
with the configured target zone.
|
1550
|
-
|
1642
|
+
|
1551
1643
|
Returns
|
1552
1644
|
-------
|
1553
1645
|
dict{str:list}
|
@@ -1561,7 +1653,7 @@ class CustomPluginTemplate:
|
|
1561
1653
|
More specifically, all the plugin inferences are the global inferences that surpass a configured confidence
|
1562
1654
|
threshold and have a specific type. For example, an object detector basically infers for all the objects in
|
1563
1655
|
COCO dataset. But, a certain plugin may need only persons and dogs.
|
1564
|
-
|
1656
|
+
|
1565
1657
|
Returns
|
1566
1658
|
-------
|
1567
1659
|
dict{str:list}
|
@@ -1585,16 +1677,16 @@ class CustomPluginTemplate:
|
|
1585
1677
|
def dataapi_inference_results(self, model_name, idx):
|
1586
1678
|
"""
|
1587
1679
|
Returns the inference results for a specific model and a specific input index.
|
1588
|
-
|
1680
|
+
|
1589
1681
|
Parameters
|
1590
1682
|
----------
|
1591
1683
|
model_name : str
|
1592
1684
|
The name of the model for which the inference results are requested.
|
1593
|
-
|
1685
|
+
|
1594
1686
|
idx : int, optional
|
1595
1687
|
The index of the input for which the inference results are requested.
|
1596
1688
|
The default value is 0.
|
1597
|
-
|
1689
|
+
|
1598
1690
|
Returns
|
1599
1691
|
-------
|
1600
1692
|
list
|
@@ -1607,17 +1699,17 @@ class CustomPluginTemplate:
|
|
1607
1699
|
Returns
|
1608
1700
|
-------
|
1609
1701
|
dict{str:list}
|
1610
|
-
the inferences that come from the serving plugins configured for the current plugin instance.
|
1611
|
-
Each key is the name of the serving plugin (AI engine).
|
1702
|
+
the inferences that come from the serving plugins configured for the current plugin instance.
|
1703
|
+
Each key is the name of the serving plugin (AI engine).
|
1612
1704
|
Each value is a list where each item in the list is an inference.
|
1613
|
-
|
1705
|
+
|
1614
1706
|
Example:
|
1615
1707
|
{
|
1616
1708
|
'object_detection_model' : [
|
1617
1709
|
[{'TLBR_POS' : ...}, {'TLBR_POS' : ...}, {'TLBR_POS' : ...}],
|
1618
1710
|
[{'TLBR_POS' : ...}]
|
1619
1711
|
],
|
1620
|
-
|
1712
|
+
|
1621
1713
|
'anomaly_detection_model' : [
|
1622
1714
|
'True/False'
|
1623
1715
|
]
|
@@ -1628,12 +1720,12 @@ class CustomPluginTemplate:
|
|
1628
1720
|
def dataapi_inferences_by_model(self, model_name):
|
1629
1721
|
"""
|
1630
1722
|
Returns the inference results for a specific model.
|
1631
|
-
|
1723
|
+
|
1632
1724
|
Parameters
|
1633
1725
|
----------
|
1634
1726
|
model_name : str
|
1635
1727
|
The name of the model for which the inference results are requested.
|
1636
|
-
|
1728
|
+
|
1637
1729
|
Returns
|
1638
1730
|
-------
|
1639
1731
|
list
|
@@ -1647,7 +1739,7 @@ class CustomPluginTemplate:
|
|
1647
1739
|
-------
|
1648
1740
|
dict{str:dict}
|
1649
1741
|
the inference metadata that comes from the serving plugins configured for the current plugin instance
|
1650
|
-
|
1742
|
+
|
1651
1743
|
Example:
|
1652
1744
|
{
|
1653
1745
|
'object_detection_model' : {'SYSTEM_TYME' : ..., 'VER' : ..., 'PICKED_INPUT' : 'IMG'},
|
@@ -1660,18 +1752,18 @@ class CustomPluginTemplate:
|
|
1660
1752
|
"""
|
1661
1753
|
API for accessing the metadata of the first input
|
1662
1754
|
(shortcut for `dataapi_specific_input_metadata`, most of the cases will have a single input on a stream)
|
1663
|
-
|
1755
|
+
|
1664
1756
|
Parameters
|
1665
1757
|
----------
|
1666
1758
|
raise_if_error : bool, optional
|
1667
1759
|
Passed to `dataapi_specific_input_metadata`
|
1668
1760
|
The default value is False
|
1669
|
-
|
1761
|
+
|
1670
1762
|
Returns
|
1671
1763
|
-------
|
1672
1764
|
dict
|
1673
1765
|
Returned by `dataapi_specific_input_metadata`
|
1674
|
-
|
1766
|
+
|
1675
1767
|
Raises
|
1676
1768
|
------
|
1677
1769
|
IndexError
|
@@ -1693,7 +1785,7 @@ class CustomPluginTemplate:
|
|
1693
1785
|
API for accessing the concatenated metadata from all inputs (images and structured datas together)
|
1694
1786
|
This is not the same as the stream metadata that points to the overall params of the execution
|
1695
1787
|
pipeline.
|
1696
|
-
|
1788
|
+
|
1697
1789
|
Returns
|
1698
1790
|
-------
|
1699
1791
|
dict
|
@@ -1704,7 +1796,7 @@ class CustomPluginTemplate:
|
|
1704
1796
|
def dataapi_plugin_input(self):
|
1705
1797
|
"""
|
1706
1798
|
Alias for `self.dataapi_full_input`
|
1707
|
-
|
1799
|
+
|
1708
1800
|
Returns
|
1709
1801
|
-------
|
1710
1802
|
dict
|
@@ -1724,7 +1816,7 @@ class CustomPluginTemplate:
|
|
1724
1816
|
def dataapi_specific_image(self, idx, full, raise_if_error):
|
1725
1817
|
"""
|
1726
1818
|
API for accessing a specific image in the 'INPUTS' list
|
1727
|
-
|
1819
|
+
|
1728
1820
|
Parameters
|
1729
1821
|
----------
|
1730
1822
|
idx : int, optional
|
@@ -1732,21 +1824,21 @@ class CustomPluginTemplate:
|
|
1732
1824
|
Attention! If there is a metastream that collects 3 inputs - ['IMG', 'STRUCT_DATA', 'IMG'], for accessing the last
|
1733
1825
|
image, `idx` should be 1!
|
1734
1826
|
The default value is 0
|
1735
|
-
|
1827
|
+
|
1736
1828
|
full : bool, optional
|
1737
1829
|
Passed to `dataapi_images`
|
1738
1830
|
The default value is False
|
1739
|
-
|
1831
|
+
|
1740
1832
|
raise_if_error : bool, optional
|
1741
1833
|
Whether to raise IndexError or not when the requested index is out of range.
|
1742
1834
|
The default value is False
|
1743
|
-
|
1835
|
+
|
1744
1836
|
Returns
|
1745
1837
|
-------
|
1746
1838
|
dict (if full==True) / np.ndarray (if full==False)
|
1747
1839
|
dict -> the whole input dictionary
|
1748
1840
|
np.ndarray -> the value of 'IMG' in the input dictionary
|
1749
|
-
|
1841
|
+
|
1750
1842
|
Raises
|
1751
1843
|
------
|
1752
1844
|
IndexError
|
@@ -1758,26 +1850,26 @@ class CustomPluginTemplate:
|
|
1758
1850
|
"""
|
1759
1851
|
API for accessing a specific image global inferences
|
1760
1852
|
(shortcut for `dataapi_specific_image_inferences`)
|
1761
|
-
|
1853
|
+
|
1762
1854
|
Parameters
|
1763
1855
|
----------
|
1764
1856
|
idx : int, optional
|
1765
1857
|
Passed to `dataapi_specific_image_inferences`
|
1766
1858
|
The default value is None
|
1767
|
-
|
1859
|
+
|
1768
1860
|
how : str, optional
|
1769
1861
|
Passed to `dataapi_specific_image_inferences`
|
1770
1862
|
The default value is None
|
1771
|
-
|
1863
|
+
|
1772
1864
|
raise_if_error : bool, optional
|
1773
1865
|
Passed to `dataapi_specific_image_inferences`
|
1774
1866
|
The default value is False
|
1775
|
-
|
1867
|
+
|
1776
1868
|
Returns
|
1777
1869
|
-------
|
1778
1870
|
dict (if how == 'dict') or list (if how == 'list')
|
1779
1871
|
returned by `dataapi_specific_image_inferences`
|
1780
|
-
|
1872
|
+
|
1781
1873
|
Raises
|
1782
1874
|
------
|
1783
1875
|
IndexError
|
@@ -1789,7 +1881,7 @@ class CustomPluginTemplate:
|
|
1789
1881
|
"""
|
1790
1882
|
API for accesing inferences for a specific image (global, plugin or instance inferences)
|
1791
1883
|
See `dataapi_images_global_inferences`, `dataapi_images_plugin_inferences`, `dataapi_images_instance_inferences`
|
1792
|
-
|
1884
|
+
|
1793
1885
|
Parameters
|
1794
1886
|
----------
|
1795
1887
|
idx : int, optional
|
@@ -1797,28 +1889,28 @@ class CustomPluginTemplate:
|
|
1797
1889
|
Attention! If there is a metastream that collects 3 inputs - ['IMG', 'STRUCT_DATA', 'IMG'], for accessing the last
|
1798
1890
|
image, `idx` should be 1!
|
1799
1891
|
The default value is 0
|
1800
|
-
|
1892
|
+
|
1801
1893
|
how : str, optional
|
1802
1894
|
Could be: 'list' or 'dict'
|
1803
1895
|
Specifies how the inferences are returned. If 'list', then the AI engine information will be lost and all the
|
1804
1896
|
inferences from all the employed AI engines will be concatenated in a list; If 'dict', then the AI engine information
|
1805
1897
|
will be preserved.
|
1806
1898
|
The default value is None ('list')
|
1807
|
-
|
1899
|
+
|
1808
1900
|
mode : str, optional
|
1809
1901
|
Could be: 'global', 'plugin' or 'instance'
|
1810
1902
|
Specifies which inferences are requested.
|
1811
1903
|
The default value is None ('instance')
|
1812
|
-
|
1904
|
+
|
1813
1905
|
raise_if_error : bool, optional
|
1814
1906
|
Whether to raise IndexError or not when the requested index is out of range.
|
1815
1907
|
The default value is False
|
1816
|
-
|
1908
|
+
|
1817
1909
|
Returns
|
1818
1910
|
-------
|
1819
1911
|
dict (if how == 'dict') or list (if how == 'list')
|
1820
1912
|
the requested image inferences (global, plugin or instance) in the requested format (dict or list)
|
1821
|
-
|
1913
|
+
|
1822
1914
|
Raises
|
1823
1915
|
------
|
1824
1916
|
IndexError
|
@@ -1830,26 +1922,26 @@ class CustomPluginTemplate:
|
|
1830
1922
|
"""
|
1831
1923
|
API for accessing a specific image inferences for the current plugin instance
|
1832
1924
|
(shortcut for `dataapi_specific_image_inferences`)
|
1833
|
-
|
1925
|
+
|
1834
1926
|
Parameters
|
1835
1927
|
----------
|
1836
1928
|
idx : int, optional
|
1837
1929
|
Passed to `dataapi_specific_image_inferences`
|
1838
1930
|
The default value is None
|
1839
|
-
|
1931
|
+
|
1840
1932
|
how : str, optional
|
1841
1933
|
Passed to `dataapi_specific_image_inferences`
|
1842
1934
|
The default value is None ('list')
|
1843
|
-
|
1935
|
+
|
1844
1936
|
raise_if_error : bool, optional
|
1845
1937
|
Passed to `dataapi_specific_image_inferences`
|
1846
1938
|
The default value is False
|
1847
|
-
|
1939
|
+
|
1848
1940
|
Returns
|
1849
1941
|
-------
|
1850
1942
|
dict (if how == 'dict') or list (if how == 'list')
|
1851
1943
|
returned by `dataapi_specific_image_inferences`
|
1852
|
-
|
1944
|
+
|
1853
1945
|
Raises
|
1854
1946
|
------
|
1855
1947
|
IndexError
|
@@ -1861,26 +1953,26 @@ class CustomPluginTemplate:
|
|
1861
1953
|
"""
|
1862
1954
|
API for accessing a specific image plugin inferences
|
1863
1955
|
(shortcut for `dataapi_specific_image_inferences`)
|
1864
|
-
|
1956
|
+
|
1865
1957
|
Parameters
|
1866
1958
|
----------
|
1867
1959
|
idx : int, optional
|
1868
1960
|
Passed to `dataapi_specific_image_inferences`
|
1869
1961
|
The default value is None
|
1870
|
-
|
1962
|
+
|
1871
1963
|
how : str, optional
|
1872
1964
|
Passed to `dataapi_specific_image_inferences`
|
1873
1965
|
The default value is None
|
1874
|
-
|
1966
|
+
|
1875
1967
|
raise_if_error : bool, optional
|
1876
1968
|
Passed to `dataapi_specific_image_inferences`
|
1877
1969
|
The default value is False
|
1878
|
-
|
1970
|
+
|
1879
1971
|
Returns
|
1880
1972
|
-------
|
1881
1973
|
dict (if how == 'dict') or list (if how == 'list')
|
1882
1974
|
returned by `dataapi_specific_image_inferences`
|
1883
|
-
|
1975
|
+
|
1884
1976
|
Raises
|
1885
1977
|
------
|
1886
1978
|
IndexError
|
@@ -1892,26 +1984,26 @@ class CustomPluginTemplate:
|
|
1892
1984
|
"""
|
1893
1985
|
API for accessing a specific image plugin positional inferences
|
1894
1986
|
(shortcut for `dataapi_specific_image_inferences`)
|
1895
|
-
|
1987
|
+
|
1896
1988
|
Parameters
|
1897
1989
|
----------
|
1898
1990
|
idx : int, optional
|
1899
1991
|
Passed to `dataapi_specific_image_inferences`
|
1900
1992
|
The default value is None
|
1901
|
-
|
1993
|
+
|
1902
1994
|
how : str, optional
|
1903
1995
|
Passed to `dataapi_specific_image_inferences`
|
1904
1996
|
The default value is None
|
1905
|
-
|
1997
|
+
|
1906
1998
|
raise_if_error : bool, optional
|
1907
1999
|
Passed to `dataapi_specific_image_inferences`
|
1908
2000
|
The default value is False
|
1909
|
-
|
2001
|
+
|
1910
2002
|
Returns
|
1911
2003
|
-------
|
1912
2004
|
dict (if how == 'dict') or list (if how == 'list')
|
1913
2005
|
returned by `dataapi_specific_image_inferences`
|
1914
|
-
|
2006
|
+
|
1915
2007
|
Raises
|
1916
2008
|
------
|
1917
2009
|
IndexError
|
@@ -1922,17 +2014,17 @@ class CustomPluginTemplate:
|
|
1922
2014
|
def dataapi_specific_input(self, idx, raise_if_error):
|
1923
2015
|
"""
|
1924
2016
|
API for accessing a specific index (by its index in the 'INPUTS' list).
|
1925
|
-
|
2017
|
+
|
1926
2018
|
Parameters
|
1927
2019
|
----------
|
1928
2020
|
idx : int, optional
|
1929
2021
|
The index of the input in the 'INPUTS' list
|
1930
2022
|
The default value is 0.
|
1931
|
-
|
2023
|
+
|
1932
2024
|
raise_if_error : bool, optional
|
1933
2025
|
Whether to raise IndexError or not when the requested index is out of range.
|
1934
2026
|
The default value is False
|
1935
|
-
|
2027
|
+
|
1936
2028
|
Returns
|
1937
2029
|
-------
|
1938
2030
|
dict
|
@@ -1945,7 +2037,7 @@ class CustomPluginTemplate:
|
|
1945
2037
|
'TYPE' : 'IMG',
|
1946
2038
|
'METADATA' : {Dictionary with current input metadata}
|
1947
2039
|
}
|
1948
|
-
|
2040
|
+
|
1949
2041
|
Raises
|
1950
2042
|
------
|
1951
2043
|
IndexError
|
@@ -1956,22 +2048,22 @@ class CustomPluginTemplate:
|
|
1956
2048
|
def dataapi_specific_input_init_data(self, idx, raise_if_error):
|
1957
2049
|
"""
|
1958
2050
|
API for accessing the initial data of a specific input
|
1959
|
-
|
2051
|
+
|
1960
2052
|
Parameters
|
1961
2053
|
----------
|
1962
2054
|
idx : int, optional
|
1963
2055
|
Passed to `dataapi_specific_input`
|
1964
2056
|
The default value is 0
|
1965
|
-
|
2057
|
+
|
1966
2058
|
raise_if_error : bool, optional
|
1967
2059
|
Passed to `dataapi_specific_input`
|
1968
2060
|
The default value is False
|
1969
|
-
|
2061
|
+
|
1970
2062
|
Returns
|
1971
2063
|
-------
|
1972
2064
|
dict
|
1973
2065
|
the value of "INIT_DATA" key in the requested input
|
1974
|
-
|
2066
|
+
|
1975
2067
|
Raises
|
1976
2068
|
------
|
1977
2069
|
IndexError
|
@@ -1982,22 +2074,22 @@ class CustomPluginTemplate:
|
|
1982
2074
|
def dataapi_specific_input_metadata(self, idx, raise_if_error):
|
1983
2075
|
"""
|
1984
2076
|
API for accessing the metadata of a specific input
|
1985
|
-
|
2077
|
+
|
1986
2078
|
Parameters
|
1987
2079
|
----------
|
1988
2080
|
idx : int, optional
|
1989
2081
|
Passed to `dataapi_specific_input`
|
1990
2082
|
The default value is 0
|
1991
|
-
|
2083
|
+
|
1992
2084
|
raise_if_error : bool, optional
|
1993
2085
|
Passed to `dataapi_specific_input`
|
1994
2086
|
The default value is False
|
1995
|
-
|
2087
|
+
|
1996
2088
|
Returns
|
1997
2089
|
-------
|
1998
2090
|
dict
|
1999
2091
|
the value of "METADATA" key in the requested input
|
2000
|
-
|
2092
|
+
|
2001
2093
|
Raises
|
2002
2094
|
------
|
2003
2095
|
IndexError
|
@@ -2008,7 +2100,7 @@ class CustomPluginTemplate:
|
|
2008
2100
|
def dataapi_specific_struct_data(self, idx, full, raise_if_error):
|
2009
2101
|
"""
|
2010
2102
|
API for accessing a specific structured data in the 'INPUTS' list
|
2011
|
-
|
2103
|
+
|
2012
2104
|
Parameters
|
2013
2105
|
----------
|
2014
2106
|
idx : int, optional
|
@@ -2016,21 +2108,21 @@ class CustomPluginTemplate:
|
|
2016
2108
|
Attention! If there is a metastream that collects 3 inputs - ['IMG', 'STRUCT_DATA', 'IMG'], for accessing the structured data
|
2017
2109
|
`idx` should be 0!
|
2018
2110
|
The default value is 0
|
2019
|
-
|
2111
|
+
|
2020
2112
|
full : bool, optional
|
2021
2113
|
Passed to `dataapi_struct_datas`
|
2022
2114
|
The default value is False
|
2023
|
-
|
2115
|
+
|
2024
2116
|
raise_if_error : bool, optional
|
2025
2117
|
Whether to raise IndexError or not when the requested index is out of range.
|
2026
2118
|
The default value is True
|
2027
|
-
|
2119
|
+
|
2028
2120
|
Returns
|
2029
2121
|
-------
|
2030
2122
|
dict (if full==True) / object (if full==False)
|
2031
2123
|
dict -> the whole input dictionary
|
2032
2124
|
object -> the value of 'STRUCT_DATA' in the input dictionary
|
2033
|
-
|
2125
|
+
|
2034
2126
|
Raises
|
2035
2127
|
------
|
2036
2128
|
IndexError
|
@@ -2041,7 +2133,7 @@ class CustomPluginTemplate:
|
|
2041
2133
|
def dataapi_specific_struct_data_inferences(self, idx, how, raise_if_error):
|
2042
2134
|
"""
|
2043
2135
|
API for accesing a specific structured data inferences
|
2044
|
-
|
2136
|
+
|
2045
2137
|
Parameters
|
2046
2138
|
----------
|
2047
2139
|
idx : int, optional
|
@@ -2049,23 +2141,23 @@ class CustomPluginTemplate:
|
|
2049
2141
|
Attention! If there is a metastream that collects 3 inputs - ['IMG', 'STRUCT_DATA', 'IMG'], for accessing the structured data,
|
2050
2142
|
`idx` should be 0!
|
2051
2143
|
The default value is 0
|
2052
|
-
|
2144
|
+
|
2053
2145
|
how : str, optional
|
2054
2146
|
Could be: 'list' or 'dict'
|
2055
2147
|
Specifies how the inferences are returned. If 'list', then the AI engine information will be lost and all the
|
2056
2148
|
inferences from all the employed AI engines will be concatenated in a list; If 'dict', then the AI engine information
|
2057
2149
|
will be preserved.
|
2058
2150
|
The default value is None ('list')
|
2059
|
-
|
2151
|
+
|
2060
2152
|
raise_if_error : bool, optional
|
2061
2153
|
Whether to raise IndexError or not when the requested index is out of range.
|
2062
2154
|
The default value is False
|
2063
|
-
|
2155
|
+
|
2064
2156
|
Returns
|
2065
2157
|
-------
|
2066
2158
|
dict (if how == 'dict') or list (if how == 'list')
|
2067
2159
|
the requested structured data inferences in the requested format (dict or list)
|
2068
|
-
|
2160
|
+
|
2069
2161
|
Raises
|
2070
2162
|
------
|
2071
2163
|
IndexError
|
@@ -2080,7 +2172,7 @@ class CustomPluginTemplate:
|
|
2080
2172
|
"""
|
2081
2173
|
This function serves returns all the params that configured the current execution
|
2082
2174
|
pipeline where the plugin instance is executed.
|
2083
|
-
|
2175
|
+
|
2084
2176
|
Returns
|
2085
2177
|
-------
|
2086
2178
|
dict
|
@@ -2101,22 +2193,22 @@ class CustomPluginTemplate:
|
|
2101
2193
|
"""
|
2102
2194
|
API for accessing the first structured data in the 'INPUTS' list
|
2103
2195
|
(shortcut for `dataapi_specific_struct_data`, most of the cases will have a single structured data on a stream)
|
2104
|
-
|
2196
|
+
|
2105
2197
|
Parameters
|
2106
2198
|
----------
|
2107
2199
|
full : bool, optional
|
2108
2200
|
Passed to `dataapi_specific_struct_data`
|
2109
2201
|
The default value is False
|
2110
|
-
|
2202
|
+
|
2111
2203
|
raise_if_error : bool, optional
|
2112
2204
|
Passed to `dataapi_specific_struct_data`
|
2113
2205
|
The default value is True
|
2114
|
-
|
2206
|
+
|
2115
2207
|
Returns
|
2116
2208
|
-------
|
2117
2209
|
dict (if full==True) / object (if full==False)
|
2118
2210
|
Returned by `dataapi_specific_struct_data`
|
2119
|
-
|
2211
|
+
|
2120
2212
|
Raises
|
2121
2213
|
------
|
2122
2214
|
IndexError
|
@@ -2128,22 +2220,22 @@ class CustomPluginTemplate:
|
|
2128
2220
|
"""
|
2129
2221
|
API for accesing a the first structured data inferences
|
2130
2222
|
(shortcut for `dataapi_specific_struct_data_inferences`, most of the cases will have a single struct data on a stream)
|
2131
|
-
|
2223
|
+
|
2132
2224
|
Parameters
|
2133
2225
|
----------
|
2134
2226
|
how : str, optional
|
2135
2227
|
Passed to `dataapi_specific_struct_data_inferences`
|
2136
2228
|
The default value is None
|
2137
|
-
|
2229
|
+
|
2138
2230
|
raise_if_error : bool, optional
|
2139
2231
|
Passed to `dataapi_specific_struct_data_inferences`
|
2140
2232
|
The default value is False
|
2141
|
-
|
2233
|
+
|
2142
2234
|
Returns
|
2143
2235
|
-------
|
2144
2236
|
dict (if how == 'dict') or list (if how == 'list')
|
2145
2237
|
returned by `dataapi_specific_struct_data_inferences`
|
2146
|
-
|
2238
|
+
|
2147
2239
|
Raises
|
2148
2240
|
------
|
2149
2241
|
IndexError
|
@@ -2154,13 +2246,13 @@ class CustomPluginTemplate:
|
|
2154
2246
|
def dataapi_struct_datas(self, full):
|
2155
2247
|
"""
|
2156
2248
|
API for accessing all the structured datas in the 'INPUTS' list
|
2157
|
-
|
2249
|
+
|
2158
2250
|
Parameters
|
2159
2251
|
----------
|
2160
2252
|
full : bool, optional
|
2161
2253
|
Specifies whether the structured datas are returned full (the whole input dictionary) or not (just the value of 'STRUCT_DATA' in the input dictionary)
|
2162
2254
|
The default value is False
|
2163
|
-
|
2255
|
+
|
2164
2256
|
Returns
|
2165
2257
|
-------
|
2166
2258
|
dict{int : dict} (if full==True) / dict{int : object} (if full==False)
|
@@ -2175,9 +2267,9 @@ class CustomPluginTemplate:
|
|
2175
2267
|
'METADATA' : {Dictionary with current input metadata}
|
2176
2268
|
}
|
2177
2269
|
} if full==True
|
2178
|
-
|
2270
|
+
|
2179
2271
|
or
|
2180
|
-
|
2272
|
+
|
2181
2273
|
{
|
2182
2274
|
0 : an_object
|
2183
2275
|
} if full==False
|
@@ -2188,7 +2280,7 @@ class CustomPluginTemplate:
|
|
2188
2280
|
"""
|
2189
2281
|
API for accessing just the structured datas inferences.
|
2190
2282
|
Filters the output of `dataapi_inferences`, keeping only the AI engines that run on structured datas
|
2191
|
-
|
2283
|
+
|
2192
2284
|
Returns
|
2193
2285
|
-------
|
2194
2286
|
dict{str:list}
|
@@ -2197,15 +2289,15 @@ class CustomPluginTemplate:
|
|
2197
2289
|
raise NotImplementedError
|
2198
2290
|
|
2199
2291
|
@property
|
2200
|
-
def datetime():
|
2292
|
+
def datetime(self):
|
2201
2293
|
"""
|
2202
2294
|
Proxy for the `datetime.datetime`
|
2203
|
-
|
2295
|
+
|
2204
2296
|
Returns
|
2205
2297
|
-------
|
2206
2298
|
datetime : datetime object
|
2207
|
-
|
2208
|
-
|
2299
|
+
|
2300
|
+
|
2209
2301
|
Example
|
2210
2302
|
-------
|
2211
2303
|
```
|
@@ -2217,20 +2309,20 @@ class CustomPluginTemplate:
|
|
2217
2309
|
def datetime_to_str(self, dt, fmt):
|
2218
2310
|
"""
|
2219
2311
|
Returns the string representation of current datetime or of a given datetime
|
2220
|
-
|
2312
|
+
|
2221
2313
|
Parameters
|
2222
2314
|
----------
|
2223
2315
|
dt : datetime, optional
|
2224
2316
|
a given datetime. The default is `None` and will generate string for current date.
|
2225
2317
|
fmt : str, optional
|
2226
2318
|
datetime format. The default is '%Y-%m-%d %H:%M:%S'.
|
2227
|
-
|
2319
|
+
|
2228
2320
|
Returns
|
2229
2321
|
-------
|
2230
2322
|
str
|
2231
2323
|
the datetime in string format.
|
2232
|
-
|
2233
|
-
|
2324
|
+
|
2325
|
+
|
2234
2326
|
Example
|
2235
2327
|
-------
|
2236
2328
|
```
|
@@ -2246,22 +2338,22 @@ class CustomPluginTemplate:
|
|
2246
2338
|
raise NotImplementedError
|
2247
2339
|
|
2248
2340
|
@property
|
2249
|
-
def deepcopy():
|
2341
|
+
def deepcopy(self):
|
2250
2342
|
"""
|
2251
2343
|
This method allows us to use the method deepcopy
|
2252
2344
|
"""
|
2253
2345
|
raise NotImplementedError
|
2254
2346
|
|
2255
2347
|
@property
|
2256
|
-
def defaultdict():
|
2348
|
+
def defaultdict(self):
|
2257
2349
|
"""
|
2258
2350
|
provides access to defaultdict class
|
2259
|
-
|
2260
|
-
|
2351
|
+
|
2352
|
+
|
2261
2353
|
Returns
|
2262
2354
|
-------
|
2263
2355
|
defaultdict : class
|
2264
|
-
|
2356
|
+
|
2265
2357
|
Example
|
2266
2358
|
-------
|
2267
2359
|
```
|
@@ -2271,7 +2363,7 @@ class CustomPluginTemplate:
|
|
2271
2363
|
raise NotImplementedError
|
2272
2364
|
|
2273
2365
|
@property
|
2274
|
-
def deque():
|
2366
|
+
def deque(self):
|
2275
2367
|
"""
|
2276
2368
|
provides access to deque class
|
2277
2369
|
"""
|
@@ -2280,18 +2372,18 @@ class CustomPluginTemplate:
|
|
2280
2372
|
def dict_to_str(self, dct):
|
2281
2373
|
"""
|
2282
2374
|
Transforms a dict into a pre-formatted strig without json package
|
2283
|
-
|
2375
|
+
|
2284
2376
|
Parameters
|
2285
2377
|
----------
|
2286
2378
|
dct : dict
|
2287
2379
|
The given dict that will be string formatted.
|
2288
|
-
|
2380
|
+
|
2289
2381
|
Returns
|
2290
2382
|
-------
|
2291
2383
|
str
|
2292
2384
|
the nicely formatted.
|
2293
|
-
|
2294
|
-
|
2385
|
+
|
2386
|
+
|
2295
2387
|
Example:
|
2296
2388
|
-------
|
2297
2389
|
```
|
@@ -2301,12 +2393,25 @@ class CustomPluginTemplate:
|
|
2301
2393
|
},
|
2302
2394
|
'b' : 'abc'
|
2303
2395
|
}
|
2304
|
-
|
2396
|
+
|
2305
2397
|
str_nice_dict = self.dict_to_str(dct=dct)
|
2306
2398
|
```
|
2307
2399
|
"""
|
2308
2400
|
raise NotImplementedError
|
2309
2401
|
|
2402
|
+
def diskapi_copy_file(self, src_path, dst_path):
|
2403
|
+
"""
|
2404
|
+
Copy a file from src to dst if safe.
|
2405
|
+
Parameters
|
2406
|
+
----------
|
2407
|
+
src_path - string, path to the source file
|
2408
|
+
dst_path - string, path to the destination file
|
2409
|
+
|
2410
|
+
Returns
|
2411
|
+
-------
|
2412
|
+
"""
|
2413
|
+
raise NotImplementedError
|
2414
|
+
|
2310
2415
|
def diskapi_create_video_file_to_data(self, filename, fps, str_codec, frame_size, universal_codec):
|
2311
2416
|
"""
|
2312
2417
|
Shortcut to `_diskapi_create_video_file`
|
@@ -2331,7 +2436,7 @@ class CustomPluginTemplate:
|
|
2331
2436
|
Parameters
|
2332
2437
|
----------
|
2333
2438
|
dir_path - string, path to the directory to be deleted
|
2334
|
-
|
2439
|
+
|
2335
2440
|
Returns
|
2336
2441
|
-------
|
2337
2442
|
"""
|
@@ -2343,7 +2448,7 @@ class CustomPluginTemplate:
|
|
2343
2448
|
Parameters
|
2344
2449
|
----------
|
2345
2450
|
file_path - string, path to the file to be deleted
|
2346
|
-
|
2451
|
+
|
2347
2452
|
Returns
|
2348
2453
|
-------
|
2349
2454
|
"""
|
@@ -2367,6 +2472,21 @@ class CustomPluginTemplate:
|
|
2367
2472
|
"""
|
2368
2473
|
raise NotImplementedError
|
2369
2474
|
|
2475
|
+
def diskapi_load_image(self, filename, folder, subdir):
|
2476
|
+
"""
|
2477
|
+
Method for loading an image from local cache.
|
2478
|
+
Parameters
|
2479
|
+
----------
|
2480
|
+
filename - string, the name of the file
|
2481
|
+
folder - string, the folder in local cache
|
2482
|
+
subdir - string, the subfolder in local cache
|
2483
|
+
|
2484
|
+
Returns
|
2485
|
+
-------
|
2486
|
+
np.ndarray, the loaded image
|
2487
|
+
"""
|
2488
|
+
raise NotImplementedError
|
2489
|
+
|
2370
2490
|
def diskapi_load_json_from_data(self, filename, verbose):
|
2371
2491
|
"""
|
2372
2492
|
Shortcut to _diskapi_load_json.
|
@@ -2403,19 +2523,22 @@ class CustomPluginTemplate:
|
|
2403
2523
|
"""
|
2404
2524
|
raise NotImplementedError
|
2405
2525
|
|
2406
|
-
def diskapi_save_dataframe_to_data(self, df, filename, ignore_index, compress, mode, header, also_markdown, verbose,
|
2526
|
+
def diskapi_save_dataframe_to_data(self, df, filename, ignore_index, compress, mode, header, also_markdown, verbose,
|
2527
|
+
as_parquet):
|
2407
2528
|
"""
|
2408
2529
|
Shortcut to _diskapi_save_dataframe.
|
2409
2530
|
"""
|
2410
2531
|
raise NotImplementedError
|
2411
2532
|
|
2412
|
-
def diskapi_save_dataframe_to_models(self, df, filename, ignore_index, compress, mode, header, also_markdown, verbose,
|
2533
|
+
def diskapi_save_dataframe_to_models(self, df, filename, ignore_index, compress, mode, header, also_markdown, verbose,
|
2534
|
+
as_parquet):
|
2413
2535
|
"""
|
2414
2536
|
Shortcut to _diskapi_save_dataframe.
|
2415
2537
|
"""
|
2416
2538
|
raise NotImplementedError
|
2417
2539
|
|
2418
|
-
def diskapi_save_dataframe_to_output(self, df, filename, ignore_index, compress, mode, header, also_markdown, verbose,
|
2540
|
+
def diskapi_save_dataframe_to_output(self, df, filename, ignore_index, compress, mode, header, also_markdown, verbose,
|
2541
|
+
as_parquet):
|
2419
2542
|
"""
|
2420
2543
|
Shortcut to _diskapi_save_dataframe.
|
2421
2544
|
"""
|
@@ -2430,7 +2553,7 @@ class CustomPluginTemplate:
|
|
2430
2553
|
filename - string, the name of the file
|
2431
2554
|
subdir - string, the subfolder in local cache
|
2432
2555
|
extension - string, the extension of the file
|
2433
|
-
|
2556
|
+
|
2434
2557
|
Returns
|
2435
2558
|
-------
|
2436
2559
|
bool, True if the file was saved successfully, False otherwise
|
@@ -2446,7 +2569,7 @@ class CustomPluginTemplate:
|
|
2446
2569
|
filename - string, the name of the file
|
2447
2570
|
subdir - string, the subfolder in local cache
|
2448
2571
|
extension - string, the extension of the file
|
2449
|
-
|
2572
|
+
|
2450
2573
|
Returns
|
2451
2574
|
-------
|
2452
2575
|
bool, True if the image was saved successfully, False otherwise
|
@@ -2496,7 +2619,7 @@ class CustomPluginTemplate:
|
|
2496
2619
|
----------
|
2497
2620
|
zip_path - string, path to .zip file
|
2498
2621
|
dir_path - string, path to directory into which to unzip the input .zip file
|
2499
|
-
|
2622
|
+
|
2500
2623
|
Returns
|
2501
2624
|
-------
|
2502
2625
|
string, the path to the unzipped directory
|
@@ -2509,21 +2632,22 @@ class CustomPluginTemplate:
|
|
2509
2632
|
-----------
|
2510
2633
|
handler: _, mandatory
|
2511
2634
|
the handler returned by `diskapi_create_video_file`
|
2512
|
-
|
2635
|
+
|
2513
2636
|
frame: np.ndarray, mandatory
|
2514
2637
|
the frame to be written in the video file.
|
2515
2638
|
Must have the the same H,W specified in `diskapi_create_video_file`
|
2516
2639
|
"""
|
2517
2640
|
raise NotImplementedError
|
2518
2641
|
|
2519
|
-
def diskapi_zip_dir(self, dir_path, zip_path):
|
2642
|
+
def diskapi_zip_dir(self, dir_path, zip_path, include_dir):
|
2520
2643
|
"""
|
2521
2644
|
Zip the contents of an entire folder (with that folder included).
|
2522
2645
|
Parameters
|
2523
2646
|
----------
|
2524
2647
|
dir_path - string, path of directory to zip
|
2525
2648
|
zip_path - string, path of the output zip file. If None, zip_path will be dir_path + ".zip"
|
2526
|
-
|
2649
|
+
include_dir - bool, whether to include the directory itself in the zip file
|
2650
|
+
|
2527
2651
|
Returns
|
2528
2652
|
-------
|
2529
2653
|
string, the path to the zipped directory
|
@@ -2531,37 +2655,37 @@ class CustomPluginTemplate:
|
|
2531
2655
|
raise NotImplementedError
|
2532
2656
|
|
2533
2657
|
@property
|
2534
|
-
def docker_branch():
|
2658
|
+
def docker_branch(self):
|
2535
2659
|
raise NotImplementedError
|
2536
2660
|
|
2537
2661
|
def download(self, url, fn, target, kwargs):
|
2538
2662
|
"""
|
2539
2663
|
Dowload wrapper that will download a given file from a url to `_local_cache/_output.
|
2540
|
-
|
2541
|
-
|
2664
|
+
|
2665
|
+
|
2542
2666
|
TODO: fix to use specific endpoints configs not only from base file_system_manager
|
2543
|
-
|
2667
|
+
|
2544
2668
|
Parameters
|
2545
2669
|
----------
|
2546
2670
|
url : str
|
2547
2671
|
the url where to find the file.
|
2548
|
-
|
2672
|
+
|
2549
2673
|
fn : str
|
2550
2674
|
local file name to be saved in `target` folder.
|
2551
|
-
|
2675
|
+
|
2552
2676
|
**kwargs : dict
|
2553
2677
|
params for special upload procedures such as minio.
|
2554
|
-
|
2555
|
-
|
2678
|
+
|
2679
|
+
|
2556
2680
|
Returns
|
2557
2681
|
-------
|
2558
2682
|
res : str
|
2559
2683
|
path of the downloaded file, None if not found.
|
2560
|
-
|
2561
|
-
|
2684
|
+
|
2685
|
+
|
2562
2686
|
Example
|
2563
2687
|
-------
|
2564
|
-
|
2688
|
+
|
2565
2689
|
```
|
2566
2690
|
res = plugin.download('http://drive.google.com/file-url', 'test.bin')
|
2567
2691
|
if res is not None:
|
@@ -2571,7 +2695,7 @@ class CustomPluginTemplate:
|
|
2571
2695
|
raise NotImplementedError
|
2572
2696
|
|
2573
2697
|
@property
|
2574
|
-
def ds_consts():
|
2698
|
+
def ds_consts(self):
|
2575
2699
|
"""
|
2576
2700
|
Alias for DatasetBuilder class from E2 constants
|
2577
2701
|
Provides access to constants used in DatasetBuilderMixin
|
@@ -2583,50 +2707,81 @@ class CustomPluginTemplate:
|
|
2583
2707
|
raise NotImplementedError
|
2584
2708
|
|
2585
2709
|
@property
|
2586
|
-
def e2_addr():
|
2710
|
+
def e2_addr(self):
|
2587
2711
|
raise NotImplementedError
|
2588
2712
|
|
2589
2713
|
@property
|
2590
|
-
def e2_id():
|
2714
|
+
def e2_id(self):
|
2591
2715
|
raise NotImplementedError
|
2592
2716
|
|
2593
2717
|
@property
|
2594
|
-
def ee_addr():
|
2718
|
+
def ee_addr(self):
|
2595
2719
|
raise NotImplementedError
|
2596
2720
|
|
2597
2721
|
@property
|
2598
|
-
def ee_id():
|
2722
|
+
def ee_id(self):
|
2599
2723
|
raise NotImplementedError
|
2600
2724
|
|
2601
2725
|
@property
|
2602
|
-
def ee_ver():
|
2726
|
+
def ee_ver(self):
|
2603
2727
|
raise NotImplementedError
|
2604
2728
|
|
2605
2729
|
@property
|
2606
|
-
def eeid():
|
2730
|
+
def eeid(self):
|
2607
2731
|
raise NotImplementedError
|
2608
2732
|
|
2609
2733
|
def end_timer(self, tmr_id, skip_first_timing, kwargs):
|
2610
2734
|
raise NotImplementedError
|
2611
2735
|
|
2612
|
-
def exec_code(self, str_b64code, debug, result_vars, self_var, modify):
|
2736
|
+
def exec_code(self, str_b64code, debug, result_vars, self_var, modify, return_printed, timeout):
|
2613
2737
|
raise NotImplementedError
|
2614
2738
|
|
2615
2739
|
@property
|
2616
|
-
def exec_timestamp():
|
2740
|
+
def exec_timestamp(self):
|
2617
2741
|
raise NotImplementedError
|
2618
2742
|
|
2619
2743
|
def execute(self):
|
2620
2744
|
"""
|
2621
2745
|
The main execution of a plugin instance.
|
2622
2746
|
This public method should NOT be overwritten under any circumstance
|
2623
|
-
|
2747
|
+
|
2624
2748
|
Returns
|
2625
2749
|
-------
|
2626
2750
|
None.
|
2627
2751
|
"""
|
2628
2752
|
raise NotImplementedError
|
2629
2753
|
|
2754
|
+
def execute_code(self, code, local_vars, output_queue, print_queue):
|
2755
|
+
raise NotImplementedError
|
2756
|
+
|
2757
|
+
def execute_code_with_timeout(self, code, timeout, local_vars):
|
2758
|
+
raise NotImplementedError
|
2759
|
+
|
2760
|
+
def execute_remote_code(self, code, debug, timeout):
|
2761
|
+
"""
|
2762
|
+
Execute code received remotely.
|
2763
|
+
Parameters
|
2764
|
+
----------
|
2765
|
+
code : str
|
2766
|
+
the code to be executed
|
2767
|
+
debug : bool, optional
|
2768
|
+
if True, the code will be executed in debug mode. The default is False.
|
2769
|
+
timeout : int, optional
|
2770
|
+
the timeout for the code execution. The default is 10.
|
2771
|
+
Returns
|
2772
|
+
-------
|
2773
|
+
dict: the result of the code execution
|
2774
|
+
If the code execution was successful, the result will contain the following keys:
|
2775
|
+
- result: the result of the code execution
|
2776
|
+
- errors: the errors that occurred during the execution
|
2777
|
+
- warnings: the warnings that occurred during the execution
|
2778
|
+
- prints: the printed messages during the execution
|
2779
|
+
- timestamp: the timestamp of the execution
|
2780
|
+
If the code execution failed, the result will contain the following key:
|
2781
|
+
- error: the error message
|
2782
|
+
"""
|
2783
|
+
raise NotImplementedError
|
2784
|
+
|
2630
2785
|
def filter_inferences(self, data, inferences):
|
2631
2786
|
"""
|
2632
2787
|
Method used for filtering the inferences that will be saved.
|
@@ -2635,7 +2790,7 @@ class CustomPluginTemplate:
|
|
2635
2790
|
Parameters
|
2636
2791
|
----------
|
2637
2792
|
inferences - list of inferences
|
2638
|
-
|
2793
|
+
|
2639
2794
|
Returns
|
2640
2795
|
-------
|
2641
2796
|
res - list of filtered inferences
|
@@ -2650,7 +2805,7 @@ class CustomPluginTemplate:
|
|
2650
2805
|
Parameters
|
2651
2806
|
----------
|
2652
2807
|
inferences - list of inferences
|
2653
|
-
|
2808
|
+
|
2654
2809
|
Returns
|
2655
2810
|
-------
|
2656
2811
|
res - list of filtered inferences indexes
|
@@ -2658,22 +2813,22 @@ class CustomPluginTemplate:
|
|
2658
2813
|
raise NotImplementedError
|
2659
2814
|
|
2660
2815
|
@property
|
2661
|
-
def first_process_time():
|
2816
|
+
def first_process_time(self):
|
2662
2817
|
raise NotImplementedError
|
2663
2818
|
|
2664
2819
|
@property
|
2665
|
-
def float_cache():
|
2820
|
+
def float_cache(self):
|
2666
2821
|
"""
|
2667
2822
|
Can be used as a statefull store of the instance - eg `plugin.float_cache[key]` will return 0
|
2668
|
-
if that key has never been initialized
|
2669
|
-
|
2670
|
-
|
2823
|
+
if that key has never been initialized
|
2824
|
+
|
2825
|
+
|
2671
2826
|
Returns
|
2672
2827
|
-------
|
2673
2828
|
dict of floats
|
2674
2829
|
Returns a default dict for float values initialized with zeros.
|
2675
|
-
|
2676
|
-
|
2830
|
+
|
2831
|
+
|
2677
2832
|
Example
|
2678
2833
|
-------
|
2679
2834
|
```
|
@@ -2688,15 +2843,15 @@ class CustomPluginTemplate:
|
|
2688
2843
|
raise NotImplementedError
|
2689
2844
|
|
2690
2845
|
@property
|
2691
|
-
def geometry_methods():
|
2846
|
+
def geometry_methods(self):
|
2692
2847
|
"""
|
2693
2848
|
Proxy for geometry_methods from decentra_vision.geometry_methods
|
2694
|
-
|
2849
|
+
|
2695
2850
|
"""
|
2696
2851
|
raise NotImplementedError
|
2697
2852
|
|
2698
2853
|
@property
|
2699
|
-
def get_additional_keys():
|
2854
|
+
def get_additional_keys(self):
|
2700
2855
|
raise NotImplementedError
|
2701
2856
|
|
2702
2857
|
def get_alerter(self, alerter):
|
@@ -2708,17 +2863,17 @@ class CustomPluginTemplate:
|
|
2708
2863
|
def get_alive_time(self, as_str):
|
2709
2864
|
"""
|
2710
2865
|
Returns plugin alive time
|
2711
|
-
|
2866
|
+
|
2712
2867
|
Parameters
|
2713
2868
|
----------
|
2714
2869
|
as_str : bool, optional
|
2715
2870
|
return as string. The default is False.
|
2716
|
-
|
2871
|
+
|
2717
2872
|
Returns
|
2718
2873
|
-------
|
2719
2874
|
result : float or str
|
2720
|
-
|
2721
|
-
|
2875
|
+
|
2876
|
+
|
2722
2877
|
Example
|
2723
2878
|
-------
|
2724
2879
|
```
|
@@ -2728,7 +2883,7 @@ class CustomPluginTemplate:
|
|
2728
2883
|
raise NotImplementedError
|
2729
2884
|
|
2730
2885
|
@property
|
2731
|
-
def get_background_period_save():
|
2886
|
+
def get_background_period_save(self):
|
2732
2887
|
raise NotImplementedError
|
2733
2888
|
|
2734
2889
|
def get_base64code(self):
|
@@ -2755,7 +2910,7 @@ class CustomPluginTemplate:
|
|
2755
2910
|
raise NotImplementedError
|
2756
2911
|
|
2757
2912
|
@property
|
2758
|
-
def get_dataset_builder_params():
|
2913
|
+
def get_dataset_builder_params(self):
|
2759
2914
|
raise NotImplementedError
|
2760
2915
|
|
2761
2916
|
def get_dataset_name(self):
|
@@ -2773,12 +2928,12 @@ class CustomPluginTemplate:
|
|
2773
2928
|
def get_exception(self):
|
2774
2929
|
"""
|
2775
2930
|
Returns last exception fullstack
|
2776
|
-
|
2931
|
+
|
2777
2932
|
Returns
|
2778
2933
|
-------
|
2779
2934
|
string
|
2780
2935
|
The full multi-line stack.
|
2781
|
-
|
2936
|
+
|
2782
2937
|
Example:
|
2783
2938
|
```
|
2784
2939
|
```
|
@@ -2786,23 +2941,55 @@ class CustomPluginTemplate:
|
|
2786
2941
|
raise NotImplementedError
|
2787
2942
|
|
2788
2943
|
@property
|
2789
|
-
def get_expand_value():
|
2944
|
+
def get_expand_value(self):
|
2945
|
+
raise NotImplementedError
|
2946
|
+
|
2947
|
+
def get_function_source_code(self, func):
|
2948
|
+
"""
|
2949
|
+
Get the source code of a function and remove the indentation.
|
2950
|
+
|
2951
|
+
Parameters
|
2952
|
+
----------
|
2953
|
+
func : Callable
|
2954
|
+
The function.
|
2955
|
+
|
2956
|
+
Returns
|
2957
|
+
-------
|
2958
|
+
str
|
2959
|
+
The source code of the function.
|
2960
|
+
"""
|
2790
2961
|
raise NotImplementedError
|
2791
2962
|
|
2792
2963
|
@property
|
2793
|
-
def get_generic_path():
|
2964
|
+
def get_generic_path(self):
|
2965
|
+
raise NotImplementedError
|
2966
|
+
|
2967
|
+
def get_gpu_info(self, device_id):
|
2968
|
+
"""
|
2969
|
+
Returns the GPU information
|
2970
|
+
|
2971
|
+
Parameters
|
2972
|
+
----------
|
2973
|
+
device_id : int, optional
|
2974
|
+
The device id. The default is 0.
|
2975
|
+
|
2976
|
+
Returns
|
2977
|
+
-------
|
2978
|
+
dict
|
2979
|
+
The dictionary containing the GPU information
|
2980
|
+
"""
|
2794
2981
|
raise NotImplementedError
|
2795
2982
|
|
2796
2983
|
@property
|
2797
|
-
def get_image_crop():
|
2984
|
+
def get_image_crop(self):
|
2798
2985
|
raise NotImplementedError
|
2799
2986
|
|
2800
2987
|
@property
|
2801
|
-
def get_image_save():
|
2988
|
+
def get_image_save(self):
|
2802
2989
|
raise NotImplementedError
|
2803
2990
|
|
2804
2991
|
@property
|
2805
|
-
def get_inference_mapping():
|
2992
|
+
def get_inference_mapping(self):
|
2806
2993
|
raise NotImplementedError
|
2807
2994
|
|
2808
2995
|
def get_inference_track_tlbr(self, inference):
|
@@ -2813,7 +3000,7 @@ class CustomPluginTemplate:
|
|
2813
3000
|
Parameters
|
2814
3001
|
----------
|
2815
3002
|
inference - dict, inference dictionary
|
2816
|
-
|
3003
|
+
|
2817
3004
|
Returns
|
2818
3005
|
-------
|
2819
3006
|
res - list, list of 4 ints representing the TLBR that will be used for tracking
|
@@ -2830,14 +3017,14 @@ class CustomPluginTemplate:
|
|
2830
3017
|
raise NotImplementedError
|
2831
3018
|
|
2832
3019
|
@property
|
2833
|
-
def get_label_file_template():
|
3020
|
+
def get_label_file_template(self):
|
2834
3021
|
raise NotImplementedError
|
2835
3022
|
|
2836
3023
|
def get_label_template_lines(self):
|
2837
3024
|
raise NotImplementedError
|
2838
3025
|
|
2839
3026
|
@property
|
2840
|
-
def get_label_template_type():
|
3027
|
+
def get_label_template_type(self):
|
2841
3028
|
raise NotImplementedError
|
2842
3029
|
|
2843
3030
|
def get_last_payload_data(self):
|
@@ -2858,7 +3045,7 @@ class CustomPluginTemplate:
|
|
2858
3045
|
- if this is None both zone1_point and zone2_point will be auto-generated
|
2859
3046
|
start_point - list or None, list of 2 int/floats describing the starting point of the current object
|
2860
3047
|
- if this is None, we will consider the first appearance of the current object as the start
|
2861
|
-
|
3048
|
+
|
2862
3049
|
Returns
|
2863
3050
|
-------
|
2864
3051
|
None if the object stayed in one zone
|
@@ -2877,13 +3064,13 @@ class CustomPluginTemplate:
|
|
2877
3064
|
raise NotImplementedError
|
2878
3065
|
|
2879
3066
|
@property
|
2880
|
-
def get_mandatory_keys():
|
3067
|
+
def get_mandatory_keys(self):
|
2881
3068
|
raise NotImplementedError
|
2882
3069
|
|
2883
3070
|
def get_models_file(self, fn):
|
2884
3071
|
"""
|
2885
3072
|
Retruns path to models file
|
2886
|
-
|
3073
|
+
|
2887
3074
|
:param fn: string - file name
|
2888
3075
|
"""
|
2889
3076
|
raise NotImplementedError
|
@@ -2896,10 +3083,11 @@ class CustomPluginTemplate:
|
|
2896
3083
|
"""
|
2897
3084
|
raise NotImplementedError
|
2898
3085
|
|
2899
|
-
def get_movement_relative_to_line(self, object_id, object_type, line, zone1_point, zone2_point, threshold,
|
3086
|
+
def get_movement_relative_to_line(self, object_id, object_type, line, zone1_point, zone2_point, threshold,
|
3087
|
+
start_point):
|
2900
3088
|
"""
|
2901
3089
|
Returns the point direction movement relative to a line (if no points are given, they are automatically generation).
|
2902
|
-
|
3090
|
+
|
2903
3091
|
If the object moved from point A to point B (relative to a line) it returns a tuple with the order (PointA, PointB),
|
2904
3092
|
otherwise it returns the tuple reversed (PointB, PointA)
|
2905
3093
|
"""
|
@@ -2924,7 +3112,7 @@ class CustomPluginTemplate:
|
|
2924
3112
|
raise NotImplementedError
|
2925
3113
|
|
2926
3114
|
@property
|
2927
|
-
def get_object_max_saves():
|
3115
|
+
def get_object_max_saves(self):
|
2928
3116
|
raise NotImplementedError
|
2929
3117
|
|
2930
3118
|
def get_output_folder(self):
|
@@ -2938,7 +3126,7 @@ class CustomPluginTemplate:
|
|
2938
3126
|
def get_payload_after_exec(self):
|
2939
3127
|
"""
|
2940
3128
|
Gets the payload and resets the internal _payload protected variable
|
2941
|
-
|
3129
|
+
|
2942
3130
|
Returns
|
2943
3131
|
-------
|
2944
3132
|
payload : GenericPayload
|
@@ -2947,7 +3135,7 @@ class CustomPluginTemplate:
|
|
2947
3135
|
raise NotImplementedError
|
2948
3136
|
|
2949
3137
|
@property
|
2950
|
-
def get_plugin_default_dataset_builder_params():
|
3138
|
+
def get_plugin_default_dataset_builder_params(self):
|
2951
3139
|
"""
|
2952
3140
|
Method that will be used for the plugins where the dataset builder mixin will be enabled by default
|
2953
3141
|
in order to facilitate the configuration of this mixin without ignoring the default ds builder params
|
@@ -2984,17 +3172,17 @@ class CustomPluginTemplate:
|
|
2984
3172
|
def get_serving_processes(self):
|
2985
3173
|
"""
|
2986
3174
|
Returns a list of used AI Engines within the current plugin instance based on given configuration
|
2987
|
-
|
3175
|
+
|
2988
3176
|
Parameters
|
2989
3177
|
----------
|
2990
3178
|
None.
|
2991
|
-
|
3179
|
+
|
2992
3180
|
Returns
|
2993
3181
|
-------
|
2994
3182
|
result : list
|
2995
3183
|
The list.
|
2996
|
-
|
2997
|
-
|
3184
|
+
|
3185
|
+
|
2998
3186
|
Example
|
2999
3187
|
-------
|
3000
3188
|
```
|
@@ -3007,7 +3195,7 @@ class CustomPluginTemplate:
|
|
3007
3195
|
raise NotImplementedError
|
3008
3196
|
|
3009
3197
|
@property
|
3010
|
-
def get_stats_update_period():
|
3198
|
+
def get_stats_update_period(self):
|
3011
3199
|
raise NotImplementedError
|
3012
3200
|
|
3013
3201
|
def get_stream_id(self):
|
@@ -3019,7 +3207,7 @@ class CustomPluginTemplate:
|
|
3019
3207
|
Parameters
|
3020
3208
|
----------
|
3021
3209
|
target
|
3022
|
-
|
3210
|
+
|
3023
3211
|
Returns
|
3024
3212
|
-------
|
3025
3213
|
"""
|
@@ -3028,7 +3216,7 @@ class CustomPluginTemplate:
|
|
3028
3216
|
def get_temperature_sensors(self, as_dict):
|
3029
3217
|
"""
|
3030
3218
|
Returns the temperature of the machine if available
|
3031
|
-
|
3219
|
+
|
3032
3220
|
Returns
|
3033
3221
|
-------
|
3034
3222
|
dict
|
@@ -3042,7 +3230,20 @@ class CustomPluginTemplate:
|
|
3042
3230
|
raise NotImplementedError
|
3043
3231
|
|
3044
3232
|
@property
|
3045
|
-
def get_total_max_saves():
|
3233
|
+
def get_total_max_saves(self):
|
3234
|
+
raise NotImplementedError
|
3235
|
+
|
3236
|
+
def get_tracking_type(self, inf):
|
3237
|
+
"""
|
3238
|
+
Public method for accessing the tracking type of inference
|
3239
|
+
Parameters
|
3240
|
+
----------
|
3241
|
+
inf - dict, inference dictionary
|
3242
|
+
|
3243
|
+
Returns
|
3244
|
+
-------
|
3245
|
+
res - str, tracking type of the inference
|
3246
|
+
"""
|
3046
3247
|
raise NotImplementedError
|
3047
3248
|
|
3048
3249
|
def get_upstream_config(self):
|
@@ -3051,31 +3252,32 @@ class CustomPluginTemplate:
|
|
3051
3252
|
def get_warnings(self):
|
3052
3253
|
raise NotImplementedError
|
3053
3254
|
|
3054
|
-
def get_witness_image(self, img, prepare_witness_kwargs, pre_process_witness_kwargs, draw_witness_image_kwargs,
|
3255
|
+
def get_witness_image(self, img, prepare_witness_kwargs, pre_process_witness_kwargs, draw_witness_image_kwargs,
|
3256
|
+
post_process_witness_kwargs):
|
3055
3257
|
"""
|
3056
3258
|
This is the wrapper function that should be called from any plug-in.
|
3057
3259
|
It contains the channel reversing and the cv2 required numpy magic and it
|
3058
3260
|
will call the `_draw_witness_image` plug-in specific method
|
3059
|
-
|
3261
|
+
|
3060
3262
|
definition of: _draw_witness_image(img_witness, **kwargs)
|
3061
|
-
|
3263
|
+
|
3062
3264
|
Parameters
|
3063
3265
|
----------
|
3064
3266
|
img: np.ndarray
|
3065
3267
|
The starting image. Can be None
|
3066
|
-
|
3268
|
+
|
3067
3269
|
prepare_witness_kwargs : dict
|
3068
3270
|
anything we need in _witness_prepare (passed as **prepare_witness_kwargs)
|
3069
|
-
|
3271
|
+
|
3070
3272
|
pre_process_witness_kwargs : dict
|
3071
3273
|
anything we need in _witness_pre_process (passed as **pre_process_witness_kwargs)
|
3072
|
-
|
3274
|
+
|
3073
3275
|
draw_witness_image_kwargs : dict
|
3074
3276
|
anything we need in _draw_witness_image (passed as **draw_witness_image_kwargs)
|
3075
|
-
|
3277
|
+
|
3076
3278
|
post_process_witness_kwargs : dict
|
3077
3279
|
anything we need in _witness_post_process (passed as **post_process_witness_kwargs)
|
3078
|
-
|
3280
|
+
|
3079
3281
|
Returns
|
3080
3282
|
-------
|
3081
3283
|
img_witness : ndarray
|
@@ -3106,18 +3308,85 @@ class CustomPluginTemplate:
|
|
3106
3308
|
raise NotImplementedError
|
3107
3309
|
|
3108
3310
|
@property
|
3109
|
-
def get_zip_period():
|
3311
|
+
def get_zip_period(self):
|
3312
|
+
raise NotImplementedError
|
3313
|
+
|
3314
|
+
def git_clone(self, repo_url, repo_dir, target, user, token, pull_if_exists):
|
3315
|
+
"""
|
3316
|
+
Clones a git repository or pulls if the repository already exists.
|
3317
|
+
|
3318
|
+
Parameters
|
3319
|
+
----------
|
3320
|
+
repo_url : str
|
3321
|
+
The git repository URL
|
3322
|
+
|
3323
|
+
token : str, optional
|
3324
|
+
The token to be used for authentication. The default is None.
|
3325
|
+
|
3326
|
+
user: str, optional
|
3327
|
+
The username to be used for authentication. The default is None.
|
3328
|
+
|
3329
|
+
token : str, optional
|
3330
|
+
The token to be used for authentication. The default is None.
|
3331
|
+
|
3332
|
+
pull_if_exists : bool, optional
|
3333
|
+
If True, the repository will be pulled if it already exists. The default is True.
|
3334
|
+
|
3335
|
+
|
3336
|
+
Returns
|
3337
|
+
-------
|
3338
|
+
str
|
3339
|
+
The local folder where the repository was cloned.
|
3340
|
+
"""
|
3341
|
+
raise NotImplementedError
|
3342
|
+
|
3343
|
+
def git_get_last_commit_hash(self, repo_url, user, token):
|
3344
|
+
"""
|
3345
|
+
Retrieves the latest commit hash from the remote git repository.
|
3346
|
+
|
3347
|
+
Parameters
|
3348
|
+
----------
|
3349
|
+
repo_url : str
|
3350
|
+
The git repository URL
|
3351
|
+
|
3352
|
+
user : str, optional
|
3353
|
+
The username to be used for authentication. The default is None.
|
3354
|
+
|
3355
|
+
token : str, optional
|
3356
|
+
The token to be used for authentication. The default is None.
|
3357
|
+
|
3358
|
+
Returns
|
3359
|
+
-------
|
3360
|
+
str
|
3361
|
+
The latest commit hash from the remote repository.
|
3362
|
+
"""
|
3363
|
+
raise NotImplementedError
|
3364
|
+
|
3365
|
+
def git_get_local_commit_hash(self, repo_dir):
|
3366
|
+
"""
|
3367
|
+
Retrieves the latest commit hash from the local git repository.
|
3368
|
+
|
3369
|
+
Parameters
|
3370
|
+
----------
|
3371
|
+
repo_dir : str
|
3372
|
+
The local directory where the repository is cloned.
|
3373
|
+
|
3374
|
+
Returns
|
3375
|
+
-------
|
3376
|
+
str
|
3377
|
+
The latest commit hash from the local repository.
|
3378
|
+
"""
|
3110
3379
|
raise NotImplementedError
|
3111
3380
|
|
3112
3381
|
@property
|
3113
|
-
def global_shmem():
|
3382
|
+
def global_shmem(self):
|
3114
3383
|
raise NotImplementedError
|
3115
3384
|
|
3116
3385
|
@property
|
3117
|
-
def gmt():
|
3386
|
+
def gmt(self):
|
3118
3387
|
"""
|
3119
3388
|
Proxy for geometry_methods from decentra_vision.geometry_methods
|
3120
|
-
|
3389
|
+
|
3121
3390
|
"""
|
3122
3391
|
raise NotImplementedError
|
3123
3392
|
|
@@ -3127,75 +3396,97 @@ class CustomPluginTemplate:
|
|
3127
3396
|
"""
|
3128
3397
|
raise NotImplementedError
|
3129
3398
|
|
3399
|
+
def image_entropy(self, image):
|
3400
|
+
"""
|
3401
|
+
Computes the entropy of an image.
|
3402
|
+
|
3403
|
+
Parameters
|
3404
|
+
----------
|
3405
|
+
image : cv2 image | PIL image | np.ndarray
|
3406
|
+
the input image.
|
3407
|
+
|
3408
|
+
Returns
|
3409
|
+
-------
|
3410
|
+
entropy: float
|
3411
|
+
the entropy of the image
|
3412
|
+
"""
|
3413
|
+
raise NotImplementedError
|
3414
|
+
|
3130
3415
|
def img_to_base64(self, img):
|
3131
3416
|
"""
|
3132
3417
|
Transforms a numpy image into a base64 encoded image
|
3133
|
-
|
3418
|
+
|
3134
3419
|
Parameters
|
3135
3420
|
----------
|
3136
3421
|
img : np.ndarray
|
3137
3422
|
the input image
|
3138
|
-
|
3423
|
+
|
3139
3424
|
Returns
|
3140
3425
|
-------
|
3141
3426
|
str: base64 encoded image
|
3142
3427
|
"""
|
3143
3428
|
raise NotImplementedError
|
3144
3429
|
|
3430
|
+
def indent_strings(self, strings, indent):
|
3431
|
+
"""
|
3432
|
+
Indents a string or a list of strings by a given number of spaces.
|
3433
|
+
"""
|
3434
|
+
raise NotImplementedError
|
3435
|
+
|
3145
3436
|
def init_plugins_shared_memory(self, dct_global):
|
3146
3437
|
raise NotImplementedError
|
3147
3438
|
|
3148
3439
|
@property
|
3149
|
-
def initiator_addr():
|
3440
|
+
def initiator_addr(self):
|
3150
3441
|
raise NotImplementedError
|
3151
3442
|
|
3152
3443
|
@property
|
3153
|
-
def initiator_id():
|
3444
|
+
def initiator_id(self):
|
3154
3445
|
raise NotImplementedError
|
3155
3446
|
|
3156
3447
|
@property
|
3157
|
-
def input_queue_size():
|
3448
|
+
def input_queue_size(self):
|
3158
3449
|
"""
|
3159
3450
|
Returns the size of the input queue that is consumed iterativelly
|
3160
3451
|
"""
|
3161
3452
|
raise NotImplementedError
|
3162
3453
|
|
3163
3454
|
@property
|
3164
|
-
def inputs():
|
3455
|
+
def inputs(self):
|
3165
3456
|
raise NotImplementedError
|
3166
3457
|
|
3167
3458
|
@property
|
3168
|
-
def inspect():
|
3459
|
+
def inspect(self):
|
3169
3460
|
"""
|
3170
3461
|
Provides access to `inspect` package
|
3171
|
-
|
3462
|
+
|
3172
3463
|
Returns
|
3173
3464
|
-------
|
3174
|
-
`inspect` package
|
3465
|
+
`inspect` package
|
3175
3466
|
"""
|
3176
3467
|
raise NotImplementedError
|
3177
3468
|
|
3178
3469
|
@property
|
3179
|
-
def instance_hash():
|
3470
|
+
def instance_hash(self):
|
3180
3471
|
raise NotImplementedError
|
3181
3472
|
|
3182
3473
|
@property
|
3183
|
-
def instance_relative_path():
|
3474
|
+
def instance_relative_path(self):
|
3184
3475
|
raise NotImplementedError
|
3185
3476
|
|
3186
3477
|
@property
|
3187
|
-
def int_cache():
|
3478
|
+
def int_cache(self):
|
3188
3479
|
"""
|
3189
3480
|
can be used as a statefull store of the instance - eg `plugin.int_cache[key]` will return 0
|
3190
|
-
if that key has never been initialized
|
3191
|
-
|
3192
|
-
|
3481
|
+
if that key has never been initialized
|
3482
|
+
|
3483
|
+
|
3193
3484
|
Returns
|
3194
3485
|
-------
|
3195
3486
|
dict of ints
|
3196
3487
|
Returns a default dict for int values initialized with zeros.
|
3197
|
-
|
3198
|
-
|
3488
|
+
|
3489
|
+
|
3199
3490
|
Example
|
3200
3491
|
-------
|
3201
3492
|
```
|
@@ -3216,7 +3507,7 @@ class CustomPluginTemplate:
|
|
3216
3507
|
interval : list - list of 2 strings representing the start and end of the interval in format HH:MM
|
3217
3508
|
weekday : int or None - the weekday index starting from 0
|
3218
3509
|
timezone : str or None - the timezone to convert to
|
3219
|
-
|
3510
|
+
|
3220
3511
|
Returns
|
3221
3512
|
-------
|
3222
3513
|
res - list of 1 or 2 tuples representing the weekday, start and end of the interval in local time.
|
@@ -3224,23 +3515,23 @@ class CustomPluginTemplate:
|
|
3224
3515
|
raise NotImplementedError
|
3225
3516
|
|
3226
3517
|
@property
|
3227
|
-
def is_data_limited_and_has_frame():
|
3518
|
+
def is_data_limited_and_has_frame(self):
|
3228
3519
|
raise NotImplementedError
|
3229
3520
|
|
3230
3521
|
@property
|
3231
|
-
def is_debug_mode():
|
3522
|
+
def is_debug_mode(self):
|
3232
3523
|
raise NotImplementedError
|
3233
3524
|
|
3234
3525
|
@property
|
3235
|
-
def is_demo_mode():
|
3526
|
+
def is_demo_mode(self):
|
3236
3527
|
raise NotImplementedError
|
3237
3528
|
|
3238
3529
|
@property
|
3239
|
-
def is_last_data():
|
3530
|
+
def is_last_data(self):
|
3240
3531
|
raise NotImplementedError
|
3241
3532
|
|
3242
3533
|
@property
|
3243
|
-
def is_limited_data_finished():
|
3534
|
+
def is_limited_data_finished(self):
|
3244
3535
|
raise NotImplementedError
|
3245
3536
|
|
3246
3537
|
def is_path_safe(self, path):
|
@@ -3249,7 +3540,7 @@ class CustomPluginTemplate:
|
|
3249
3540
|
Parameters
|
3250
3541
|
----------
|
3251
3542
|
path - string, path to be checked
|
3252
|
-
|
3543
|
+
|
3253
3544
|
Returns
|
3254
3545
|
-------
|
3255
3546
|
bool, True if the path is safe, False otherwise
|
@@ -3257,23 +3548,28 @@ class CustomPluginTemplate:
|
|
3257
3548
|
raise NotImplementedError
|
3258
3549
|
|
3259
3550
|
@property
|
3260
|
-
def is_plugin_stopped():
|
3551
|
+
def is_plugin_stopped(self):
|
3261
3552
|
raise NotImplementedError
|
3262
3553
|
|
3263
3554
|
@property
|
3264
|
-
def is_plugin_temporary_stopped():
|
3555
|
+
def is_plugin_temporary_stopped(self):
|
3265
3556
|
raise NotImplementedError
|
3266
3557
|
|
3267
3558
|
@property
|
3268
|
-
def is_process_postponed():
|
3559
|
+
def is_process_postponed(self):
|
3269
3560
|
raise NotImplementedError
|
3270
3561
|
|
3271
3562
|
@property
|
3272
|
-
def is_queue_overflown():
|
3563
|
+
def is_queue_overflown(self):
|
3273
3564
|
raise NotImplementedError
|
3274
3565
|
|
3275
3566
|
@property
|
3276
|
-
def is_supervisor_node():
|
3567
|
+
def is_supervisor_node(self):
|
3568
|
+
"""
|
3569
|
+
Returns `True` if the plugin is running on the supervisor node and `False` otherwise.
|
3570
|
+
Warning: This property is not safe/trusted while the plugin is initializing due to the
|
3571
|
+
fact that the supervisor node may not be set yet within the NET_MON plugin.
|
3572
|
+
"""
|
3277
3573
|
raise NotImplementedError
|
3278
3574
|
|
3279
3575
|
def is_valid_datapoint(self, data):
|
@@ -3284,7 +3580,7 @@ class CustomPluginTemplate:
|
|
3284
3580
|
Parameters
|
3285
3581
|
----------
|
3286
3582
|
data
|
3287
|
-
|
3583
|
+
|
3288
3584
|
Returns
|
3289
3585
|
-------
|
3290
3586
|
True if valid, False otherwise
|
@@ -3292,24 +3588,24 @@ class CustomPluginTemplate:
|
|
3292
3588
|
raise NotImplementedError
|
3293
3589
|
|
3294
3590
|
@property
|
3295
|
-
def iteration():
|
3591
|
+
def iteration(self):
|
3296
3592
|
raise NotImplementedError
|
3297
3593
|
|
3298
3594
|
@property
|
3299
|
-
def json():
|
3595
|
+
def json(self):
|
3300
3596
|
"""
|
3301
3597
|
Provides access to `json` package
|
3302
|
-
|
3598
|
+
|
3303
3599
|
Returns
|
3304
3600
|
-------
|
3305
|
-
`json` package
|
3601
|
+
`json` package
|
3306
3602
|
"""
|
3307
3603
|
raise NotImplementedError
|
3308
3604
|
|
3309
3605
|
def json_dumps(self, dct, replace_nan, kwargs):
|
3310
3606
|
"""
|
3311
3607
|
Alias for `safe_json_dumps` for backward compatibility
|
3312
|
-
|
3608
|
+
|
3313
3609
|
"""
|
3314
3610
|
raise NotImplementedError
|
3315
3611
|
|
@@ -3320,74 +3616,74 @@ class CustomPluginTemplate:
|
|
3320
3616
|
raise NotImplementedError
|
3321
3617
|
|
3322
3618
|
@property
|
3323
|
-
def last_payload_time():
|
3619
|
+
def last_payload_time(self):
|
3324
3620
|
raise NotImplementedError
|
3325
3621
|
|
3326
3622
|
@property
|
3327
|
-
def last_payload_time_str():
|
3623
|
+
def last_payload_time_str(self):
|
3328
3624
|
raise NotImplementedError
|
3329
3625
|
|
3330
3626
|
@property
|
3331
|
-
def last_process_time():
|
3627
|
+
def last_process_time(self):
|
3332
3628
|
raise NotImplementedError
|
3333
3629
|
|
3334
3630
|
@property
|
3335
|
-
def limited_data_counter():
|
3631
|
+
def limited_data_counter(self):
|
3336
3632
|
raise NotImplementedError
|
3337
3633
|
|
3338
3634
|
@property
|
3339
|
-
def limited_data_crt_time():
|
3635
|
+
def limited_data_crt_time(self):
|
3340
3636
|
raise NotImplementedError
|
3341
3637
|
|
3342
3638
|
@property
|
3343
|
-
def limited_data_duration():
|
3639
|
+
def limited_data_duration(self):
|
3344
3640
|
raise NotImplementedError
|
3345
3641
|
|
3346
3642
|
@property
|
3347
|
-
def limited_data_finished_flag():
|
3643
|
+
def limited_data_finished_flag(self):
|
3348
3644
|
raise NotImplementedError
|
3349
3645
|
|
3350
3646
|
@property
|
3351
|
-
def limited_data_fps():
|
3647
|
+
def limited_data_fps(self):
|
3352
3648
|
raise NotImplementedError
|
3353
3649
|
|
3354
3650
|
@property
|
3355
|
-
def limited_data_frame_count():
|
3651
|
+
def limited_data_frame_count(self):
|
3356
3652
|
raise NotImplementedError
|
3357
3653
|
|
3358
3654
|
@property
|
3359
|
-
def limited_data_frame_current():
|
3655
|
+
def limited_data_frame_current(self):
|
3360
3656
|
raise NotImplementedError
|
3361
3657
|
|
3362
3658
|
@property
|
3363
|
-
def limited_data_process_fps():
|
3659
|
+
def limited_data_process_fps(self):
|
3364
3660
|
raise NotImplementedError
|
3365
3661
|
|
3366
3662
|
@property
|
3367
|
-
def limited_data_progress():
|
3663
|
+
def limited_data_progress(self):
|
3368
3664
|
raise NotImplementedError
|
3369
3665
|
|
3370
3666
|
@property
|
3371
|
-
def limited_data_remaining_time():
|
3667
|
+
def limited_data_remaining_time(self):
|
3372
3668
|
raise NotImplementedError
|
3373
3669
|
|
3374
3670
|
@property
|
3375
|
-
def limited_data_seconds_elapsed():
|
3671
|
+
def limited_data_seconds_elapsed(self):
|
3376
3672
|
raise NotImplementedError
|
3377
3673
|
|
3378
3674
|
@property
|
3379
|
-
def limited_data_total_counter():
|
3675
|
+
def limited_data_total_counter(self):
|
3380
3676
|
raise NotImplementedError
|
3381
3677
|
|
3382
3678
|
def load_config_file(self, fn):
|
3383
3679
|
"""
|
3384
3680
|
Loads a json/yaml config file and returns the config dictionary
|
3385
|
-
|
3681
|
+
|
3386
3682
|
Parameters
|
3387
3683
|
----------
|
3388
3684
|
fn : str
|
3389
3685
|
The filename of the config file
|
3390
|
-
|
3686
|
+
|
3391
3687
|
Returns
|
3392
3688
|
-------
|
3393
3689
|
dict
|
@@ -3396,18 +3692,18 @@ class CustomPluginTemplate:
|
|
3396
3692
|
raise NotImplementedError
|
3397
3693
|
|
3398
3694
|
@property
|
3399
|
-
def local_data_cache():
|
3695
|
+
def local_data_cache(self):
|
3400
3696
|
"""
|
3401
3697
|
Can be used as a statefull store of the instance - eg `plugin.state[key]` will return `None`
|
3402
|
-
if that key has never been initialized
|
3403
|
-
|
3404
|
-
|
3698
|
+
if that key has never been initialized
|
3699
|
+
|
3700
|
+
|
3405
3701
|
Returns
|
3406
3702
|
-------
|
3407
3703
|
dict
|
3408
3704
|
a default dict.
|
3409
|
-
|
3410
|
-
|
3705
|
+
|
3706
|
+
|
3411
3707
|
Example
|
3412
3708
|
-------
|
3413
3709
|
```
|
@@ -3422,7 +3718,7 @@ class CustomPluginTemplate:
|
|
3422
3718
|
def lock_resource(self, str_res):
|
3423
3719
|
"""
|
3424
3720
|
Locks a resource given a string. Alias to `self.log.lock_resource`
|
3425
|
-
|
3721
|
+
|
3426
3722
|
Parameters
|
3427
3723
|
----------
|
3428
3724
|
str_res : str
|
@@ -3431,16 +3727,50 @@ class CustomPluginTemplate:
|
|
3431
3727
|
raise NotImplementedError
|
3432
3728
|
|
3433
3729
|
@property
|
3434
|
-
def loop_paused():
|
3730
|
+
def loop_paused(self):
|
3435
3731
|
raise NotImplementedError
|
3436
3732
|
|
3437
3733
|
@property
|
3438
|
-
def loop_timings():
|
3734
|
+
def loop_timings(self):
|
3439
3735
|
raise NotImplementedError
|
3440
3736
|
|
3441
3737
|
def mainthread_wait_for_plugin(self):
|
3442
3738
|
raise NotImplementedError
|
3443
3739
|
|
3740
|
+
def managed_lock_resource(self, str_res, condition):
|
3741
|
+
"""
|
3742
|
+
Managed lock resource. Will lock and unlock resource automatically.
|
3743
|
+
To be used in a with statement.
|
3744
|
+
The condition parameter allows users to disable the lock if desired.
|
3745
|
+
|
3746
|
+
Parameters
|
3747
|
+
----------
|
3748
|
+
str_res : str
|
3749
|
+
The resource to lock.
|
3750
|
+
condition : bool, optional
|
3751
|
+
If False the lock will not be acquired. The default is True.
|
3752
|
+
|
3753
|
+
Returns
|
3754
|
+
-------
|
3755
|
+
LockResource
|
3756
|
+
The lock resource object.
|
3757
|
+
|
3758
|
+
Example
|
3759
|
+
-------
|
3760
|
+
```
|
3761
|
+
with self.managed_lock_resource('my_resource'):
|
3762
|
+
# do something
|
3763
|
+
```
|
3764
|
+
|
3765
|
+
```
|
3766
|
+
# will control if the following operation is locked or not based on this flag
|
3767
|
+
locking = False
|
3768
|
+
with self.managed_lock_resource('my_resource', condition=locking):
|
3769
|
+
# do something
|
3770
|
+
```
|
3771
|
+
"""
|
3772
|
+
raise NotImplementedError
|
3773
|
+
|
3444
3774
|
def maybe_archive_upload_last_files(self):
|
3445
3775
|
"""
|
3446
3776
|
Method used for archiving and uploading the remaining datapoints (if it's the case) when the plugin instance closes.
|
@@ -3452,29 +3782,29 @@ class CustomPluginTemplate:
|
|
3452
3782
|
def maybe_download(self, url, fn, target, kwargs):
|
3453
3783
|
"""
|
3454
3784
|
Enables http/htps/minio download capabilities.
|
3455
|
-
|
3456
|
-
|
3785
|
+
|
3786
|
+
|
3457
3787
|
Parameters
|
3458
3788
|
----------
|
3459
3789
|
url : str or list
|
3460
3790
|
The URI or URIs to be used for downloads
|
3461
|
-
|
3791
|
+
|
3462
3792
|
fn: str of list
|
3463
3793
|
The filename or filenames to be locally used
|
3464
|
-
|
3794
|
+
|
3465
3795
|
target: str
|
3466
3796
|
Can be `output`, `models` or `data`. Default is `output`
|
3467
|
-
|
3797
|
+
|
3468
3798
|
kwargs: dict
|
3469
3799
|
if url starts with 'minio:' the function will retrieve minio conn
|
3470
3800
|
params from **kwargs and use minio_download (if needed or forced)
|
3471
|
-
|
3801
|
+
|
3472
3802
|
Returns
|
3473
3803
|
-------
|
3474
3804
|
files, messages : list, list
|
3475
3805
|
all the local files and result messages from download process
|
3476
|
-
|
3477
|
-
|
3806
|
+
|
3807
|
+
|
3478
3808
|
Example
|
3479
3809
|
-------
|
3480
3810
|
"""
|
@@ -3499,21 +3829,24 @@ class CustomPluginTemplate:
|
|
3499
3829
|
"""
|
3500
3830
|
This method is called by the plugin manager when the instance config has changed.
|
3501
3831
|
IMPORTANT: it runs on the same thread as the BusinessManager so it should not block!
|
3502
|
-
|
3832
|
+
|
3503
3833
|
For the particular case when only INSTANCE_COMMAND is modified then the plugin should not reset its state
|
3504
3834
|
"""
|
3505
3835
|
raise NotImplementedError
|
3506
3836
|
|
3837
|
+
def method_to_base64(self, func, verbose):
|
3838
|
+
raise NotImplementedError
|
3839
|
+
|
3507
3840
|
@property
|
3508
|
-
def modified_by_addr():
|
3841
|
+
def modified_by_addr(self):
|
3509
3842
|
raise NotImplementedError
|
3510
3843
|
|
3511
3844
|
@property
|
3512
|
-
def modified_by_id():
|
3845
|
+
def modified_by_id(self):
|
3513
3846
|
raise NotImplementedError
|
3514
3847
|
|
3515
3848
|
@property
|
3516
|
-
def n_plugin_exceptions():
|
3849
|
+
def n_plugin_exceptions(self):
|
3517
3850
|
raise NotImplementedError
|
3518
3851
|
|
3519
3852
|
def need_refresh(self):
|
@@ -3522,14 +3855,14 @@ class CustomPluginTemplate:
|
|
3522
3855
|
def needs_update(self, dct_newdict, except_keys):
|
3523
3856
|
"""
|
3524
3857
|
Check if we need to perform a config update: if a new dict is different from current config_data
|
3525
|
-
|
3858
|
+
|
3526
3859
|
Parameters
|
3527
3860
|
----------
|
3528
3861
|
dct_newdict : dict
|
3529
3862
|
The new dict to be checked
|
3530
3863
|
except_keys : list
|
3531
3864
|
list of keys to be excluded from check
|
3532
|
-
|
3865
|
+
|
3533
3866
|
Returns
|
3534
3867
|
-------
|
3535
3868
|
bool, list
|
@@ -3538,41 +3871,41 @@ class CustomPluginTemplate:
|
|
3538
3871
|
raise NotImplementedError
|
3539
3872
|
|
3540
3873
|
@property
|
3541
|
-
def net_mon():
|
3874
|
+
def net_mon(self):
|
3542
3875
|
raise NotImplementedError
|
3543
3876
|
|
3544
3877
|
@property
|
3545
|
-
def netmon():
|
3878
|
+
def netmon(self):
|
3546
3879
|
raise NotImplementedError
|
3547
3880
|
|
3548
3881
|
@property
|
3549
|
-
def network_monitor():
|
3882
|
+
def network_monitor(self):
|
3550
3883
|
raise NotImplementedError
|
3551
3884
|
|
3552
3885
|
@property
|
3553
|
-
def node_addr():
|
3886
|
+
def node_addr(self):
|
3554
3887
|
raise NotImplementedError
|
3555
3888
|
|
3556
3889
|
@property
|
3557
|
-
def node_id():
|
3890
|
+
def node_id(self):
|
3558
3891
|
raise NotImplementedError
|
3559
3892
|
|
3560
3893
|
def normalize_text(self, text):
|
3561
3894
|
"""
|
3562
3895
|
Uses unidecode to normalize text. Requires unidecode package
|
3563
|
-
|
3896
|
+
|
3564
3897
|
Parameters
|
3565
3898
|
----------
|
3566
3899
|
text : str
|
3567
3900
|
the proposed text with diacritics and so on.
|
3568
|
-
|
3901
|
+
|
3569
3902
|
Returns
|
3570
3903
|
-------
|
3571
3904
|
text : str
|
3572
3905
|
decoded text if unidecode was avail
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3906
|
+
|
3907
|
+
|
3908
|
+
|
3576
3909
|
Example
|
3577
3910
|
-------
|
3578
3911
|
```
|
@@ -3585,23 +3918,23 @@ class CustomPluginTemplate:
|
|
3585
3918
|
def now_in_schedule(self, schedule, weekdays):
|
3586
3919
|
"""
|
3587
3920
|
Check if the current time is in a active schedule given the schedule data
|
3588
|
-
|
3589
|
-
|
3921
|
+
|
3922
|
+
|
3590
3923
|
Parameters
|
3591
3924
|
----------
|
3592
3925
|
schedule : dict or list
|
3593
3926
|
the schedule.
|
3594
|
-
|
3927
|
+
|
3595
3928
|
weekdays : TYPE, optional
|
3596
3929
|
list of weekdays. The default is None.
|
3597
|
-
|
3598
|
-
|
3930
|
+
|
3931
|
+
|
3599
3932
|
Returns
|
3600
3933
|
-------
|
3601
3934
|
bool
|
3602
3935
|
Returns true if time in schedule.
|
3603
|
-
|
3604
|
-
|
3936
|
+
|
3937
|
+
|
3605
3938
|
Example
|
3606
3939
|
-------
|
3607
3940
|
```
|
@@ -3618,22 +3951,22 @@ class CustomPluginTemplate:
|
|
3618
3951
|
----------
|
3619
3952
|
nice_print
|
3620
3953
|
short
|
3621
|
-
|
3954
|
+
|
3622
3955
|
Returns
|
3623
3956
|
-------
|
3624
3957
|
"""
|
3625
3958
|
raise NotImplementedError
|
3626
3959
|
|
3627
3960
|
@property
|
3628
|
-
def np():
|
3961
|
+
def np(self):
|
3629
3962
|
"""
|
3630
3963
|
Provides access to numerical processing library
|
3631
|
-
|
3632
|
-
|
3964
|
+
|
3965
|
+
|
3633
3966
|
Returns
|
3634
3967
|
-------
|
3635
3968
|
np : Numpy package
|
3636
|
-
|
3969
|
+
|
3637
3970
|
Example:
|
3638
3971
|
```
|
3639
3972
|
np_zeros = self.np.zeros(shape=(10,10))
|
@@ -3642,18 +3975,18 @@ class CustomPluginTemplate:
|
|
3642
3975
|
raise NotImplementedError
|
3643
3976
|
|
3644
3977
|
@property
|
3645
|
-
def obj_cache():
|
3978
|
+
def obj_cache(self):
|
3646
3979
|
"""
|
3647
3980
|
Can be used as a statefull store of the instance - eg `plugin.obj_cache[key]` will return `None`
|
3648
|
-
if that key has never been initialized
|
3649
|
-
|
3650
|
-
|
3981
|
+
if that key has never been initialized
|
3982
|
+
|
3983
|
+
|
3651
3984
|
Returns
|
3652
3985
|
-------
|
3653
3986
|
dict
|
3654
3987
|
a default dict for objects.
|
3655
|
-
|
3656
|
-
|
3988
|
+
|
3989
|
+
|
3657
3990
|
Example
|
3658
3991
|
-------
|
3659
3992
|
```
|
@@ -3661,14 +3994,14 @@ class CustomPluginTemplate:
|
|
3661
3994
|
if obj is None:
|
3662
3995
|
obj = ClassObj1()
|
3663
3996
|
self.obj_cache['Obj1'] = obj
|
3664
|
-
```
|
3997
|
+
```
|
3665
3998
|
"""
|
3666
3999
|
raise NotImplementedError
|
3667
4000
|
|
3668
4001
|
def on_close(self):
|
3669
4002
|
"""
|
3670
4003
|
Called at shutdown time in the plugin thread.
|
3671
|
-
|
4004
|
+
|
3672
4005
|
Returns
|
3673
4006
|
-------
|
3674
4007
|
None.
|
@@ -3678,12 +4011,12 @@ class CustomPluginTemplate:
|
|
3678
4011
|
def on_command(self, data, kwargs):
|
3679
4012
|
"""
|
3680
4013
|
Called when the instance receives new INSTANCE_COMMAND
|
3681
|
-
|
4014
|
+
|
3682
4015
|
Parameters
|
3683
4016
|
----------
|
3684
4017
|
data : any
|
3685
4018
|
object, string, etc.
|
3686
|
-
|
4019
|
+
|
3687
4020
|
Returns
|
3688
4021
|
-------
|
3689
4022
|
None.
|
@@ -3693,7 +4026,7 @@ class CustomPluginTemplate:
|
|
3693
4026
|
def on_init(self):
|
3694
4027
|
"""
|
3695
4028
|
Called at init time in the plugin thread.
|
3696
|
-
|
4029
|
+
|
3697
4030
|
Returns
|
3698
4031
|
-------
|
3699
4032
|
None.
|
@@ -3701,13 +4034,13 @@ class CustomPluginTemplate:
|
|
3701
4034
|
raise NotImplementedError
|
3702
4035
|
|
3703
4036
|
@property
|
3704
|
-
def os_environ():
|
4037
|
+
def os_environ(self):
|
3705
4038
|
"""
|
3706
4039
|
Returns a copy of the current environment variables based on `os.environ`.
|
3707
|
-
Important: Changing a value in the returned dictionary does NOT change
|
4040
|
+
Important: Changing a value in the returned dictionary does NOT change
|
3708
4041
|
the value of the actual environment variable.
|
3709
|
-
|
3710
|
-
|
4042
|
+
|
4043
|
+
|
3711
4044
|
Returns
|
3712
4045
|
-------
|
3713
4046
|
_type_
|
@@ -3716,16 +4049,16 @@ class CustomPluginTemplate:
|
|
3716
4049
|
raise NotImplementedError
|
3717
4050
|
|
3718
4051
|
@property
|
3719
|
-
def os_path():
|
4052
|
+
def os_path(self):
|
3720
4053
|
"""
|
3721
4054
|
Proxy for `os.path` package
|
3722
|
-
|
3723
|
-
|
4055
|
+
|
4056
|
+
|
3724
4057
|
Returns
|
3725
4058
|
-------
|
3726
4059
|
package
|
3727
|
-
|
3728
|
-
|
4060
|
+
|
4061
|
+
|
3729
4062
|
Example
|
3730
4063
|
-------
|
3731
4064
|
```
|
@@ -3736,7 +4069,7 @@ class CustomPluginTemplate:
|
|
3736
4069
|
raise NotImplementedError
|
3737
4070
|
|
3738
4071
|
@property
|
3739
|
-
def outside_working_hours():
|
4072
|
+
def outside_working_hours(self):
|
3740
4073
|
raise NotImplementedError
|
3741
4074
|
|
3742
4075
|
def parse_generic_path(self, data):
|
@@ -3745,22 +4078,22 @@ class CustomPluginTemplate:
|
|
3745
4078
|
Parameters
|
3746
4079
|
----------
|
3747
4080
|
data - dictionary of data from both model serving and payload
|
3748
|
-
|
4081
|
+
|
3749
4082
|
Returns
|
3750
4083
|
-------
|
3751
4084
|
"""
|
3752
4085
|
raise NotImplementedError
|
3753
4086
|
|
3754
4087
|
@property
|
3755
|
-
def partial():
|
4088
|
+
def partial(self):
|
3756
4089
|
"""
|
3757
4090
|
Provides access to `functools.partial` method
|
3758
|
-
|
4091
|
+
|
3759
4092
|
Returns
|
3760
4093
|
-------
|
3761
4094
|
method
|
3762
|
-
|
3763
|
-
|
4095
|
+
|
4096
|
+
|
3764
4097
|
Example
|
3765
4098
|
-------
|
3766
4099
|
```
|
@@ -3785,21 +4118,21 @@ class CustomPluginTemplate:
|
|
3785
4118
|
"""
|
3786
4119
|
This method allows the addition of data directly in the next outgoing payload
|
3787
4120
|
from the current biz plugin instance
|
3788
|
-
|
4121
|
+
|
3789
4122
|
Parameters
|
3790
4123
|
----------
|
3791
4124
|
key : str
|
3792
4125
|
the name of the key
|
3793
4126
|
val : any
|
3794
4127
|
A value that will be json-ified.
|
3795
|
-
|
4128
|
+
|
3796
4129
|
Returns
|
3797
4130
|
-------
|
3798
4131
|
None.
|
3799
|
-
|
3800
|
-
|
4132
|
+
|
4133
|
+
|
3801
4134
|
Example:
|
3802
|
-
-------
|
4135
|
+
-------
|
3803
4136
|
```
|
3804
4137
|
bool_is_alert = ...
|
3805
4138
|
plugin.payload_set_value("is_special_alert", bool_is_alert)
|
@@ -3808,19 +4141,19 @@ class CustomPluginTemplate:
|
|
3808
4141
|
raise NotImplementedError
|
3809
4142
|
|
3810
4143
|
@property
|
3811
|
-
def pd():
|
4144
|
+
def pd(self):
|
3812
4145
|
"""
|
3813
4146
|
Provides access to pandas library
|
3814
|
-
|
4147
|
+
|
3815
4148
|
Returns
|
3816
4149
|
-------
|
3817
4150
|
package
|
3818
|
-
|
3819
|
-
|
4151
|
+
|
4152
|
+
|
3820
4153
|
Example
|
3821
4154
|
-------
|
3822
4155
|
```
|
3823
|
-
df = self.pd.DataFrame({'a' : [1,2,3], 'b':[0,0,1]})
|
4156
|
+
df = self.pd.DataFrame({'a' : [1,2,3], 'b':[0,0,1]})
|
3824
4157
|
```
|
3825
4158
|
"""
|
3826
4159
|
raise NotImplementedError
|
@@ -3847,8 +4180,8 @@ class CustomPluginTemplate:
|
|
3847
4180
|
"""
|
3848
4181
|
Generates a `default_image` that will be embedded in the plugin response containing
|
3849
4182
|
a time-series plot
|
3850
|
-
|
3851
|
-
|
4183
|
+
|
4184
|
+
|
3852
4185
|
Parameters
|
3853
4186
|
----------
|
3854
4187
|
vals : list[float]
|
@@ -3857,13 +4190,13 @@ class CustomPluginTemplate:
|
|
3857
4190
|
prediction data. The default is None.
|
3858
4191
|
title : str, optional
|
3859
4192
|
a title for our plot. The default is ''.
|
3860
|
-
|
4193
|
+
|
3861
4194
|
Returns
|
3862
4195
|
-------
|
3863
4196
|
msg : str
|
3864
4197
|
a error or success `'Plot ok'` message.
|
3865
|
-
|
3866
|
-
|
4198
|
+
|
4199
|
+
|
3867
4200
|
Example
|
3868
4201
|
-------
|
3869
4202
|
```
|
@@ -3877,43 +4210,43 @@ class CustomPluginTemplate:
|
|
3877
4210
|
raise NotImplementedError
|
3878
4211
|
|
3879
4212
|
@property
|
3880
|
-
def plugin_id():
|
4213
|
+
def plugin_id(self):
|
3881
4214
|
"""
|
3882
4215
|
Returns the instance id of the current plugin.
|
3883
4216
|
WARNING: This should be overwridden in the plugin class to return the correct id.
|
3884
|
-
|
4217
|
+
|
3885
4218
|
Returns
|
3886
4219
|
-------
|
3887
4220
|
str
|
3888
4221
|
the instance id.
|
3889
|
-
|
4222
|
+
|
3890
4223
|
Example
|
3891
4224
|
-------
|
3892
|
-
```
|
4225
|
+
```
|
3893
4226
|
instance_id = self.instance_id
|
3894
|
-
```
|
4227
|
+
```
|
3895
4228
|
"""
|
3896
4229
|
raise NotImplementedError
|
3897
4230
|
|
3898
4231
|
def plugin_loop(self):
|
3899
4232
|
"""
|
3900
4233
|
This is BusinessPlugin main execution loop (plugin loop)
|
3901
|
-
|
4234
|
+
|
3902
4235
|
- plugin.outside_working_hours and plugin.is_process_postponed need to be handled also
|
3903
4236
|
- main thread execution actually is wrapped in the "execute"
|
3904
|
-
|
4237
|
+
|
3905
4238
|
stop precedence:
|
3906
4239
|
PROCESS_DELAY > FORCE_PAUSE > WORKING_HOURS
|
3907
|
-
|
4240
|
+
|
3908
4241
|
"""
|
3909
4242
|
raise NotImplementedError
|
3910
4243
|
|
3911
4244
|
@property
|
3912
|
-
def plugin_output_path():
|
4245
|
+
def plugin_output_path(self):
|
3913
4246
|
raise NotImplementedError
|
3914
4247
|
|
3915
4248
|
@property
|
3916
|
-
def plugins_shmem():
|
4249
|
+
def plugins_shmem(self):
|
3917
4250
|
raise NotImplementedError
|
3918
4251
|
|
3919
4252
|
def poseapi_extract_coords_and_scores(self, tlbr, kpt_with_conf, to_flip, inverse_keypoint_coords):
|
@@ -3928,7 +4261,7 @@ class CustomPluginTemplate:
|
|
3928
4261
|
inverse_keypoint_coords : bool,
|
3929
4262
|
if True the first value of the coordinates will be scaled by the width and the second by the height
|
3930
4263
|
if False the first value of the coordinates will be scaled by the height and the second by the width
|
3931
|
-
|
4264
|
+
|
3932
4265
|
Returns
|
3933
4266
|
-------
|
3934
4267
|
keypoint_coords : np.ndarray (N, 2) coordinates of the keypoints
|
@@ -3960,7 +4293,7 @@ class CustomPluginTemplate:
|
|
3960
4293
|
Parameters
|
3961
4294
|
----------
|
3962
4295
|
idx : int, index of the keypoint
|
3963
|
-
|
4296
|
+
|
3964
4297
|
Returns
|
3965
4298
|
-------
|
3966
4299
|
tuple : color of the keypoint
|
@@ -3973,7 +4306,7 @@ class CustomPluginTemplate:
|
|
3973
4306
|
Parameters
|
3974
4307
|
----------
|
3975
4308
|
idx : int, index of the keypoint
|
3976
|
-
|
4309
|
+
|
3977
4310
|
Returns
|
3978
4311
|
-------
|
3979
4312
|
tuple : color of the keypoint
|
@@ -4010,7 +4343,7 @@ class CustomPluginTemplate:
|
|
4010
4343
|
Parameters
|
4011
4344
|
----------
|
4012
4345
|
idx : int, index of the keypoint
|
4013
|
-
|
4346
|
+
|
4014
4347
|
Returns
|
4015
4348
|
-------
|
4016
4349
|
bool : whether the keypoint is an arm keypoint
|
@@ -4023,7 +4356,7 @@ class CustomPluginTemplate:
|
|
4023
4356
|
Parameters
|
4024
4357
|
----------
|
4025
4358
|
idx : int, index of the keypoint
|
4026
|
-
|
4359
|
+
|
4027
4360
|
Returns
|
4028
4361
|
-------
|
4029
4362
|
bool : whether the keypoint is an extremity keypoint
|
@@ -4036,7 +4369,7 @@ class CustomPluginTemplate:
|
|
4036
4369
|
Parameters
|
4037
4370
|
----------
|
4038
4371
|
idx : int, index of the keypoint
|
4039
|
-
|
4372
|
+
|
4040
4373
|
Returns
|
4041
4374
|
-------
|
4042
4375
|
bool : whether the keypoint is a face keypoint
|
@@ -4049,7 +4382,7 @@ class CustomPluginTemplate:
|
|
4049
4382
|
Parameters
|
4050
4383
|
----------
|
4051
4384
|
idx : int, index of the keypoint
|
4052
|
-
|
4385
|
+
|
4053
4386
|
Returns
|
4054
4387
|
-------
|
4055
4388
|
bool : whether the keypoint is an insertion keypoint
|
@@ -4062,7 +4395,7 @@ class CustomPluginTemplate:
|
|
4062
4395
|
Parameters
|
4063
4396
|
----------
|
4064
4397
|
idx : int, index of the keypoint
|
4065
|
-
|
4398
|
+
|
4066
4399
|
Returns
|
4067
4400
|
-------
|
4068
4401
|
bool : whether the keypoint is left sided
|
@@ -4075,7 +4408,7 @@ class CustomPluginTemplate:
|
|
4075
4408
|
Parameters
|
4076
4409
|
----------
|
4077
4410
|
idx : int, index of the keypoint
|
4078
|
-
|
4411
|
+
|
4079
4412
|
Returns
|
4080
4413
|
-------
|
4081
4414
|
bool : whether the keypoint is a leg keypoint
|
@@ -4088,7 +4421,7 @@ class CustomPluginTemplate:
|
|
4088
4421
|
Parameters
|
4089
4422
|
----------
|
4090
4423
|
idx : int, index of the keypoint
|
4091
|
-
|
4424
|
+
|
4092
4425
|
Returns
|
4093
4426
|
-------
|
4094
4427
|
bool : whether the keypoint is a lower body keypoint
|
@@ -4101,7 +4434,7 @@ class CustomPluginTemplate:
|
|
4101
4434
|
Parameters
|
4102
4435
|
----------
|
4103
4436
|
idx : int, index of the keypoint
|
4104
|
-
|
4437
|
+
|
4105
4438
|
Returns
|
4106
4439
|
-------
|
4107
4440
|
bool : whether the keypoint is right sided
|
@@ -4114,7 +4447,7 @@ class CustomPluginTemplate:
|
|
4114
4447
|
Parameters
|
4115
4448
|
----------
|
4116
4449
|
idx : int, index of the keypoint
|
4117
|
-
|
4450
|
+
|
4118
4451
|
Returns
|
4119
4452
|
-------
|
4120
4453
|
bool : whether the keypoint is an upper body keypoint
|
@@ -4151,7 +4484,7 @@ class CustomPluginTemplate:
|
|
4151
4484
|
def process(self):
|
4152
4485
|
"""
|
4153
4486
|
The main code of the plugin (loop iteration code). Called at each iteration of the plugin loop.
|
4154
|
-
|
4487
|
+
|
4155
4488
|
Returns
|
4156
4489
|
-------
|
4157
4490
|
Payload.
|
@@ -4162,15 +4495,15 @@ class CustomPluginTemplate:
|
|
4162
4495
|
raise NotImplementedError
|
4163
4496
|
|
4164
4497
|
@property
|
4165
|
-
def pyplot():
|
4498
|
+
def pyplot(self):
|
4166
4499
|
"""
|
4167
4500
|
Returns the matplotlib.pyplot package
|
4168
|
-
|
4501
|
+
|
4169
4502
|
Returns
|
4170
4503
|
-------
|
4171
4504
|
plt : package
|
4172
4505
|
the matplotlib.pyplot package.
|
4173
|
-
|
4506
|
+
|
4174
4507
|
Example
|
4175
4508
|
-------
|
4176
4509
|
```
|
@@ -4183,17 +4516,17 @@ class CustomPluginTemplate:
|
|
4183
4516
|
def pyplot_to_np(self, plt):
|
4184
4517
|
"""
|
4185
4518
|
Converts a pyplot image to numpy array
|
4186
|
-
|
4519
|
+
|
4187
4520
|
Parameters
|
4188
4521
|
----------
|
4189
4522
|
plt : pyplot
|
4190
4523
|
the pyplot image.
|
4191
|
-
|
4524
|
+
|
4192
4525
|
Returns
|
4193
4526
|
-------
|
4194
4527
|
np.ndarray
|
4195
4528
|
the numpy array image.
|
4196
|
-
|
4529
|
+
|
4197
4530
|
Example
|
4198
4531
|
-------
|
4199
4532
|
```
|
@@ -4220,10 +4553,10 @@ class CustomPluginTemplate:
|
|
4220
4553
|
raise NotImplementedError
|
4221
4554
|
|
4222
4555
|
@property
|
4223
|
-
def re():
|
4556
|
+
def re(self):
|
4224
4557
|
"""
|
4225
4558
|
Provides access to `re` package
|
4226
|
-
|
4559
|
+
|
4227
4560
|
Returns
|
4228
4561
|
-------
|
4229
4562
|
`re` package
|
@@ -4231,17 +4564,17 @@ class CustomPluginTemplate:
|
|
4231
4564
|
raise NotImplementedError
|
4232
4565
|
|
4233
4566
|
@property
|
4234
|
-
def ready_cfg_handlers():
|
4567
|
+
def ready_cfg_handlers(self):
|
4235
4568
|
raise NotImplementedError
|
4236
4569
|
|
4237
4570
|
@property
|
4238
|
-
def requests():
|
4571
|
+
def requests(self):
|
4239
4572
|
"""
|
4240
4573
|
Provides access to `requests` package
|
4241
|
-
|
4574
|
+
|
4242
4575
|
Returns
|
4243
4576
|
-------
|
4244
|
-
`requests` package
|
4577
|
+
`requests` package
|
4245
4578
|
"""
|
4246
4579
|
raise NotImplementedError
|
4247
4580
|
|
@@ -4270,21 +4603,21 @@ class CustomPluginTemplate:
|
|
4270
4603
|
raise NotImplementedError
|
4271
4604
|
|
4272
4605
|
@property
|
4273
|
-
def runs_in_docker():
|
4606
|
+
def runs_in_docker(self):
|
4274
4607
|
raise NotImplementedError
|
4275
4608
|
|
4276
4609
|
def safe_json_dumps(self, dct, replace_nan, kwargs):
|
4277
4610
|
"""
|
4278
4611
|
Safe json dumps that can handle numpy arrays and so on
|
4279
|
-
|
4612
|
+
|
4280
4613
|
Parameters
|
4281
4614
|
----------
|
4282
4615
|
dct : dict
|
4283
4616
|
The dict to be dumped
|
4284
|
-
|
4617
|
+
|
4285
4618
|
replace_nan : bool, optional
|
4286
4619
|
Replaces nan values with None. The default is False.
|
4287
|
-
|
4620
|
+
|
4288
4621
|
Returns
|
4289
4622
|
-------
|
4290
4623
|
str
|
@@ -4295,12 +4628,12 @@ class CustomPluginTemplate:
|
|
4295
4628
|
def sanitize_name(self, name):
|
4296
4629
|
"""
|
4297
4630
|
Returns a sanitized name that can be used as a variable name
|
4298
|
-
|
4631
|
+
|
4299
4632
|
Parameters
|
4300
4633
|
----------
|
4301
4634
|
name : str
|
4302
4635
|
the proposed name
|
4303
|
-
|
4636
|
+
|
4304
4637
|
Returns
|
4305
4638
|
-------
|
4306
4639
|
str
|
@@ -4312,12 +4645,12 @@ class CustomPluginTemplate:
|
|
4312
4645
|
"""
|
4313
4646
|
Method that allows saving the local config in local cache in order to update a
|
4314
4647
|
specific set of given keys that might have been modified during runtime
|
4315
|
-
|
4648
|
+
|
4316
4649
|
Parameters
|
4317
4650
|
----------
|
4318
4651
|
keys : list
|
4319
4652
|
List of keys to be saved.
|
4320
|
-
|
4653
|
+
|
4321
4654
|
Returns
|
4322
4655
|
-------
|
4323
4656
|
None.
|
@@ -4325,7 +4658,7 @@ class CustomPluginTemplate:
|
|
4325
4658
|
raise NotImplementedError
|
4326
4659
|
|
4327
4660
|
@property
|
4328
|
-
def save_path():
|
4661
|
+
def save_path(self):
|
4329
4662
|
raise NotImplementedError
|
4330
4663
|
|
4331
4664
|
def search_id(self, id, alerter):
|
@@ -4334,13 +4667,13 @@ class CustomPluginTemplate:
|
|
4334
4667
|
def set_default_image(self, img):
|
4335
4668
|
"""
|
4336
4669
|
Sets given image as witness for current payload
|
4337
|
-
|
4670
|
+
|
4338
4671
|
Parameters
|
4339
4672
|
----------
|
4340
4673
|
img : np.ndarray
|
4341
4674
|
the RGB image.
|
4342
|
-
|
4343
|
-
|
4675
|
+
|
4676
|
+
|
4344
4677
|
Example
|
4345
4678
|
-------
|
4346
4679
|
```
|
@@ -4359,18 +4692,18 @@ class CustomPluginTemplate:
|
|
4359
4692
|
def set_text_witness(self, text):
|
4360
4693
|
"""
|
4361
4694
|
Creates a simple empty witness with given centered text.
|
4362
|
-
|
4695
|
+
|
4363
4696
|
Parameters
|
4364
4697
|
----------
|
4365
4698
|
text : str
|
4366
|
-
The text that will be in the output. If the text is bigger than the screen
|
4699
|
+
The text that will be in the output. If the text is bigger than the screen
|
4367
4700
|
it will be displayed on multiple lines
|
4368
|
-
|
4701
|
+
|
4369
4702
|
Returns
|
4370
4703
|
-------
|
4371
4704
|
None.
|
4372
|
-
|
4373
|
-
|
4705
|
+
|
4706
|
+
|
4374
4707
|
Example
|
4375
4708
|
-------
|
4376
4709
|
```
|
@@ -4382,13 +4715,13 @@ class CustomPluginTemplate:
|
|
4382
4715
|
def set_witness_image(self, img):
|
4383
4716
|
"""
|
4384
4717
|
Sets given image as witness for current payload
|
4385
|
-
|
4718
|
+
|
4386
4719
|
Parameters
|
4387
4720
|
----------
|
4388
4721
|
img : np.ndarray
|
4389
4722
|
the RGB image.
|
4390
|
-
|
4391
|
-
|
4723
|
+
|
4724
|
+
|
4392
4725
|
Example
|
4393
4726
|
-------
|
4394
4727
|
```
|
@@ -4402,11 +4735,11 @@ class CustomPluginTemplate:
|
|
4402
4735
|
raise NotImplementedError
|
4403
4736
|
|
4404
4737
|
@property
|
4405
|
-
def shapely_geometry():
|
4738
|
+
def shapely_geometry(self):
|
4406
4739
|
"""
|
4407
4740
|
Provides access to geometry library from shapely package
|
4408
|
-
|
4409
|
-
|
4741
|
+
|
4742
|
+
|
4410
4743
|
Returns
|
4411
4744
|
-------
|
4412
4745
|
geometry : TYPE
|
@@ -4414,16 +4747,30 @@ class CustomPluginTemplate:
|
|
4414
4747
|
"""
|
4415
4748
|
raise NotImplementedError
|
4416
4749
|
|
4750
|
+
def shorten_str(self, s, max_len):
|
4751
|
+
"""
|
4752
|
+
Shortens a string to a given max length.
|
4753
|
+
Parameters
|
4754
|
+
----------
|
4755
|
+
s : str | list | dict
|
4756
|
+
max_len : int, optional
|
4757
|
+
|
4758
|
+
Returns
|
4759
|
+
-------
|
4760
|
+
str | list | dict : the shortened string
|
4761
|
+
"""
|
4762
|
+
raise NotImplementedError
|
4763
|
+
|
4417
4764
|
def should_progress(self, progress, step):
|
4418
4765
|
"""
|
4419
4766
|
Helper function for progress intervals from 5 to 5%. Returns true if param progress hits the value
|
4420
4767
|
else false. Once a `True` is returned it will never again be returned
|
4421
|
-
|
4768
|
+
|
4422
4769
|
Parameters
|
4423
4770
|
----------
|
4424
4771
|
progress : float
|
4425
4772
|
percentage 0-100.
|
4426
|
-
|
4773
|
+
|
4427
4774
|
Returns
|
4428
4775
|
-------
|
4429
4776
|
result : bool
|
@@ -4441,15 +4788,15 @@ class CustomPluginTemplate:
|
|
4441
4788
|
raise NotImplementedError
|
4442
4789
|
|
4443
4790
|
@property
|
4444
|
-
def sns():
|
4791
|
+
def sns(self):
|
4445
4792
|
"""
|
4446
4793
|
Provides access to the seaborn library
|
4447
|
-
|
4794
|
+
|
4448
4795
|
Returns
|
4449
4796
|
-------
|
4450
4797
|
sns : package
|
4451
4798
|
the Seaborn package.
|
4452
|
-
|
4799
|
+
|
4453
4800
|
Example
|
4454
4801
|
-------
|
4455
4802
|
```
|
@@ -4463,7 +4810,7 @@ class CustomPluginTemplate:
|
|
4463
4810
|
raise NotImplementedError
|
4464
4811
|
|
4465
4812
|
@property
|
4466
|
-
def start_time():
|
4813
|
+
def start_time(self):
|
4467
4814
|
raise NotImplementedError
|
4468
4815
|
|
4469
4816
|
def start_timer(self, tmr_id):
|
@@ -4473,12 +4820,12 @@ class CustomPluginTemplate:
|
|
4473
4820
|
raise NotImplementedError
|
4474
4821
|
|
4475
4822
|
@property
|
4476
|
-
def state():
|
4823
|
+
def state(self):
|
4477
4824
|
"""
|
4478
4825
|
Alias for `plugin.local_data_cache`
|
4479
4826
|
can be used as a statefull store of the instance - eg `plugin.state[key]` will return `None`
|
4480
|
-
if that key has never been initialized
|
4481
|
-
|
4827
|
+
if that key has never been initialized
|
4828
|
+
|
4482
4829
|
Returns
|
4483
4830
|
-------
|
4484
4831
|
dict
|
@@ -4486,10 +4833,31 @@ class CustomPluginTemplate:
|
|
4486
4833
|
"""
|
4487
4834
|
raise NotImplementedError
|
4488
4835
|
|
4836
|
+
def state_machine_api_callback_always_false(self):
|
4837
|
+
raise NotImplementedError
|
4838
|
+
|
4839
|
+
def state_machine_api_callback_always_true(self):
|
4840
|
+
raise NotImplementedError
|
4841
|
+
|
4842
|
+
def state_machine_api_callback_do_nothing(self):
|
4843
|
+
raise NotImplementedError
|
4844
|
+
|
4845
|
+
def state_machine_api_destroy(self, name):
|
4846
|
+
raise NotImplementedError
|
4847
|
+
|
4848
|
+
def state_machine_api_get_current_state(self, name):
|
4849
|
+
raise NotImplementedError
|
4850
|
+
|
4851
|
+
def state_machine_api_init(self, name, state_machine_transitions, initial_state, on_successful_step_callback):
|
4852
|
+
raise NotImplementedError
|
4853
|
+
|
4854
|
+
def state_machine_api_step(self, name):
|
4855
|
+
raise NotImplementedError
|
4856
|
+
|
4489
4857
|
def step(self):
|
4490
4858
|
"""
|
4491
4859
|
The main code of the plugin (loop iteration code). Called at each iteration of the plugin loop.
|
4492
|
-
|
4860
|
+
|
4493
4861
|
Returns
|
4494
4862
|
-------
|
4495
4863
|
None.
|
@@ -4503,18 +4871,18 @@ class CustomPluginTemplate:
|
|
4503
4871
|
raise NotImplementedError
|
4504
4872
|
|
4505
4873
|
@property
|
4506
|
-
def str_cache():
|
4874
|
+
def str_cache(self):
|
4507
4875
|
"""
|
4508
4876
|
Can be used as a statefull store of the instance - eg `plugin.str_cache[key]` will return empty string
|
4509
|
-
if that key has never been initialized
|
4510
|
-
|
4511
|
-
|
4877
|
+
if that key has never been initialized
|
4878
|
+
|
4879
|
+
|
4512
4880
|
Returns
|
4513
4881
|
-------
|
4514
4882
|
defaultdict
|
4515
4883
|
a defaultdict with empty strings.
|
4516
|
-
|
4517
|
-
|
4884
|
+
|
4885
|
+
|
4518
4886
|
Example
|
4519
4887
|
-------
|
4520
4888
|
```
|
@@ -4525,22 +4893,7 @@ class CustomPluginTemplate:
|
|
4525
4893
|
"""
|
4526
4894
|
raise NotImplementedError
|
4527
4895
|
|
4528
|
-
def str_to_base64(self,
|
4529
|
-
"""
|
4530
|
-
Transforms a string into a base64 encoded string
|
4531
|
-
|
4532
|
-
Parameters
|
4533
|
-
----------
|
4534
|
-
txt : str
|
4535
|
-
the input string
|
4536
|
-
|
4537
|
-
compress : bool, optional
|
4538
|
-
if True, the string will be compressed before encoding. The default is False.
|
4539
|
-
|
4540
|
-
Returns
|
4541
|
-
-------
|
4542
|
-
str: base64 encoded string
|
4543
|
-
"""
|
4896
|
+
def str_to_base64(self, str, verbose, compress):
|
4544
4897
|
raise NotImplementedError
|
4545
4898
|
|
4546
4899
|
def str_to_datetime(self, str_time, weekday):
|
@@ -4550,7 +4903,7 @@ class CustomPluginTemplate:
|
|
4550
4903
|
----------
|
4551
4904
|
str_time : str - time in format HH:MM
|
4552
4905
|
weekday : int or None - the weekday index starting from 0
|
4553
|
-
|
4906
|
+
|
4554
4907
|
Returns
|
4555
4908
|
-------
|
4556
4909
|
datetime object with the time set to the provided one
|
@@ -4558,41 +4911,59 @@ class CustomPluginTemplate:
|
|
4558
4911
|
raise NotImplementedError
|
4559
4912
|
|
4560
4913
|
@property
|
4561
|
-
def str_unique_identification():
|
4914
|
+
def str_unique_identification(self):
|
4915
|
+
raise NotImplementedError
|
4916
|
+
|
4917
|
+
def string_to_base64(self, txt, compress):
|
4918
|
+
"""
|
4919
|
+
Transforms a string into a base64 encoded string
|
4920
|
+
|
4921
|
+
Parameters
|
4922
|
+
----------
|
4923
|
+
txt : str
|
4924
|
+
the input string
|
4925
|
+
|
4926
|
+
compress : bool, optional
|
4927
|
+
if True, the string will be compressed before encoding. The default is False.
|
4928
|
+
|
4929
|
+
Returns
|
4930
|
+
-------
|
4931
|
+
str: base64 encoded string
|
4932
|
+
"""
|
4562
4933
|
raise NotImplementedError
|
4563
4934
|
|
4564
4935
|
@property
|
4565
|
-
def system_version():
|
4936
|
+
def system_version(self):
|
4566
4937
|
raise NotImplementedError
|
4567
4938
|
|
4568
4939
|
@property
|
4569
|
-
def system_versions():
|
4940
|
+
def system_versions(self):
|
4570
4941
|
raise NotImplementedError
|
4571
4942
|
|
4572
4943
|
@property
|
4573
|
-
def testing_scorer_config():
|
4944
|
+
def testing_scorer_config(self):
|
4574
4945
|
raise NotImplementedError
|
4575
4946
|
|
4576
4947
|
@property
|
4577
|
-
def testing_tester_config():
|
4948
|
+
def testing_tester_config(self):
|
4578
4949
|
raise NotImplementedError
|
4579
4950
|
|
4580
4951
|
@property
|
4581
|
-
def testing_tester_name():
|
4952
|
+
def testing_tester_name(self):
|
4582
4953
|
raise NotImplementedError
|
4583
4954
|
|
4584
4955
|
@property
|
4585
|
-
def testing_tester_y_true_src():
|
4956
|
+
def testing_tester_y_true_src(self):
|
4586
4957
|
raise NotImplementedError
|
4587
4958
|
|
4588
4959
|
@property
|
4589
|
-
def testing_upload_result():
|
4960
|
+
def testing_upload_result(self):
|
4590
4961
|
raise NotImplementedError
|
4591
4962
|
|
4592
4963
|
def threadapi_base64_code_map(self, base64_code, lst_data, n_threads):
|
4593
4964
|
"""
|
4594
4965
|
Run a custom code method in parallel using ThreadPoolExecutor.map
|
4595
|
-
|
4966
|
+
|
4596
4967
|
Parameters
|
4597
4968
|
----------
|
4598
4969
|
base64_code : str
|
@@ -4602,7 +4973,7 @@ class CustomPluginTemplate:
|
|
4602
4973
|
n_threads : int, optional
|
4603
4974
|
The number of threads to use, by default 1
|
4604
4975
|
If this number is higher than 1/4 of available CPUs, it will be set to 1/4 of available CPUs
|
4605
|
-
|
4976
|
+
|
4606
4977
|
Returns
|
4607
4978
|
-------
|
4608
4979
|
list
|
@@ -4613,7 +4984,7 @@ class CustomPluginTemplate:
|
|
4613
4984
|
def threadapi_map(self, func, lst_data, n_threads):
|
4614
4985
|
"""
|
4615
4986
|
Run a function in parallel using ThreadPoolExecutor.map
|
4616
|
-
|
4987
|
+
|
4617
4988
|
Parameters
|
4618
4989
|
----------
|
4619
4990
|
func : callable
|
@@ -4623,7 +4994,7 @@ class CustomPluginTemplate:
|
|
4623
4994
|
n_threads : int, optional
|
4624
4995
|
The number of threads to use, by default 1
|
4625
4996
|
If this number is higher than 1/4 of available CPUs, it will be set to 1/4 of available CPUs
|
4626
|
-
|
4997
|
+
|
4627
4998
|
Returns
|
4628
4999
|
-------
|
4629
5000
|
list
|
@@ -4634,7 +5005,7 @@ class CustomPluginTemplate:
|
|
4634
5005
|
def threadapi_run(self, func, n_threads):
|
4635
5006
|
"""
|
4636
5007
|
Run a function in parallel using threads
|
4637
|
-
|
5008
|
+
|
4638
5009
|
Parameters
|
4639
5010
|
----------
|
4640
5011
|
func : callable
|
@@ -4643,7 +5014,7 @@ class CustomPluginTemplate:
|
|
4643
5014
|
n_threads : int
|
4644
5015
|
The number of threads to use, by default 1
|
4645
5016
|
If this number is higher than 1/4 of available CPUs, it will be set to 1/4 of available CPUs
|
4646
|
-
|
5017
|
+
|
4647
5018
|
Returns
|
4648
5019
|
-------
|
4649
5020
|
list
|
@@ -4654,29 +5025,29 @@ class CustomPluginTemplate:
|
|
4654
5025
|
def time(self):
|
4655
5026
|
"""
|
4656
5027
|
Returns current timestamp
|
4657
|
-
|
5028
|
+
|
4658
5029
|
Returns
|
4659
5030
|
-------
|
4660
5031
|
time : timestamp (float)
|
4661
5032
|
current timestamp.
|
4662
|
-
|
4663
|
-
|
5033
|
+
|
5034
|
+
|
4664
5035
|
Example
|
4665
5036
|
-------
|
4666
5037
|
```
|
4667
5038
|
t1 = self.time()
|
4668
5039
|
... # do some stuff
|
4669
5040
|
elapsed = self.time() - t1
|
4670
|
-
```
|
5041
|
+
```
|
4671
5042
|
"""
|
4672
5043
|
raise NotImplementedError
|
4673
5044
|
|
4674
5045
|
@property
|
4675
|
-
def time_alive():
|
5046
|
+
def time_alive(self):
|
4676
5047
|
raise NotImplementedError
|
4677
5048
|
|
4678
5049
|
@property
|
4679
|
-
def time_from_last_process():
|
5050
|
+
def time_from_last_process(self):
|
4680
5051
|
raise NotImplementedError
|
4681
5052
|
|
4682
5053
|
def time_in_interval_hours(self, ts, start, end):
|
@@ -4687,7 +5058,7 @@ class CustomPluginTemplate:
|
|
4687
5058
|
ts: datetime timestamp
|
4688
5059
|
start = 'hh:mm'
|
4689
5060
|
end = 'hh:mm'
|
4690
|
-
|
5061
|
+
|
4691
5062
|
Returns
|
4692
5063
|
-------
|
4693
5064
|
"""
|
@@ -4696,26 +5067,26 @@ class CustomPluginTemplate:
|
|
4696
5067
|
def time_in_schedule(self, ts, schedule, weekdays):
|
4697
5068
|
"""
|
4698
5069
|
Check if a given timestamp `ts` is in a active schedule given the schedule data
|
4699
|
-
|
4700
|
-
|
5070
|
+
|
5071
|
+
|
4701
5072
|
Parameters
|
4702
5073
|
----------
|
4703
5074
|
ts : float
|
4704
5075
|
the given timestamp.
|
4705
|
-
|
5076
|
+
|
4706
5077
|
schedule : dict or list
|
4707
5078
|
the schedule.
|
4708
|
-
|
5079
|
+
|
4709
5080
|
weekdays : TYPE, optional
|
4710
5081
|
list of weekdays. The default is None.
|
4711
|
-
|
4712
|
-
|
5082
|
+
|
5083
|
+
|
4713
5084
|
Returns
|
4714
5085
|
-------
|
4715
5086
|
bool
|
4716
5087
|
Returns true if time in schedule.
|
4717
|
-
|
4718
|
-
|
5088
|
+
|
5089
|
+
|
4719
5090
|
Example
|
4720
5091
|
-------
|
4721
5092
|
```
|
@@ -4728,21 +5099,21 @@ class CustomPluginTemplate:
|
|
4728
5099
|
def time_to_str(self, ts, fmt):
|
4729
5100
|
"""
|
4730
5101
|
Alias for `timestamp_to_str`
|
4731
|
-
|
4732
|
-
|
5102
|
+
|
5103
|
+
|
4733
5104
|
Parameters
|
4734
5105
|
----------
|
4735
5106
|
ts : float, optional
|
4736
5107
|
The given time. The default is None.
|
4737
5108
|
fmt : str, optional
|
4738
5109
|
The time format. The default is '%Y-%m-%d %H:%M:%S'.
|
4739
|
-
|
5110
|
+
|
4740
5111
|
Returns
|
4741
5112
|
-------
|
4742
5113
|
str
|
4743
5114
|
the string formatted time.
|
4744
|
-
|
4745
|
-
|
5115
|
+
|
5116
|
+
|
4746
5117
|
Example
|
4747
5118
|
-------
|
4748
5119
|
```
|
@@ -4755,13 +5126,14 @@ class CustomPluginTemplate:
|
|
4755
5126
|
raise NotImplementedError
|
4756
5127
|
|
4757
5128
|
@property
|
4758
|
-
def time_with_no_data():
|
5129
|
+
def time_with_no_data(self):
|
4759
5130
|
raise NotImplementedError
|
4760
5131
|
|
4761
5132
|
def timebins_append(self, value, key):
|
4762
5133
|
raise NotImplementedError
|
4763
5134
|
|
4764
|
-
def timebins_create_bin(self, key, weekday_names, report_default_empty_value, per_day_of_week_timeslot,
|
5135
|
+
def timebins_create_bin(self, key, weekday_names, report_default_empty_value, per_day_of_week_timeslot,
|
5136
|
+
warmup_anomaly_models):
|
4765
5137
|
raise NotImplementedError
|
4766
5138
|
|
4767
5139
|
def timebins_get_bin(self, key):
|
@@ -4791,19 +5163,19 @@ class CustomPluginTemplate:
|
|
4791
5163
|
def timedelta(self, kwargs):
|
4792
5164
|
"""
|
4793
5165
|
Alias of `datetime.timedelta`
|
4794
|
-
|
4795
|
-
|
5166
|
+
|
5167
|
+
|
4796
5168
|
Parameters
|
4797
5169
|
----------
|
4798
|
-
**kwargs :
|
5170
|
+
**kwargs :
|
4799
5171
|
can contain days, seconds, microseconds, milliseconds, minutes, hours, weeks.
|
4800
|
-
|
4801
|
-
|
5172
|
+
|
5173
|
+
|
4802
5174
|
Returns
|
4803
5175
|
-------
|
4804
5176
|
timedelta object
|
4805
|
-
|
4806
|
-
|
5177
|
+
|
5178
|
+
|
4807
5179
|
Example
|
4808
5180
|
-------
|
4809
5181
|
```
|
@@ -4818,25 +5190,25 @@ class CustomPluginTemplate:
|
|
4818
5190
|
def timestamp_to_str(self, ts, fmt):
|
4819
5191
|
"""
|
4820
5192
|
Returns the string representation of current time or of a given timestamp
|
4821
|
-
|
4822
|
-
|
5193
|
+
|
5194
|
+
|
4823
5195
|
Parameters
|
4824
5196
|
----------
|
4825
5197
|
ts : float, optional
|
4826
|
-
timestamp. The default is None and will generate string for current timestamp.
|
5198
|
+
timestamp. The default is None and will generate string for current timestamp.
|
4827
5199
|
fmt : str, optional
|
4828
5200
|
format. The default is '%Y-%m-%d %H:%M:%S'.
|
4829
|
-
|
4830
|
-
|
5201
|
+
|
5202
|
+
|
4831
5203
|
Returns
|
4832
5204
|
-------
|
4833
5205
|
str
|
4834
5206
|
the timestamp in string format.
|
4835
|
-
|
4836
|
-
|
5207
|
+
|
5208
|
+
|
4837
5209
|
Example
|
4838
5210
|
-------
|
4839
|
-
|
5211
|
+
|
4840
5212
|
```
|
4841
5213
|
t1 = self.time()
|
4842
5214
|
...
|
@@ -4847,13 +5219,31 @@ class CustomPluginTemplate:
|
|
4847
5219
|
raise NotImplementedError
|
4848
5220
|
|
4849
5221
|
@property
|
4850
|
-
def
|
5222
|
+
def timezone(self):
|
5223
|
+
"""
|
5224
|
+
Proxy for the `datetime.timezone`
|
5225
|
+
|
5226
|
+
Returns
|
5227
|
+
-------
|
5228
|
+
timezone : timezone object
|
5229
|
+
|
5230
|
+
|
5231
|
+
Example
|
5232
|
+
-------
|
5233
|
+
```
|
5234
|
+
utc = self.timezone.utc
|
5235
|
+
```
|
5236
|
+
"""
|
5237
|
+
raise NotImplementedError
|
5238
|
+
|
5239
|
+
@property
|
5240
|
+
def total_payload_count(self):
|
4851
5241
|
raise NotImplementedError
|
4852
5242
|
|
4853
5243
|
def trace_info(self):
|
4854
5244
|
"""
|
4855
5245
|
Returns a multi-line string with the last exception stacktrace (if any)
|
4856
|
-
|
5246
|
+
|
4857
5247
|
Returns
|
4858
5248
|
-------
|
4859
5249
|
str.
|
@@ -4867,7 +5257,7 @@ class CustomPluginTemplate:
|
|
4867
5257
|
----------
|
4868
5258
|
object_id - int
|
4869
5259
|
object_type - str
|
4870
|
-
|
5260
|
+
|
4871
5261
|
Returns
|
4872
5262
|
-------
|
4873
5263
|
res - list, list of points that signify the provided object's centroid on each appearance.
|
@@ -4883,7 +5273,7 @@ class CustomPluginTemplate:
|
|
4883
5273
|
object_id - int
|
4884
5274
|
object_type - str
|
4885
5275
|
class_name - str or list
|
4886
|
-
|
5276
|
+
|
4887
5277
|
Returns
|
4888
5278
|
-------
|
4889
5279
|
res - int, how many times the object was a certain class.
|
@@ -4900,7 +5290,7 @@ class CustomPluginTemplate:
|
|
4900
5290
|
object_id - int
|
4901
5291
|
object_type - str
|
4902
5292
|
class_name - str or list
|
4903
|
-
|
5293
|
+
|
4904
5294
|
Returns
|
4905
5295
|
-------
|
4906
5296
|
res - float, ratio of class appearances.
|
@@ -4914,7 +5304,7 @@ class CustomPluginTemplate:
|
|
4914
5304
|
----------
|
4915
5305
|
object_id - int
|
4916
5306
|
object_type - str
|
4917
|
-
|
5307
|
+
|
4918
5308
|
Returns
|
4919
5309
|
-------
|
4920
5310
|
res - list, list of intervals that the specified object was in the target zone.
|
@@ -4928,7 +5318,7 @@ class CustomPluginTemplate:
|
|
4928
5318
|
----------
|
4929
5319
|
object_id - int
|
4930
5320
|
object_type - str
|
4931
|
-
|
5321
|
+
|
4932
5322
|
Returns
|
4933
5323
|
-------
|
4934
5324
|
res - int, total number of seconds spent in the target zone
|
@@ -4942,7 +5332,7 @@ class CustomPluginTemplate:
|
|
4942
5332
|
----------
|
4943
5333
|
object_id - int
|
4944
5334
|
object_type - str
|
4945
|
-
|
5335
|
+
|
4946
5336
|
Returns
|
4947
5337
|
-------
|
4948
5338
|
res - list, last seen rectangle of the specified object in format [top, left, bottom, right]
|
@@ -4963,13 +5353,28 @@ class CustomPluginTemplate:
|
|
4963
5353
|
method - str, method used for computing the distance
|
4964
5354
|
- if 'l1' this will return the 'l1' distance
|
4965
5355
|
- if 'l2' this will return the 'l2' distance
|
4966
|
-
|
5356
|
+
|
4967
5357
|
Returns
|
4968
5358
|
-------
|
4969
5359
|
res - int or float, max distance the specified object was from its original position
|
4970
5360
|
"""
|
4971
5361
|
raise NotImplementedError
|
4972
5362
|
|
5363
|
+
def trackapi_most_seen_type(self, object_id, object_type):
|
5364
|
+
"""
|
5365
|
+
Public method for accessing the most seen type of specified object.
|
5366
|
+
If meta-types are not used than this will just provide the object's type.
|
5367
|
+
Parameters
|
5368
|
+
----------
|
5369
|
+
object_id - int
|
5370
|
+
object_type - str
|
5371
|
+
|
5372
|
+
Returns
|
5373
|
+
-------
|
5374
|
+
res - str, most seen type of the specified object
|
5375
|
+
"""
|
5376
|
+
raise NotImplementedError
|
5377
|
+
|
4973
5378
|
def trackapi_non_class_count(self, object_id, object_type, class_name):
|
4974
5379
|
"""
|
4975
5380
|
If meta-types are not used than this will just provide 0.
|
@@ -4979,7 +5384,7 @@ class CustomPluginTemplate:
|
|
4979
5384
|
object_id - int
|
4980
5385
|
object_type - str
|
4981
5386
|
class_name - str or list
|
4982
|
-
|
5387
|
+
|
4983
5388
|
Returns
|
4984
5389
|
-------
|
4985
5390
|
res - int, how many times the object was not a certain class.
|
@@ -4993,7 +5398,7 @@ class CustomPluginTemplate:
|
|
4993
5398
|
----------
|
4994
5399
|
object_id - int
|
4995
5400
|
object_type - str
|
4996
|
-
|
5401
|
+
|
4997
5402
|
Returns
|
4998
5403
|
-------
|
4999
5404
|
res - list, centroid of the current object on its first appearance.
|
@@ -5008,7 +5413,7 @@ class CustomPluginTemplate:
|
|
5008
5413
|
----------
|
5009
5414
|
object_id - int
|
5010
5415
|
object_type - str
|
5011
|
-
|
5416
|
+
|
5012
5417
|
Returns
|
5013
5418
|
-------
|
5014
5419
|
res - dict, dictionary providing the number of times the current object appeared as a certain class.
|
@@ -5023,7 +5428,7 @@ class CustomPluginTemplate:
|
|
5023
5428
|
----------
|
5024
5429
|
object_id - int
|
5025
5430
|
object_type - str
|
5026
|
-
|
5431
|
+
|
5027
5432
|
Returns
|
5028
5433
|
-------
|
5029
5434
|
res - deque, list of the type that the current object was at each appearance
|
@@ -5031,13 +5436,13 @@ class CustomPluginTemplate:
|
|
5031
5436
|
raise NotImplementedError
|
5032
5437
|
|
5033
5438
|
@property
|
5034
|
-
def unique_identification():
|
5439
|
+
def unique_identification(self):
|
5035
5440
|
raise NotImplementedError
|
5036
5441
|
|
5037
5442
|
def unlock_resource(self, str_res):
|
5038
5443
|
"""
|
5039
5444
|
Unlocks a resource given a string. Alias to `self.log.unlock_resource`
|
5040
|
-
|
5445
|
+
|
5041
5446
|
Parameters
|
5042
5447
|
----------
|
5043
5448
|
str_res : str
|
@@ -5072,61 +5477,65 @@ class CustomPluginTemplate:
|
|
5072
5477
|
raise NotImplementedError
|
5073
5478
|
|
5074
5479
|
@property
|
5075
|
-
def upstream_inputs_deque():
|
5480
|
+
def upstream_inputs_deque(self):
|
5076
5481
|
raise NotImplementedError
|
5077
5482
|
|
5078
5483
|
@property
|
5079
|
-
def urlparse():
|
5484
|
+
def urlparse(self):
|
5080
5485
|
"""
|
5081
5486
|
Provides access to `urlparse` method from `urllib.parse` package
|
5082
|
-
|
5487
|
+
|
5083
5488
|
Returns
|
5084
5489
|
-------
|
5085
|
-
`urlparse` method
|
5490
|
+
`urlparse` method
|
5086
5491
|
"""
|
5087
5492
|
raise NotImplementedError
|
5088
5493
|
|
5089
5494
|
@property
|
5090
|
-
def urlunparse():
|
5495
|
+
def urlunparse(self):
|
5091
5496
|
"""
|
5092
5497
|
Provides access to `urlunparse` method from `urllib.parse` package
|
5093
|
-
|
5498
|
+
|
5094
5499
|
Returns
|
5095
5500
|
-------
|
5096
|
-
`urlunparse` method
|
5501
|
+
`urlunparse` method
|
5097
5502
|
"""
|
5098
5503
|
raise NotImplementedError
|
5099
5504
|
|
5100
5505
|
@property
|
5101
|
-
def
|
5506
|
+
def use_local_comms_only(self):
|
5507
|
+
raise NotImplementedError
|
5508
|
+
|
5509
|
+
@property
|
5510
|
+
def utils(self):
|
5102
5511
|
"""
|
5103
|
-
Provides access to methods from
|
5512
|
+
Provides access to methods from naeural_core.bussiness.utils.py
|
5104
5513
|
"""
|
5105
5514
|
raise NotImplementedError
|
5106
5515
|
|
5107
5516
|
def uuid(self, size):
|
5108
5517
|
"""
|
5109
5518
|
Returns a unique id.
|
5110
|
-
|
5111
|
-
|
5519
|
+
|
5520
|
+
|
5112
5521
|
Parameters
|
5113
5522
|
----------
|
5114
5523
|
size : int, optional
|
5115
5524
|
the number of chars in the uid. The default is 13.
|
5116
|
-
|
5525
|
+
|
5117
5526
|
Returns
|
5118
5527
|
-------
|
5119
5528
|
str
|
5120
5529
|
the uid.
|
5121
|
-
|
5122
|
-
|
5530
|
+
|
5531
|
+
|
5123
5532
|
Example
|
5124
5533
|
-------
|
5125
|
-
|
5534
|
+
|
5126
5535
|
```
|
5127
5536
|
str_uid = self.uuid()
|
5128
5537
|
result = {'generated' : str_uid}
|
5129
|
-
```
|
5538
|
+
```
|
5130
5539
|
"""
|
5131
5540
|
raise NotImplementedError
|
5132
5541
|
|
@@ -5154,33 +5563,33 @@ class CustomPluginTemplate:
|
|
5154
5563
|
def vision_plot_detections(self):
|
5155
5564
|
"""
|
5156
5565
|
Plots detection on default output image if any
|
5157
|
-
|
5158
|
-
|
5566
|
+
|
5567
|
+
|
5159
5568
|
Returns
|
5160
5569
|
-------
|
5161
5570
|
None.
|
5162
|
-
|
5163
|
-
|
5571
|
+
|
5572
|
+
|
5164
5573
|
Example
|
5165
5574
|
-------
|
5166
5575
|
```
|
5167
5576
|
img = self.dataapi_image()
|
5168
|
-
if img is not None: # no need to try and plot if there is not image
|
5577
|
+
if img is not None: # no need to try and plot if there is not image
|
5169
5578
|
self.vision_plot_detections()
|
5170
5579
|
```
|
5171
5580
|
"""
|
5172
5581
|
raise NotImplementedError
|
5173
5582
|
|
5174
5583
|
@property
|
5175
|
-
def was_last_data():
|
5584
|
+
def was_last_data(self):
|
5176
5585
|
raise NotImplementedError
|
5177
5586
|
|
5178
5587
|
@property
|
5179
|
-
def working_hours():
|
5588
|
+
def working_hours(self):
|
5180
5589
|
raise NotImplementedError
|
5181
5590
|
|
5182
5591
|
@property
|
5183
|
-
def working_hours_is_new_shift():
|
5592
|
+
def working_hours_is_new_shift(self):
|
5184
5593
|
raise NotImplementedError
|
5185
5594
|
|
5186
5595
|
def working_hours_to_local(self, working_hours_schedule, timezone):
|
@@ -5190,7 +5599,7 @@ class CustomPluginTemplate:
|
|
5190
5599
|
----------
|
5191
5600
|
working_hours_schedule : list or dict - the working hours schedule
|
5192
5601
|
timezone : str or None - the timezone to convert to
|
5193
|
-
|
5602
|
+
|
5194
5603
|
Returns
|
5195
5604
|
-------
|
5196
5605
|
res_working_hours - list or dict with the working hours (and weekdays if necessary) converted to local time
|
@@ -5198,10 +5607,10 @@ class CustomPluginTemplate:
|
|
5198
5607
|
raise NotImplementedError
|
5199
5608
|
|
5200
5609
|
@property
|
5201
|
-
def yaml():
|
5610
|
+
def yaml(self):
|
5202
5611
|
"""
|
5203
5612
|
Provides access to `yaml` package
|
5204
|
-
|
5613
|
+
|
5205
5614
|
Returns
|
5206
5615
|
-------
|
5207
5616
|
`yaml` package
|