sumo-wrapper-python 1.7.0__py3-none-any.whl → 1.8.0__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.
sumo/wrapper/_logging.py CHANGED
@@ -28,6 +28,9 @@ class LogHandlerSumo(logging.Handler):
28
28
  if "objectUuid" in record.__dict__:
29
29
  json["objectUuid"] = record.__dict__.get("objectUuid")
30
30
 
31
+ if "details" in record.__dict__:
32
+ json["details"] = record.__dict__.get("details")
33
+
31
34
  self._sumoClient.post("/message-log/new", json=json)
32
35
  except Exception:
33
36
  # Never fail on logging
@@ -38,10 +38,17 @@ def _return_last_value(retry_state):
38
38
 
39
39
 
40
40
  class RetryStrategy:
41
- def __init__(self, stop_after=6, multiplier=0.5, exp_base=2):
41
+ def __init__(
42
+ self,
43
+ stop_after=6,
44
+ multiplier=0.5,
45
+ exp_base=2,
46
+ before_sleep=_log_retry_info,
47
+ ):
42
48
  self._stop_after = stop_after
43
49
  self._multiplier = multiplier
44
50
  self._exp_base = exp_base
51
+ self._before_sleep = before_sleep
45
52
  return
46
53
 
47
54
  def make_retryer(self) -> tn.Retrying:
@@ -60,7 +67,7 @@ class RetryStrategy:
60
67
  )
61
68
  ),
62
69
  retry_error_callback=_return_last_value,
63
- before_sleep=_log_retry_info,
70
+ before_sleep=self._before_sleep,
64
71
  )
65
72
 
66
73
  def make_retryer_async(self) -> tn.AsyncRetrying:
@@ -79,5 +86,5 @@ class RetryStrategy:
79
86
  )
80
87
  ),
81
88
  retry_error_callback=_return_last_value,
82
- before_sleep=_log_retry_info,
89
+ before_sleep=self._before_sleep,
83
90
  )
sumo/wrapper/_version.py CHANGED
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.7.0'
22
- __version_tuple__ = version_tuple = (1, 7, 0)
21
+ __version__ = version = '1.8.0'
22
+ __version_tuple__ = version_tuple = (1, 8, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -219,7 +219,12 @@ class SumoClient:
219
219
  )
220
220
 
221
221
  @raise_for_status
222
- def get(self, path: str, params: Optional[Dict] = None) -> httpx.Response:
222
+ def get(
223
+ self,
224
+ path: str,
225
+ params: Optional[Dict] = None,
226
+ retry_strategy: Optional[RetryStrategy] = None,
227
+ ) -> httpx.Response:
223
228
  """Performs a GET-request to the Sumo API.
224
229
 
225
230
  Args:
@@ -277,8 +282,9 @@ class SumoClient:
277
282
  timeout=self._timeout,
278
283
  )
279
284
 
280
- retryer = self._retry_strategy.make_retryer()
281
-
285
+ retryer = (
286
+ retry_strategy if retry_strategy else self._retry_strategy
287
+ ).make_retryer()
282
288
  return retryer(_get)
283
289
 
284
290
  @raise_for_status
@@ -288,6 +294,7 @@ class SumoClient:
288
294
  blob: Optional[bytes] = None,
289
295
  json: Optional[dict] = None,
290
296
  params: Optional[dict] = None,
297
+ retry_strategy: Optional[RetryStrategy] = None,
291
298
  ) -> httpx.Response:
292
299
  """Performs a POST-request to the Sumo API.
293
300
 
@@ -352,7 +359,9 @@ class SumoClient:
352
359
  timeout=self._timeout,
353
360
  )
354
361
 
355
- retryer = self._retry_strategy.make_retryer()
362
+ retryer = (
363
+ retry_strategy if retry_strategy else self._retry_strategy
364
+ ).make_retryer()
356
365
 
357
366
  return retryer(_post)
358
367
 
@@ -362,6 +371,7 @@ class SumoClient:
362
371
  path: str,
363
372
  blob: Optional[bytes] = None,
364
373
  json: Optional[dict] = None,
374
+ retry_strategy: Optional[RetryStrategy] = None,
365
375
  ) -> httpx.Response:
366
376
  """Performs a PUT-request to the Sumo API.
367
377
 
@@ -401,13 +411,18 @@ class SumoClient:
401
411
  timeout=self._timeout,
402
412
  )
403
413
 
404
- retryer = self._retry_strategy.make_retryer()
414
+ retryer = (
415
+ retry_strategy if retry_strategy else self._retry_strategy
416
+ ).make_retryer()
405
417
 
406
418
  return retryer(_put)
407
419
 
408
420
  @raise_for_status
409
421
  def delete(
410
- self, path: str, params: Optional[dict] = None
422
+ self,
423
+ path: str,
424
+ params: Optional[dict] = None,
425
+ retry_strategy: Optional[RetryStrategy] = None,
411
426
  ) -> httpx.Response:
412
427
  """Performs a DELETE-request to the Sumo API.
413
428
 
