wizata-dsapi 1.2.25__py3-none-any.whl → 1.2.27__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.
@@ -148,7 +148,7 @@ def df_from_dict(df_dict: dict) -> pandas.DataFrame:
148
148
  raise ValueError('if using a multi-line dataframe please provide a Timestamp column')
149
149
 
150
150
  if "Timestamp" not in df_dict:
151
- df_dict["Timestamp"] = [datetime.utcnow()]
151
+ df_dict["Timestamp"] = [datetime.now(timezone.utc)]
152
152
  else:
153
153
  timestamp_col = []
154
154
  for timestamp_ms in df_dict["Timestamp"]:
@@ -208,7 +208,7 @@ def verify_relative_datetime(formatted_string: str) -> bool:
208
208
  def generate_epoch(formatted_string: str, now=None):
209
209
  """
210
210
  generate an epoch based on a formatted string (e.g. now+6h) - see documentation.
211
- * now = datetime.utcnow() can be override
211
+ * now = datetime.now(timezone.utc) can be override
212
212
  * units = 'y' = 365d, 'M'=30d , 'w'=7d , 'd'=24h , 'h'=60m, 'm'=60s , 's'=1000'ms'
213
213
  * operators = '+' or '-'
214
214
  :param formatted_string: formatted epoch representation using relative time.
@@ -216,7 +216,7 @@ def generate_epoch(formatted_string: str, now=None):
216
216
  :return: epoch in ms.
217
217
  """
218
218
  if now is None:
219
- now = datetime.utcnow()
219
+ now = datetime.now(timezone.utc)
220
220
 
221
221
  pattern = r'^now([+-]\d+([yMwdHhms]{1,2}))?$'
222
222
  match = re.match(pattern, formatted_string)
@@ -274,5 +274,5 @@ def generate_unique_key() -> str:
274
274
  - 11 char for 'animal_'
275
275
  - 3 car for number XXX
276
276
  """
277
- return f"{datetime.now().strftime('%y%m%d')}_{random.choice(colors).lower()}_" \
277
+ return f"{datetime.now(timezone.utc).strftime('%y%m%d')}_{random.choice(colors).lower()}_" \
278
278
  f"{random.choice(animals).lower()}_{random.randint(1, 999)}"
wizata_dsapi/request.py CHANGED
@@ -355,6 +355,36 @@ class Request(ApiDto):
355
355
  else:
356
356
  return
357
357
 
358
+ def set_twin(self, twin):
359
+ """
360
+ set a twin properly (str hardware Id or uuid.UUID)
361
+ :param twin:
362
+ :return:
363
+ """
364
+ if self.template is None:
365
+ self.template = {}
366
+ if isinstance(twin, uuid.UUID):
367
+ self.template['twin_id'] = twin
368
+ elif isinstance(twin, str):
369
+ self.template['twin_hardware_id'] = twin
370
+ else:
371
+ raise TypeError('twin must be str or uuid on request')
372
+
373
+ def set_template(self, template):
374
+ """
375
+ set a template properly (str key or uuid.UUID)
376
+ :param template:
377
+ :return:
378
+ """
379
+ if self.template is None:
380
+ self.template = {}
381
+ if isinstance(template, uuid.UUID):
382
+ self.template['template_id'] = template
383
+ elif isinstance(template, str):
384
+ self.template['template_key'] = template
385
+ else:
386
+ raise TypeError('template must be str or uuid on request')
387
+
358
388
  def __format_date(self, dt_to_format):
359
389
  if isinstance(dt_to_format, datetime):
360
390
  millisec = dt_to_format.timestamp() * 1000
@@ -468,22 +498,27 @@ class Request(ApiDto):
468
498
  else:
469
499
  self.template = {}
470
500
 
471
- if template_id is not None:
501
+ template = None
502
+ if template_key is not None:
503
+ template = template_key
504
+ elif template_id is not None:
472
505
  if isinstance(template_id, uuid.UUID):
473
- self.template['template_id'] = template_id
506
+ template = template_id
474
507
  else:
475
- self.template['template_id'] = uuid.UUID(template_id)
476
- elif template_key is not None:
477
- self.template['template_key'] = str(template_key)
478
-
479
- if twin_id is not None:
508
+ template = uuid.UUID(template_id)
509
+ if template is not None:
510
+ self.set_template(template=template)
511
+
512
+ twin = None
513
+ if twin_hardware_id is not None:
514
+ twin = twin_hardware_id
515
+ elif twin_id is not None:
480
516
  if isinstance(twin_id, uuid.UUID):
481
- self.template['twin_id'] = twin_id
517
+ twin = twin_id
482
518
  else:
483
- self.template['twin_id'] = uuid.UUID(twin_id)
484
-
485
- elif twin_hardware_id is not None:
486
- self.template['twin_hardware_id'] = str(twin_hardware_id)
519
+ twin = uuid.UUID(twin_id)
520
+ if twin is not None:
521
+ self.set_twin(twin=twin)
487
522
 
488
523
  def get_params(self):
489
524
  """
wizata_dsapi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.2.25"
1
+ __version__ = "1.2.27"
@@ -662,11 +662,11 @@ class WizataDSAPIClient(ApiInterface):
662
662
 
