ingestr 0.6.2__py3-none-any.whl → 0.6.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.

Potentially problematic release.


This version of ingestr might be problematic. Click here for more details.

@@ -1,5 +1,6 @@
1
1
  """Gorgias source helpers"""
2
2
 
3
+ import time
3
4
  from typing import Any, Iterable, Optional, Tuple
4
5
 
5
6
  from dlt.common.pendulum import pendulum
@@ -9,6 +10,8 @@ from dlt.sources.helpers import requests
9
10
  from pyrate_limiter import Duration, Limiter, Rate
10
11
  from requests.auth import HTTPBasicAuth
11
12
 
13
+ RETRY_COUNT = 10
14
+
12
15
 
13
16
  def get_max_datetime_from_datetime_fields(
14
17
  item: Dict[str, Any],
@@ -104,10 +107,24 @@ class GorgiasApi:
104
107
 
105
108
  while True:
106
109
  limiter.try_acquire(f"gorgias-{self.domain}")
107
- response = requests.get(
108
- url, params=params, auth=HTTPBasicAuth(self.email, self.api_key)
109
- )
110
- response.raise_for_status()
110
+
111
+ # this is to retry a back-off if we get a 429
112
+ for i in range(RETRY_COUNT):
113
+ try:
114
+ response = requests.get(
115
+ url, params=params, auth=HTTPBasicAuth(self.email, self.api_key)
116
+ )
117
+ except Exception as e:
118
+ retry_after = int(response.headers.get("Retry-After", 10))
119
+ print(
120
+ f"Got an error from Gorgias API, retrying after {retry_after} seconds",
121
+ e,
122
+ )
123
+ time.sleep(retry_after)
124
+ continue
125
+
126
+ break
127
+
111
128
  if len(response.json()["data"]) == 0:
112
129
  break
113
130
 
ingestr/src/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.6.2"
1
+ __version__ = "0.6.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ingestr
3
- Version: 0.6.2
3
+ Version: 0.6.4
4
4
  Summary: ingestr is a command-line application that ingests data from various sources and stores them in any database.
5
5
  Project-URL: Homepage, https://github.com/bruin-data/ingestr
6
6
  Project-URL: Issues, https://github.com/bruin-data/ingestr/issues
@@ -6,14 +6,14 @@ ingestr/src/factory.py,sha256=7skwetBXFIwAuKyTFfffGPgSo_PRRZ5uEnxOHUv28yQ,3517
6
6
  ingestr/src/factory_test.py,sha256=X9sFkvNByWChIcyeDt1QiIPMIzGNKb7M5A_GUE0-nnI,664
7
7
  ingestr/src/sources.py,sha256=v0oFu-Pt_Zv06FypBb9_rHKP_iIMpkgm9MMaVpOUjPg,10313
8
8
  ingestr/src/sources_test.py,sha256=t94u1lYAspxzfe-DkxVtq5vw6xrLWphipvwntrwrzqg,3930
9
- ingestr/src/version.py,sha256=jFlbxEJFS0G44LE-yXXVSwXACA1J_NyYDk5E20_2zpc,22
9
+ ingestr/src/version.py,sha256=WMmvm2Keb76yMz8OL_h4fKT34Xpi-1BVfCiTn2QGzz4,22
10
10
  ingestr/src/google_sheets/README.md,sha256=wFQhvmGpRA38Ba2N_WIax6duyD4c7c_pwvvprRfQDnw,5470
11
11
  ingestr/src/google_sheets/__init__.py,sha256=5qlX-6ilx5MW7klC7B_0jGSxloQSLkSESTh4nlY3Aos,6643
12
12
  ingestr/src/google_sheets/helpers/__init__.py,sha256=5hXZrZK8cMO3UOuL-s4OKOpdACdihQD0hYYlSEu-iQ8,35
13
13
  ingestr/src/google_sheets/helpers/api_calls.py,sha256=RiVfdacbaneszhmuhYilkJnkc9kowZvQUCUxz0G6SlI,5404
14
14
  ingestr/src/google_sheets/helpers/data_processing.py,sha256=WYO6z4XjGcG0Hat2J2enb-eLX5mSNVb2vaqRE83FBWU,11000
15
15
  ingestr/src/gorgias/__init__.py,sha256=iASGYJhdx6yZ0uDgIaQQfW91l3p0XOhowalIByLFkvw,21228
16
- ingestr/src/gorgias/helpers.py,sha256=dQ56CpZJobBVZP-vCM56vKHZdrfCHqla5peUt0bVr1c,4905
16
+ ingestr/src/gorgias/helpers.py,sha256=DamuijnvhGY9hysQO4txrVMf4izkGbh5qfBKImdOINE,5427
17
17
  ingestr/src/gorgias/helpers_test.py,sha256=kSR2nhB8U8HZ8pgDnd7HvXlzojmBnpOm8fTKHJvvKGY,1580
18
18
  ingestr/src/mongodb/__init__.py,sha256=E7SDeCyYNkYZZ_RFhjCRDZUGpKtaxpPG5sFSmKJV62U,4336
19
19
  ingestr/src/mongodb/helpers.py,sha256=80vtAeNyUn1iMN0CeLrTlKqYN6I6fHF81Kd2UuE8Kns,5653
@@ -40,8 +40,8 @@ ingestr/testdata/delete_insert_part2.csv,sha256=B_KUzpzbNdDY_n7wWop1mT2cz36TmayS
40
40
  ingestr/testdata/merge_expected.csv,sha256=DReHqWGnQMsf2PBv_Q2pfjsgvikYFnf1zYcQZ7ZqYN0,276
41
41
  ingestr/testdata/merge_part1.csv,sha256=Pw8Z9IDKcNU0qQHx1z6BUf4rF_-SxKGFOvymCt4OY9I,185
42
42
  ingestr/testdata/merge_part2.csv,sha256=T_GiWxA81SN63_tMOIuemcvboEFeAmbKc7xRXvL9esw,287
43
- ingestr-0.6.2.dist-info/METADATA,sha256=UitFFYGnAlTIH9cR6_fSynXNnUsa9YVDxfvXVvkujq8,5699
44
- ingestr-0.6.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
45
- ingestr-0.6.2.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
46
- ingestr-0.6.2.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
47
- ingestr-0.6.2.dist-info/RECORD,,
43
+ ingestr-0.6.4.dist-info/METADATA,sha256=P9HvhFDdyABsqWup6JK4-LgdaCDH_UBvTByLtFvxbW4,5699
44
+ ingestr-0.6.4.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
45
+ ingestr-0.6.4.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
46
+ ingestr-0.6.4.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
47
+ ingestr-0.6.4.dist-info/RECORD,,