wizata-dsapi 1.2.2__py3-none-any.whl → 1.2.4__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.
wizata_dsapi/__init__.py CHANGED
@@ -4,7 +4,7 @@ from .api_dto import ApiDto, VarType
4
4
  from .paged_query_result import PagedQueryResult
5
5
  from .plot import Plot
6
6
  from .mlmodel import MLModel, MLModelConfig
7
- from .request import Request, filter_map
7
+ from .request import Request, filter_map, RequestGroup, RequestGroupMap
8
8
  from .execution import Execution, ExecutionStatus, ExecutionStepLog, AbortedException
9
9
  from .experiment import Experiment
10
10
  from .ds_dataframe import DSDataFrame
wizata_dsapi/request.py CHANGED
@@ -1,5 +1,8 @@
1
1
  import uuid
2
2
  from datetime import datetime, timedelta, timezone
3
+
4
+ from reactivex.operators import group_by
5
+
3
6
  from .dataframe_toolkit import generate_epoch
4
7
  from .api_dto import ApiDto
5
8
 
@@ -13,6 +16,77 @@ filter_map = {
13
16
  }
14
17
 
15
18
 
19
+ class RequestGroupMap:
20
+ """
21
+ Define a mapping between a set of datapoints and their corresponding event datapoint.
22
+ :ivar event_hardware_id str: hardware id of the datapoint identifying event inside a group.
23
+ :ivar event_datapoint: datapoint complete definition corresponding to event_hardware_id.
24
+ :ivar datapoints_hardware_ids list: list of all related datapoints.
25
+ :ivar datapoints dict: dict with key as hardware id and value datapoint for all mapped datapoints.
26
+ """
27
+
28
+ def __init__(self,
29
+ event_hardware_id: str,
30
+ datapoints_hardware_ids: list):
31
+ self.event_hardware_id = event_hardware_id
32
+ self.datapoints_hardware_ids = datapoints_hardware_ids
33
+ self.event_datapoint = None
34
+ self.datapoints = {}
35
+
36
+
37
+ class RequestGroup:
38
+ """
39
+ Define a group statement within a structured query.
40
+ """
41
+
42
+ def __init__(self,
43
+ system_id,
44
+ events: list = None,
45
+ group_by: str = "id",
46
+ start_delay: int = 0,
47
+ end_delay: int = 0,
48
+ maps: list = None):
49
+ self.system_id = system_id
50
+ self.group_by = group_by
51
+ self.events = events
52
+ self.maps = maps
53
+ self.start_delay = start_delay
54
+ self.end_delay = end_delay
55
+
56
+ @classmethod
57
+ def from_dict(cls, my_dict):
58
+ if my_dict is None or not isinstance(my_dict, dict):
59
+ raise ValueError(f"illegal group {my_dict}")
60
+
61
+ if "system_id" not in my_dict or my_dict["system_id"] is None:
62
+ if not isinstance(["system_id"], str) and not isinstance(my_dict["system_id"], int):
63
+ raise ValueError(f"please specify system_id in {my_dict}")
64
+
65
+ group = RequestGroup(
66
+ system_id=["system_id"]
67
+ )
68
+
69
+ # set group_by
70
+ if "group_by" in my_dict:
71
+ if my_dict["group_by"] not in ["id", "type"]:
72
+ raise ValueError(f"illegal group {my_dict['group_by']}")
73
+ group.group_by = my_dict["group_by"]
74
+
75
+ # one of the two is accepted to set events
76
+ if "event_ids" in my_dict:
77
+ group.events = my_dict["event_ids"]
78
+ if "events" in my_dict:
79
+ group.events = my_dict["events"]
80
+
81
+ if "start_delay" in my_dict:
82
+ group.start_delay = int(my_dict["start_delay"])
83
+
84
+ if "end_delay" in my_dict:
85
+ group.end_delay = int(my_dict["end_delay"])
86
+
87
+ return group
88
+
89
+
16
90
  class Request(ApiDto):
17
91
  """
18
92
  request defines how to fetch data from time-series database.
@@ -117,6 +191,23 @@ class Request(ApiDto):
117
191
  else:
118
192
  raise TypeError(f'field must be None, str or a list of str')
119
193
 
194
+ @property
195
+ def groups(self) -> list[RequestGroup]:
196
+ """
197
+ return formatted groups list based on group
198
+ :return:
199
+ """
200
+ if self.group is not None and self.group != {}:
201
+ if not isinstance(self.group, list):
202
+ return [RequestGroup.from_dict(self.group)]
203
+ else:
204
+ groups = []
205
+ for group in self.group:
206
+ groups.append(RequestGroup.from_dict(group))
207
+ return groups
208
+ else:
209
+ return []
210
+
120
211
  def get_template_id(self):
121
212
  """
122
213
  extract template id from request if present.
wizata_dsapi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.2.2"
1
+ __version__ = "1.2.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizata-dsapi
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -1,4 +1,4 @@
1
- wizata_dsapi/__init__.py,sha256=4yjQDC652yIQAcA0zc8zdoiWfmVoRpn7MRCnupXcSGw,1969
1
+ wizata_dsapi/__init__.py,sha256=rXiNoTi7YeObXCa4nLOdILZhhmt_GL2_eIQ5TK5NNlw,2000
2
2
  wizata_dsapi/api_config.py,sha256=CkEmEZYNKqtnzZRHH5O4QW3O4MtoOJHoghh7ZsOokEc,5073
