sumo-wrapper-python 1.6.1__tar.gz → 1.8.0__tar.gz

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.
Files changed (46) hide show
  1. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/PKG-INFO +1 -1
  2. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/_logging.py +3 -0
  3. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/_retry_strategy.py +10 -3
  4. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/_version.py +3 -3
  5. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/sumo_client.py +60 -18
  6. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo_wrapper_python.egg-info/PKG-INFO +1 -1
  7. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/.github/pull_request_template.md +0 -0
  8. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/.github/workflows/build_docs.yaml +0 -0
  9. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/.github/workflows/linting.yml +0 -0
  10. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/.github/workflows/publish_release.yml +0 -0
  11. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/.github/workflows/pytest.yml +0 -0
  12. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/.gitignore +0 -0
  13. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/.pre-commit-config.yaml +0 -0
  14. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/.readthedocs.yaml +0 -0
  15. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/CONTRIBUTING.md +0 -0
  16. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/LICENSE +0 -0
  17. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/README.md +0 -0
  18. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/SECURITY.md +0 -0
  19. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/Makefile +0 -0
  20. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/_static/equinor-logo.png +0 -0
  21. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/_static/equinor-logo2.jpg +0 -0
  22. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/_static/equinor_logo.jpg +0 -0
  23. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/_static/equinor_logo_only.jpg +0 -0
  24. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/_templates/layout.html +0 -0
  25. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/api.rst +0 -0
  26. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/conf.py +0 -0
  27. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/index.rst +0 -0
  28. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/make.bat +0 -0
  29. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/docs/sumo-wrapper-python.rst +0 -0
  30. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/pyproject.toml +0 -0
  31. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/setup.cfg +0 -0
  32. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/__init__.py +0 -0
  33. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/__init__.py +0 -0
  34. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/_auth_provider.py +0 -0
  35. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/_blob_client.py +0 -0
  36. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/_decorators.py +0 -0
  37. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo/wrapper/login.py +0 -0
  38. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo_wrapper_python.egg-info/SOURCES.txt +0 -0
  39. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
  40. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
  41. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo_wrapper_python.egg-info/requires.txt +0 -0
  42. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
  43. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/tests/conftest.py +0 -0
  44. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/tests/test_sumo_thin_client.py +0 -0
  45. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/tests/testdata/case.yml +0 -0
  46. {sumo_wrapper_python-1.6.1 → sumo_wrapper_python-1.8.0}/tests/testdata/surface.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sumo-wrapper-python
3
- Version: 1.6.1
3
+ Version: 1.8.0
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -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
  )
@@ -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.6.1'
22
- __version_tuple__ = version_tuple = (1, 6, 1)
21
+ __version__ = version = '1.8.0'
22
+ __version_tuple__ = version_tuple = (1, 8, 0)
23
23
 
24
- __commit_id__ = commit_id = 'g298e73c63'
24
+ __commit_id__ = commit_id = 'gd3b39bc3e'
@@ -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:
@@ -522,7 +542,7 @@ class SumoClient:
522
542
  ).text
523
543
  self.auth.store_shared_access_key_for_case(case_uuid, token)
524
544
 
525
- def client_for_case(self, case_uuid):
545
+ def client_for_case(self, case_uuid, interactive=False):
526
546
  """Instantiate and return new SumoClient for accessing the
527
547
  case identified by *case_uuid*."""
528
548
  if self.auth.has_case_token(case_uuid):
@@ -532,13 +552,17 @@ class SumoClient:
532
552
  retry_strategy=self._retry_strategy,
533
553
  timeout=self._timeout,
534
554
  case_uuid=case_uuid,
555
+ interactive=interactive,
535
556
  )
536
557
  else:
537
558
  return self
538
559
 
539
560
  @raise_for_status_async
540
561
  async def get_async(
541
- self, path: str, params: Optional[dict] = None
562
+ self,
563
+ path: str,
564
+ params: Optional[dict] = None,
565
+ retry_strategy: Optional[RetryStrategy] = None,
542
566
  ) -> httpx.Response:
543
567
  """Performs an async GET-request to the Sumo API.
544
568
 
@@ -597,7 +621,9 @@ class SumoClient:
597
621
  timeout=self._timeout,
598
622
  )
599
623
 
600
- retryer = self._retry_strategy.make_retryer_async()
624
+ retryer = (
625
+ retry_strategy if retry_strategy else self._retry_strategy
626
+ ).make_retryer_async()
601
627
 
602
628
  return await retryer(_get)
603
629
 
@@ -608,6 +634,7 @@ class SumoClient:
608
634
  blob: Optional[bytes] = None,
609
635
  json: Optional[dict] = None,
610
636
  params: Optional[dict] = None,
637
+ retry_strategy: Optional[RetryStrategy] = None,
611
638
  ) -> httpx.Response:
612
639
  """Performs an async POST-request to the Sumo API.
613
640
 
@@ -673,7 +700,9 @@ class SumoClient:
673
700
  timeout=self._timeout,
674
701
  )
675
702
 
676
- retryer = self._retry_strategy.make_retryer_async()
703
+ retryer = (
704
+ retry_strategy if retry_strategy else self._retry_strategy
705
+ ).make_retryer_async()
677
706
 
678
707
  return await retryer(_post)
679
708
 
@@ -683,6 +712,7 @@ class SumoClient:
683
712
  path: str,
684
713
  blob: Optional[bytes] = None,
685
714
  json: Optional[dict] = None,
715
+ retry_strategy: Optional[RetryStrategy] = None,
686
716
  ) -> httpx.Response:
687
717
  """Performs an async PUT-request to the Sumo API.
688
718
 
@@ -722,13 +752,18 @@ class SumoClient:
722
752
  timeout=self._timeout,
723
753
  )
724
754
 
725
- retryer = self._retry_strategy.make_retryer_async()
755
+ retryer = (
756
+ retry_strategy if retry_strategy else self._retry_strategy
757
+ ).make_retryer_async()
726
758
 
727
759
  return await retryer(_put)
728
760
 
729
761
  @raise_for_status_async
730
762
  async def delete_async(
731
- self, path: str, params: Optional[dict] = None
763
+ self,
764
+ path: str,
765
+ params: Optional[dict] = None,
766
+ retry_strategy: Optional[RetryStrategy] = None,
732
767
  ) -> httpx.Response:
733
768
  """Performs an async DELETE-request to the Sumo API.
734
769
 
@@ -762,12 +797,17 @@ class SumoClient:
762
797
  timeout=self._timeout,
763
798
  )
764
799
 
765
- retryer = self._retry_strategy.make_retryer_async()
800
+ retryer = (
801
+ retry_strategy if retry_strategy else self._retry_strategy
802
+ ).make_retryer_async()
766
803
 
767
804
  return await retryer(_delete)
768
805
 
769
806
  async def poll_async(
770
- self, response_in: httpx.Response, timeout=None
807
+ self,
808
+ response_in: httpx.Response,
809
+ timeout=None,
810
+ retry_strategy: Optional[RetryStrategy] = None,
771
811
  ) -> httpx.Response:
772
812
  """Poll a specific endpoint until a result is obtained.
773
813
 
@@ -781,7 +821,9 @@ class SumoClient:
781
821
  expiry = time.time() + timeout if timeout is not None else None
782
822
  while True:
783
823
  await asyncio.sleep(retry_after)
784
- response = await self.get_async(location)
824
+ response = await self.get_async(
825
+ location, retry_strategy=retry_strategy
826
+ )
785
827
  if response.status_code != 202:
786
828
  return response
787
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.6.1
3
+ Version: 1.8.0
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License