airbyte-source-github 1.8.35.dev202507171002__py3-none-any.whl → 1.8.36.dev202507211247__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.
- {airbyte_source_github-1.8.35.dev202507171002.dist-info → airbyte_source_github-1.8.36.dev202507211247.dist-info}/METADATA +1 -1
- {airbyte_source_github-1.8.35.dev202507171002.dist-info → airbyte_source_github-1.8.36.dev202507211247.dist-info}/RECORD +6 -6
- source_github/backoff_strategies.py +15 -16
- source_github/utils.py +13 -2
- {airbyte_source_github-1.8.35.dev202507171002.dist-info → airbyte_source_github-1.8.36.dev202507211247.dist-info}/WHEEL +0 -0
- {airbyte_source_github-1.8.35.dev202507171002.dist-info → airbyte_source_github-1.8.36.dev202507211247.dist-info}/entry_points.txt +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
source_github/__init__.py,sha256=punPc3v0mXEYOun7cbkfM5KUhgjv72B9DgDhI4VtzcQ,1134
|
|
2
|
-
source_github/backoff_strategies.py,sha256=
|
|
2
|
+
source_github/backoff_strategies.py,sha256=0BWPR4_EtguVIIhN1-_fsPExiGs40FuXrtK_4qxHeKg,2936
|
|
3
3
|
source_github/config_migrations.py,sha256=H58hHqAnuvb0B8IXHW4aEDZ3HotEg7HdA2rXDG9XW7A,3832
|
|
4
4
|
source_github/constants.py,sha256=Hj3Q4y7OoU-Iff4m9gEC2CjwmWJYXhNbHVNjg8EBLmQ,238
|
|
5
5
|
source_github/errors_handlers.py,sha256=POqpvbrNAoZztjwByOJxJbIaxhWC8KWLi3gK1WzbiK8,7259
|
|
@@ -57,8 +57,8 @@ source_github/schemas/workflows.json,sha256=gSNw8WZaVKbX4AL97PbjZHzvxcOltXqv9Ao1
|
|
|
57
57
|
source_github/source.py,sha256=1o8eayigi4xSUeNHdCd-mhNswGUq_XQrVk2eihTjm1o,14246
|
|
58
58
|
source_github/spec.json,sha256=7LOQm01fP_RvPF-HifhNPJ7i0AxT2LTNPaLAA3uOfNY,7443
|
|
59
59
|
source_github/streams.py,sha256=h5YMPLIsLTv7WX_mcURVC2LmmWBLraZvKH8J_GzV1IE,77441
|
|
60
|
-
source_github/utils.py,sha256=
|
|
61
|
-
airbyte_source_github-1.8.
|
|
62
|
-
airbyte_source_github-1.8.
|
|
63
|
-
airbyte_source_github-1.8.
|
|
64
|
-
airbyte_source_github-1.8.
|
|
60
|
+
source_github/utils.py,sha256=SzjCYAOOtpzmpj7A3KOAMSlY-v2HSWOXOWUjxOk2Ges,5959
|
|
61
|
+
airbyte_source_github-1.8.36.dev202507211247.dist-info/METADATA,sha256=NS3dCMe40d7sDPv3VEiGAp8__vLr6nGGKRb_hjhiEAk,5218
|
|
62
|
+
airbyte_source_github-1.8.36.dev202507211247.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
63
|
+
airbyte_source_github-1.8.36.dev202507211247.dist-info/entry_points.txt,sha256=gYhqVrTAZvMwuYByg0b_-o115yUFLLcfNxMrLZmiW9k,55
|
|
64
|
+
airbyte_source_github-1.8.36.dev202507211247.dist-info/RECORD,,
|
|
@@ -9,15 +9,12 @@ import requests
|
|
|
9
9
|
|
|
10
10
|
from airbyte_cdk import BackoffStrategy
|
|
11
11
|
from airbyte_cdk.sources.streams.http import HttpStream
|
|
12
|
-
from airbyte_cdk.utils import AirbyteTracedException
|
|
13
|
-
from airbyte_protocol.models import FailureType
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
class GithubStreamABCBackoffStrategy(BackoffStrategy):
|
|
17
15
|
min_backoff_time = 60.0
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
max_seconds_between_messages = 3600.0
|
|
16
|
+
# https://docs.github.com/en/rest/using-the-rest-api/troubleshooting-the-rest-api?apiVersion=2022-11-28
|
|
17
|
+
RATE_LIMITS_STATUS_CODES = [403, 429]
|
|
21
18
|
|
|
22
19
|
def __init__(self, stream: HttpStream, **kwargs): # type: ignore # noqa
|
|
23
20
|
self.stream = stream
|
|
@@ -33,26 +30,28 @@ class GithubStreamABCBackoffStrategy(BackoffStrategy):
|
|
|
33
30
|
retry_after = response_or_exception.headers.get("Retry-After")
|
|
34
31
|
if retry_after is not None:
|
|
35
32
|
backoff_time_in_seconds = max(float(retry_after), self.min_backoff_time)
|
|
36
|
-
return self.get_waiting_time(backoff_time_in_seconds)
|
|
33
|
+
return self.get_waiting_time(backoff_time_in_seconds, response_or_exception)
|
|
37
34
|
|
|
38
35
|
reset_time = response_or_exception.headers.get("X-RateLimit-Reset")
|
|
39
36
|
if reset_time:
|
|
40
37
|
backoff_time_in_seconds = max(float(reset_time) - time.time(), self.min_backoff_time)
|
|
41
|
-
return self.get_waiting_time(backoff_time_in_seconds)
|
|
38
|
+
return self.get_waiting_time(backoff_time_in_seconds, response_or_exception)
|
|
42
39
|
return None
|
|
43
40
|
|
|
44
|
-
def get_waiting_time(self, backoff_time_in_seconds: float) -> Optional[float]:
|
|
41
|
+
def get_waiting_time(self, backoff_time_in_seconds: float, response: requests.Response) -> Optional[float]:
|
|
45
42
|
if backoff_time_in_seconds < 60 * 10: # type: ignore[operator]
|
|
46
43
|
return backoff_time_in_seconds
|
|
47
|
-
elif backoff_time_in_seconds > self.max_seconds_between_messages:
|
|
48
|
-
raise AirbyteTracedException(
|
|
49
|
-
internal_message="Waiting time from header is too long.",
|
|
50
|
-
message=f"The stream {self.stream.name} have faced rate limits, but waiting time is too long. The stream will sync data in the next sync when rate limits are refreshed.",
|
|
51
|
-
failure_type=FailureType.transient_error,
|
|
52
|
-
)
|
|
53
44
|
else:
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
# New token will be used in the next request or fail if all tokens are exhausted
|
|
46
|
+
if response.status_code in self.RATE_LIMITS_STATUS_CODES:
|
|
47
|
+
self.stream._http_client._session.auth.find_available_token(response.request)
|
|
48
|
+
else:
|
|
49
|
+
self.stream._http_client._session.auth.update_token()
|
|
50
|
+
|
|
51
|
+
# update headers in the request itself so the next request will use new token
|
|
52
|
+
response.request.headers.update(self.stream._http_client._session.auth.get_auth_header())
|
|
53
|
+
|
|
54
|
+
return 1
|
|
56
55
|
|
|
57
56
|
|
|
58
57
|
class ContributorActivityBackoffStrategy(BackoffStrategy):
|
source_github/utils.py
CHANGED
|
@@ -76,8 +76,14 @@ class MultipleTokenAuthenticatorWithRateLimiter(AbstractHeaderAuthenticator):
|
|
|
76
76
|
return {self.auth_header: self.token}
|
|
77
77
|
return {}
|
|
78
78
|
|
|
79
|
-
def
|
|
80
|
-
"""
|
|
79
|
+
def find_available_token(self, request: requests.Request):
|
|
80
|
+
"""
|
|
81
|
+
Iterates over each provided token and check their availability.
|
|
82
|
+
If no tokens are available or reset time is more than 10 minutes, an error is raised.
|
|
83
|
+
Method process_token() returns True is current token is available,
|
|
84
|
+
otherwise goes to the next token and sets it as current and checks for availability.
|
|
85
|
+
"""
|
|
86
|
+
|
|
81
87
|
while True:
|
|
82
88
|
current_token = self._tokens[self.current_active_token]
|
|
83
89
|
if "graphql" in request.path_url:
|
|
@@ -87,6 +93,11 @@ class MultipleTokenAuthenticatorWithRateLimiter(AbstractHeaderAuthenticator):
|
|
|
87
93
|
if self.process_token(current_token, "count_rest", "reset_at_rest"):
|
|
88
94
|
break
|
|
89
95
|
|
|
96
|
+
def __call__(self, request):
|
|
97
|
+
"""Attach the HTTP headers required to authenticate on the HTTP request"""
|
|
98
|
+
|
|
99
|
+
self.find_available_token(request)
|
|
100
|
+
|
|
90
101
|
request.headers.update(self.get_auth_header())
|
|
91
102
|
|
|
92
103
|
return request
|
|
File without changes
|