3
3
  wizata_dsapi/api_dto.py,sha256=-NdaTRvw5jW5xFGpIhY8U0-SdvzW2t6QD26y0UPApU0,2238
4
4
  wizata_dsapi/api_interface.py,sha256=DURk-0ey16T8sV5e2Y2G_YybPEusJvZuY0oD5L7AnXo,10903
@@ -23,7 +23,7 @@ wizata_dsapi/pipeline.py,sha256=WDJeOxPZJiYW1qwTNZUm3jom2epIxqrSoiUwcrTF9EE,3130
23
23
  wizata_dsapi/pipeline_deployment.py,sha256=grekBaxUK0EhL9w7lDB8vNuW_wzLnHVm9Mq8Lkbkguk,1722
24
24
  wizata_dsapi/pipeline_image.py,sha256=M3FOr45dJIAEvsmXPpMD8JZ09k5-YpW9PRYEWJqptcI,5272
25
25
  wizata_dsapi/plot.py,sha256=SPGKFWWYNcRvHcqvvnPIIIBKsd5UwhdsxLW7b2dG2rs,2360
26
- wizata_dsapi/request.py,sha256=Uqn03M6mUct6FQ4kj5A0SwX8g0vA8rM2W3EyWUvadqA,23159
26
+ wizata_dsapi/request.py,sha256=uZCTNiDz8Y2vq2e1UEXcBaNSCn4m7JaIh8ZiqqmKq7I,26209
27
27
  wizata_dsapi/script.py,sha256=DeEciwVpuCYZetgJCoivw_bYe8ma52WuTaTQ_VkLEcg,12930
28
28
  wizata_dsapi/solution_component.py,sha256=8gbZWx2h_xUqI_pAXa3goqAnR5Y-GDMii8MeGlaK1IE,9531
29
29
  wizata_dsapi/streamlit_utils.py,sha256=sXBdygktbixV828Zg01Nl27_a4F8zGFc4RY0C8g-1bc,1942
@@ -31,7 +31,7 @@ wizata_dsapi/template.py,sha256=h2f3dLduJ4WhreVxJXuFIB3pinnI3c39WxBms0bCgos,1300
31
31
  wizata_dsapi/trigger.py,sha256=w3BZYP-L3SUwvaT0oCTanh_Ewn57peZvlt7vxzHv9J8,5129
32
32
  wizata_dsapi/twin.py,sha256=OFDFg2CsTxOUOVOf6kkDUEK9A3ED7yuPpN9TqodGruo,6581
33
33
  wizata_dsapi/twinregistration.py,sha256=Mi6-YuwroiEXc0c1hgrOaphh4hNVoHupxOnXedVtJtE,13377
34
- wizata_dsapi/version.py,sha256=uuf4VNtTNA93fMhoAur9YafzaKJFnczY-H1SSCSuRVQ,22
34
+ wizata_dsapi/version.py,sha256=XBKH8E1LmDxv06U39yqMBbXZapOERFgICEDYZs_kRso,22
35
35
  wizata_dsapi/wizard_function.py,sha256=RbM7W7Gf-6Rhp_1dU9DBYkHaciknGAGvuAndhAS_vyo,942
36
36
  wizata_dsapi/wizard_request.py,sha256=v6BaqKLKvTWmUSo0_gda9FabAQz5x_-GOH1Av50GzFo,3762
37
37
  wizata_dsapi/wizata_dsapi_client.py,sha256=Qz54vYoxRLBUa21Q55K5Oo1qtZpW9ucuXi4BX1N85oE,78716
@@ -42,8 +42,8 @@ wizata_dsapi/plots/__init__.py,sha256=qgnSFqrjOPur-807M8uh5awIfjM1ZHXUXcAqHc-r2l
42
42
  wizata_dsapi/plots/common.py,sha256=jdPsJqLHBwSKc6dX83BSGPqSRxzIVNHSYO5yI_8sjGk,6568
43
43
  wizata_dsapi/scripts/__init__.py,sha256=hAxiETSQf0qOHde1si1tEAJU48seqEgHrchCzS2-LvQ,80
44
44
  wizata_dsapi/scripts/common.py,sha256=efwq-Rd0lvYljIs3gSFz9izogBD7asOU2cTK-IvHTkM,4244
45
- wizata_dsapi-1.2.2.dist-info/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
- wizata_dsapi-1.2.2.dist-info/METADATA,sha256=_WJlwzUyvWJZ_3MRO9gfS6qMPD2ctlM7c63Vv1RKTQY,2187
47
- wizata_dsapi-1.2.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
48
- wizata_dsapi-1.2.2.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
49
- wizata_dsapi-1.2.2.dist-info/RECORD,,
45
+ wizata_dsapi-1.2.4.dist-info/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
+ wizata_dsapi-1.2.4.dist-info/METADATA,sha256=mTEgSlDDw2Y6uEMkiF-EBNStOQhMmJ-4hvewz0tiMEw,2187
47
+ wizata_dsapi-1.2.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
48
+ wizata_dsapi-1.2.4.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
49
+ wizata_dsapi-1.2.4.dist-info/RECORD,,