@@ -441,7 +456,9 @@ class SumoClient:
441
456
  timeout=self._timeout,
442
457
  )
443
458
 
444
- retryer = self._retry_strategy.make_retryer()
459
+ retryer = (
460
+ retry_strategy if retry_strategy else self._retry_strategy
461
+ ).make_retryer()
445
462
 
446
463
  return retryer(_delete)
447
464
 
@@ -460,7 +477,10 @@ class SumoClient:
460
477
  return location, retry_after
461
478
 
462
479
  def poll(
463
- self, response_in: httpx.Response, timeout=None
480
+ self,
481
+ response_in: httpx.Response,
482
+ timeout=None,
483
+ retry_strategy: Optional[RetryStrategy] = None,
464
484
  ) -> httpx.Response:
465
485
  """Poll a specific endpoint until a result is obtained.
466
486
 
@@ -474,7 +494,7 @@ class SumoClient:
474
494
  expiry = time.time() + timeout if timeout is not None else None
475
495
  while True:
476
496
  time.sleep(retry_after)
477
- response = self.get(location)
497
+ response = self.get(location, retry_strategy=retry_strategy)
478
498
  if response.status_code != 202:
479
499
  return response
480
500
  if expiry is not None and time.time() > expiry:
@@ -539,7 +559,10 @@ class SumoClient:
539
559
 
540
560
  @raise_for_status_async
541
561
  async def get_async(
542
- self, path: str, params: Optional[dict] = None
562
+ self,
563
+ path: str,
564
+ params: Optional[dict] = None,
565
+ retry_strategy: Optional[RetryStrategy] = None,
543
566
  ) -> httpx.Response:
544
567
  """Performs an async GET-request to the Sumo API.
545
568
 
@@ -598,7 +621,9 @@ class SumoClient:
598
621
  timeout=self._timeout,
599
622
  )
600
623
 
601
- retryer = self._retry_strategy.make_retryer_async()
624
+ retryer = (
625
+ retry_strategy if retry_strategy else self._retry_strategy
626
+ ).make_retryer_async()
602
627
 
603
628
  return await retryer(_get)
604
629
 
@@ -609,6 +634,7 @@ class SumoClient:
609
634
  blob: Optional[bytes] = None,
610
635
  json: Optional[dict] = None,
611
636
  params: Optional[dict] = None,
637
+ retry_strategy: Optional[RetryStrategy] = None,
612
638
  ) -> httpx.Response:
613
639
  """Performs an async POST-request to the Sumo API.
614
640
 
@@ -674,7 +700,9 @@ class SumoClient:
674
700
  timeout=self._timeout,
675
701
  )
676
702
 
677
- retryer = self._retry_strategy.make_retryer_async()
703
+ retryer = (
704
+ retry_strategy if retry_strategy else self._retry_strategy
705
+ ).make_retryer_async()
678
706
 
679
707
  return await retryer(_post)
680
708
 
@@ -684,6 +712,7 @@ class SumoClient:
684
712
  path: str,
685
713
  blob: Optional[bytes] = None,
686
714
  json: Optional[dict] = None,
715
+ retry_strategy: Optional[RetryStrategy] = None,
687
716
  ) -> httpx.Response:
688
717
  """Performs an async PUT-request to the Sumo API.
689
718
 
@@ -723,13 +752,18 @@ class SumoClient:
723
752
  timeout=self._timeout,
724
753
  )
725
754
 
726
- retryer = self._retry_strategy.make_retryer_async()
755
+ retryer = (
756
+ retry_strategy if retry_strategy else self._retry_strategy
757
+ ).make_retryer_async()
727
758
 
728
759
  return await retryer(_put)
729
760
 
730
761
  @raise_for_status_async
731
762
  async def delete_async(
732
- self, path: str, params: Optional[dict] = None
763
+ self,
764
+ path: str,
765
+ params: Optional[dict] = None,
766
+ retry_strategy: Optional[RetryStrategy] = None,
733
767
  ) -> httpx.Response:
734
768
  """Performs an async DELETE-request to the Sumo API.
735
769
 
@@ -763,12 +797,17 @@ class SumoClient:
763
797
  timeout=self._timeout,
764
798
  )
765
799
 
766
- retryer = self._retry_strategy.make_retryer_async()
800
+ retryer = (
801
+ retry_strategy if retry_strategy else self._retry_strategy
802
+ ).make_retryer_async()
767
803
 
768
804
  return await retryer(_delete)
769
805
 
770
806
  async def poll_async(
771
- self, response_in: httpx.Response, timeout=None
807
+ self,
808
+ response_in: httpx.Response,
809
+ timeout=None,
810
+ retry_strategy: Optional[RetryStrategy] = None,
772
811
  ) -> httpx.Response:
773
812
  """Poll a specific endpoint until a result is obtained.
774
813
 
@@ -782,7 +821,9 @@ class SumoClient:
782
821
  expiry = time.time() + timeout if timeout is not None else None
783
822
  while True:
784
823
  await asyncio.sleep(retry_after)