663
663
  request.set_aggregation(agg_method, interval)
664
664
 
665
- if template is not None or twin is not None:
666
- request.select_template(
667
- template_key=template,
668
- twin_hardware_id=twin
669
- )
665
+ if twin is not None:
666
+ request.set_twin(twin)
667
+
668
+ if template is not None:
669
+ request.set_template(template)
670
670
 
671
671
  if filters is not None:
672
672
  request.filters = filters
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizata-dsapi
3
- Version: 1.2.25
3
+ Version: 1.2.27
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -5,7 +5,7 @@ wizata_dsapi/api_interface.py,sha256=DURk-0ey16T8sV5e2Y2G_YybPEusJvZuY0oD5L7AnXo
5
5
  wizata_dsapi/bucket.py,sha256=Zz9olv-pymikAutGitSuGWrAPiawOTW86JDDHG4ugTc,1150
6
6
  wizata_dsapi/business_label.py,sha256=u0TVfUNfoR9qSv8lzpf6rNjlg3G9xTiz6itefcKfeak,4151
7
7
  wizata_dsapi/context.py,sha256=M7hsvXoU0Bn_5ONDB-5VvjriMpno6bAgh0RrJ9Y-h7U,11600
8
- wizata_dsapi/dataframe_toolkit.py,sha256=22H4SizmhTQ1DNIzd6tg0izgncRDcrdkfGdBO6Vbi5g,9039
8
+ wizata_dsapi/dataframe_toolkit.py,sha256=7D8JrhsFSGXeO3mRAd2e2cLmdjbXRjk04IuaMG8F974,9078
9
9
  wizata_dsapi/datapoint.py,sha256=UUatqzWMwC4ucM6HdeQDWtLS4fGqEsDABCNVmxoP5Hg,14635
10
10
  wizata_dsapi/datastore.py,sha256=BSHZmCSJ679boBA1eCkaWGJCy1CUeipKKGt2jDHzdVo,2663
11
11
  wizata_dsapi/ds_dataframe.py,sha256=Sk2JRUuTRJzko3HosJnbK34STpgSJUlqxLq8w_E5VM4,2089
@@ -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=qHh1-DQri2Vh17069fHmLlrF5vjNTvA4jmD6mYjg2w8,26515
26
+ wizata_dsapi/request.py,sha256=W4E1BHacQdJiBLPI96yVeHz41rbfFuGrbuw1U60L_DM,27560
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,10 +31,10 @@ wizata_dsapi/template.py,sha256=wtCRKKk3PchH4RrNgNYlEF_9C6bzZwKIeLyEvgv6Fdo,1370
31
31
  wizata_dsapi/trigger.py,sha256=w3BZYP-L3SUwvaT0oCTanh_Ewn57peZvlt7vxzHv9J8,5129
32
32
  wizata_dsapi/twin.py,sha256=S0DUzQf1smZXZTdXpXZPtkZYCfKIhw53EecCnsl9i4Q,11017
33
33
  wizata_dsapi/twinregistration.py,sha256=Mi6-YuwroiEXc0c1hgrOaphh4hNVoHupxOnXedVtJtE,13377
34
- wizata_dsapi/version.py,sha256=9j001fhDZzLSWs6YCbGQFuK5ERX5EUWz3RKLN8l5JS8,23
34
+ wizata_dsapi/version.py,sha256=JKArgvnX6ljUI_WxYnXTejXGdjsA4KJ3Cy2xBcK4vh4,23
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
- wizata_dsapi/wizata_dsapi_client.py,sha256=6URQeMA5A9eXxC2cs8TUbKolmOo-Kj6kII9NmRRITPQ,78702
37
+ wizata_dsapi/wizata_dsapi_client.py,sha256=kos_8j47CBXiy6y6b_H2yDUe3aWh76diEmWjCisYKkY,78662
38
38
  wizata_dsapi/words.py,sha256=tV8CqzCqODZCV7PgBxBF5exBxeF_ya9t5DiUy-cg6Sg,1535
39
39
  wizata_dsapi/models/__init__.py,sha256=O5PHqw8lKILw4apO-MfDxPz73wK0vADD9y3xjuzX7Tw,104
40
40
  wizata_dsapi/models/common.py,sha256=1dTqE80-mFJnUwEdNlJdhJzfZ2N5Kp8Nb3LQ8uwPtLc,3808
@@ -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.25.dist-info/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
- wizata_dsapi-1.2.25.dist-info/METADATA,sha256=hWT2ESQIOnGzoOoXklVARi5LoeEYuL0Sf0IKCU60_YM,2188
47
- wizata_dsapi-1.2.25.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
48
- wizata_dsapi-1.2.25.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
49
- wizata_dsapi-1.2.25.dist-info/RECORD,,
45
+ wizata_dsapi-1.2.27.dist-info/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
+ wizata_dsapi-1.2.27.dist-info/METADATA,sha256=idjFas_BsW1WjABbd60xyTwUAh0JWIkhvafZWvg6PS8,2188
47
+ wizata_dsapi-1.2.27.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
48
+ wizata_dsapi-1.2.27.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
49
+ wizata_dsapi-1.2.27.dist-info/RECORD,,