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