785
- response = await self.get_async(location)
824
+ response = await self.get_async(
825
+ location, retry_strategy=retry_strategy
826
+ )
786
827
  if response.status_code != 202:
787
828
  return response
788
829
  if expiry is not None and time.time() > expiry:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sumo-wrapper-python
3
- Version: 1.7.0
3
+ Version: 1.8.0
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -0,0 +1,16 @@
1
+ sumo/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
2
+ sumo/wrapper/__init__.py,sha256=JK6iMAy2Fdrc7iaIHTn60fHPdRvsgNjZwWD6DJtGUYQ,235
3
+ sumo/wrapper/_auth_provider.py,sha256=XO2WcEJjQuXsDhFZ3wplOL_plxNdAqk2yw2jzv3iLSQ,16660
4
+ sumo/wrapper/_blob_client.py,sha256=SyfyFZ1hHVWKU4lmgUqSjl5TaK_OJNQ__0wDETrp-ag,1623
5
+ sumo/wrapper/_decorators.py,sha256=ZwyrWkfAXiGNSgYsQSEXA13D-WIQM2XPf0v2z9N8HyQ,1002
6
+ sumo/wrapper/_logging.py,sha256=vm85iaarcqeM40kvv32dO1UKKCWVfeF8a3rN1-K82S0,1185
7
+ sumo/wrapper/_retry_strategy.py,sha256=33eY_PxgcDXJs6_NDQOOkllADePnZgge_cELtaLfJZM,2650
8
+ sumo/wrapper/_version.py,sha256=n6hqiGWubG62zMPv1zntf2ad8WUFfELiXM1ZL13KtJA,520
9
+ sumo/wrapper/login.py,sha256=PtpQ5Qi8Gm1N0hMnE79Je4QvQ8JMuKqa46TwZgjHRnM,2328
10
+ sumo/wrapper/sumo_client.py,sha256=fI9khiMOgpK6Vai0Sk8YD3vp0dREbdr_1WHW9nv9WWg,24430
11
+ sumo_wrapper_python-1.8.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
+ sumo_wrapper_python-1.8.0.dist-info/METADATA,sha256=q0aV31EJYFco6NYg0f7bCRUc-7ocS7CGR9zAP7inUPk,14615
13
+ sumo_wrapper_python-1.8.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
14
+ sumo_wrapper_python-1.8.0.dist-info/entry_points.txt,sha256=V_vGky2C3He5vohJAxnBdvpt_fqfUDFj5irUm9HtoFc,55
15
+ sumo_wrapper_python-1.8.0.dist-info/top_level.txt,sha256=rLbKyH9rWgCj3PoLeR7fvC5X8vCaUc5LF8-Y_GBWZL0,5
16
+ sumo_wrapper_python-1.8.0.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- sumo/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
2
- sumo/wrapper/__init__.py,sha256=JK6iMAy2Fdrc7iaIHTn60fHPdRvsgNjZwWD6DJtGUYQ,235
3
- sumo/wrapper/_auth_provider.py,sha256=XO2WcEJjQuXsDhFZ3wplOL_plxNdAqk2yw2jzv3iLSQ,16660
4
- sumo/wrapper/_blob_client.py,sha256=SyfyFZ1hHVWKU4lmgUqSjl5TaK_OJNQ__0wDETrp-ag,1623
5
- sumo/wrapper/_decorators.py,sha256=ZwyrWkfAXiGNSgYsQSEXA13D-WIQM2XPf0v2z9N8HyQ,1002
6
- sumo/wrapper/_logging.py,sha256=WAGrjPmK2_JC9w1IxT5onq1iEAreEsyzmm95pXBe0dA,1074
7
- sumo/wrapper/_retry_strategy.py,sha256=JSXy-ki5vWI_N4D52LpK9EoAmPrnT3H6OG0aBLsJRMk,2525
8
- sumo/wrapper/_version.py,sha256=pvN114lCpRNcdz9ufJCnl1MMqgOtZU1RmZfWI_uxL9s,520
9
- sumo/wrapper/login.py,sha256=PtpQ5Qi8Gm1N0hMnE79Je4QvQ8JMuKqa46TwZgjHRnM,2328
10
- sumo/wrapper/sumo_client.py,sha256=yGCfJCIxOMANuApIk2aii-a2HIgZzZH8UpEhs84va30,23167
11
- sumo_wrapper_python-1.7.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
- sumo_wrapper_python-1.7.0.dist-info/METADATA,sha256=iONTtIeFvEqGTsGU6UJpm_7l4eQzaMFILoH9hvCncMQ,14615
13
- sumo_wrapper_python-1.7.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
14
- sumo_wrapper_python-1.7.0.dist-info/entry_points.txt,sha256=V_vGky2C3He5vohJAxnBdvpt_fqfUDFj5irUm9HtoFc,55
15
- sumo_wrapper_python-1.7.0.dist-info/top_level.txt,sha256=rLbKyH9rWgCj3PoLeR7fvC5X8vCaUc5LF8-Y_GBWZL0,5
16
- sumo_wrapper_python-1.7.0.dist-info/RECORD,,