events-sdk-python 0.0.3__py2.py3-none-any.whl → 0.0.4__py2.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.
- {events_sdk_python-0.0.3.dist-info → events_sdk_python-0.0.4.dist-info}/METADATA +9 -8
- {events_sdk_python-0.0.3.dist-info → events_sdk_python-0.0.4.dist-info}/RECORD +8 -8
- {events_sdk_python-0.0.3.dist-info → events_sdk_python-0.0.4.dist-info}/WHEEL +1 -1
- hightouch/htevents/consumer.py +6 -2
- hightouch/htevents/test/consumer.py +77 -0
- hightouch/htevents/version.py +1 -1
- {events_sdk_python-0.0.3.dist-info → events_sdk_python-0.0.4.dist-info/licenses}/LICENSE +0 -0
- {events_sdk_python-0.0.3.dist-info → events_sdk_python-0.0.4.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: events-sdk-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: Events SDK Python for Hightouch event collection.
|
|
5
5
|
Author-email: Hightouch <engineering@hightouch.com>
|
|
6
6
|
License: MIT License
|
|
@@ -64,14 +64,15 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
64
64
|
Requires-Python: >=3.6
|
|
65
65
|
Description-Content-Type: text/markdown
|
|
66
66
|
License-File: LICENSE
|
|
67
|
-
Requires-Dist: requests
|
|
68
|
-
Requires-Dist: backoff
|
|
69
|
-
Requires-Dist: python-dateutil
|
|
70
|
-
Requires-Dist: PyJWT
|
|
67
|
+
Requires-Dist: requests~=2.7
|
|
68
|
+
Requires-Dist: backoff~=2.1
|
|
69
|
+
Requires-Dist: python-dateutil~=2.2
|
|
70
|
+
Requires-Dist: PyJWT<3.0,>=2.0
|
|
71
71
|
Requires-Dist: pyjwt[crypto]
|
|
72
72
|
Provides-Extra: dev
|
|
73
|
-
Requires-Dist: mock
|
|
74
|
-
Requires-Dist: ruff
|
|
73
|
+
Requires-Dist: mock==2.0.0; extra == "dev"
|
|
74
|
+
Requires-Dist: ruff==0.1.4; extra == "dev"
|
|
75
|
+
Dynamic: license-file
|
|
75
76
|
|
|
76
77
|
# Events SDK Python
|
|
77
78
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
events_sdk_python-0.0.4.dist-info/licenses/LICENSE,sha256=mb53FUjQUfpzcRsGM-kXz_XQJ1x3kfRrrUhua2vN8lE,2166
|
|
1
2
|
hightouch/htevents/__init__.py,sha256=lM8kU9UhhRcEMFCGgNfvlJ4G1LGwjCNoKBB8fRwDR6I,2587
|
|
2
3
|
hightouch/htevents/client.py,sha256=li8kcmU9sXRi--m5mSzZ5lMTXEItlVK6_m-GACWa-1M,12969
|
|
3
|
-
hightouch/htevents/consumer.py,sha256=
|
|
4
|
+
hightouch/htevents/consumer.py,sha256=bNVyND2TKd-tySA6XCcy9PosjQerAMptMZXGavicY3o,5068
|
|
4
5
|
hightouch/htevents/oauth_manager.py,sha256=gzlnBcKwh5d-O1PLgrmu_1QMwkuBQmU82QpwirvWh_E,9998
|
|
5
6
|
hightouch/htevents/request.py,sha256=k8ymfYsAK1NgzaPC5PjELkGE9YvqsjCT2BRew_RrilM,2983
|
|
6
7
|
hightouch/htevents/utils.py,sha256=h6bG00qRc6ZPYXxqNMZGt9ob_pZrifiFNfdrFKsyXHQ,2463
|
|
7
|
-
hightouch/htevents/version.py,sha256
|
|
8
|
+
hightouch/htevents/version.py,sha256=_AMCRx0HPnXtG7NMWq5H0EWKj6knJPeJdG7gXs-3sBI,18
|
|
8
9
|
hightouch/htevents/test/__init__.py,sha256=yqXsMtFca5oCT_ngdOXumKFFQfMkT0-hq-ImOSQhc0g,2862
|
|
9
10
|
hightouch/htevents/test/client.py,sha256=HuOSDmwhzgGwalFrWez_B5s4ugAk67GzA48_73QTYMI,13655
|
|
10
11
|
hightouch/htevents/test/constants.py,sha256=gyP7NcJL4OKnOwTAdD2W9yKxpVZcNFy-YmE_pkzlqW4,427
|
|
11
|
-
hightouch/htevents/test/consumer.py,sha256
|
|
12
|
+
hightouch/htevents/test/consumer.py,sha256=mu6GSFUTiPTCR1v0Hb5L7_qzZ-do3SB8SeXnIwoMIGc,9965
|
|
12
13
|
hightouch/htevents/test/module.py,sha256=CJTKjMGF40q00DupaC18TUEHqQpa7ReUe8karSMQpkE,1197
|
|
13
14
|
hightouch/htevents/test/oauth.py,sha256=CelWqVca5BZ0Y0F5Uy1jZpWPtLzSFJWYk6_-FOKbxRE,8988
|
|
14
15
|
hightouch/htevents/test/request.py,sha256=VHgQD_Hg6sOmcs7wF5RftYxCBCPc9lUxhmEEJC-4zX8,2264
|
|
15
16
|
hightouch/htevents/test/utils.py,sha256=oQBtiU1zOwTl06xAvxKieCpIYr4dSfGNkXderUTaezs,2153
|
|
16
|
-
events_sdk_python-0.0.
|
|
17
|
-
events_sdk_python-0.0.
|
|
18
|
-
events_sdk_python-0.0.
|
|
19
|
-
events_sdk_python-0.0.
|
|
20
|
-
events_sdk_python-0.0.3.dist-info/RECORD,,
|
|
17
|
+
events_sdk_python-0.0.4.dist-info/METADATA,sha256=MW0k9spq3z-wEgF09_mMPrrm0Kz4kBBj8H7_VDgzYEI,5150
|
|
18
|
+
events_sdk_python-0.0.4.dist-info/WHEEL,sha256=4YBfCYNH4wlLpv3pzq1hbEuIlXA4WJabKLFurZ7eTL0,109
|
|
19
|
+
events_sdk_python-0.0.4.dist-info/top_level.txt,sha256=Z93PhJFjV-hVq01IydzU1oJWFGISSGq5-iV1AULWBy0,10
|
|
20
|
+
events_sdk_python-0.0.4.dist-info/RECORD,,
|
hightouch/htevents/consumer.py
CHANGED
|
@@ -90,12 +90,16 @@ class Consumer(Thread):
|
|
|
90
90
|
self.log.error('error uploading: %s', e)
|
|
91
91
|
success = False
|
|
92
92
|
if self.on_error:
|
|
93
|
-
|
|
93
|
+
try:
|
|
94
|
+
self.on_error(e, batch)
|
|
95
|
+
except Exception:
|
|
96
|
+
# A raising callback must not kill the consumer thread.
|
|
97
|
+
self.log.exception('error in on_error callback')
|
|
94
98
|
finally:
|
|
95
99
|
# mark items as acknowledged from queue
|
|
96
100
|
for _ in batch:
|
|
97
101
|
self.queue.task_done()
|
|
98
|
-
|
|
102
|
+
return success
|
|
99
103
|
|
|
100
104
|
def next(self):
|
|
101
105
|
"""Return the next batch of items to upload."""
|
|
@@ -49,6 +49,83 @@ class TestConsumer(unittest.TestCase):
|
|
|
49
49
|
success = consumer.upload()
|
|
50
50
|
self.assertTrue(success)
|
|
51
51
|
|
|
52
|
+
def test_upload_failure_returns_false_and_acks_queue(self):
|
|
53
|
+
q = Queue()
|
|
54
|
+
consumer = Consumer(q, TEST_WRITE_KEY)
|
|
55
|
+
track = {'type': 'track', 'event': 'python event', 'userId': 'userId'}
|
|
56
|
+
q.put(track)
|
|
57
|
+
with mock.patch.object(
|
|
58
|
+
consumer, 'request', side_effect=Exception('upload failed')
|
|
59
|
+
):
|
|
60
|
+
success = consumer.upload()
|
|
61
|
+
self.assertFalse(success)
|
|
62
|
+
self.assertTrue(q.empty())
|
|
63
|
+
q.join()
|
|
64
|
+
|
|
65
|
+
def test_on_error_called_on_upload_failure(self):
|
|
66
|
+
q = Queue()
|
|
67
|
+
errors = []
|
|
68
|
+
|
|
69
|
+
def on_error(error, batch):
|
|
70
|
+
errors.append((error, batch))
|
|
71
|
+
|
|
72
|
+
consumer = Consumer(q, TEST_WRITE_KEY, on_error=on_error)
|
|
73
|
+
track = {'type': 'track', 'event': 'python event', 'userId': 'userId'}
|
|
74
|
+
q.put(track)
|
|
75
|
+
upload_error = Exception('upload failed')
|
|
76
|
+
with mock.patch.object(consumer, 'request', side_effect=upload_error):
|
|
77
|
+
success = consumer.upload()
|
|
78
|
+
self.assertFalse(success)
|
|
79
|
+
self.assertEqual(len(errors), 1)
|
|
80
|
+
self.assertIs(errors[0][0], upload_error)
|
|
81
|
+
self.assertEqual(errors[0][1], [track])
|
|
82
|
+
q.join()
|
|
83
|
+
|
|
84
|
+
def test_on_error_exception_does_not_propagate(self):
|
|
85
|
+
q = Queue()
|
|
86
|
+
|
|
87
|
+
def on_error(error, batch):
|
|
88
|
+
raise RuntimeError('callback failed')
|
|
89
|
+
|
|
90
|
+
consumer = Consumer(q, TEST_WRITE_KEY, on_error=on_error)
|
|
91
|
+
track = {'type': 'track', 'event': 'python event', 'userId': 'userId'}
|
|
92
|
+
q.put(track)
|
|
93
|
+
with mock.patch.object(
|
|
94
|
+
consumer, 'request', side_effect=Exception('upload failed')
|
|
95
|
+
):
|
|
96
|
+
# Capture logs so the intentional traceback is not emitted to
|
|
97
|
+
# stderr (GitHub Actions would annotate it as a check failure).
|
|
98
|
+
with self.assertLogs('hightouch', level='ERROR') as logs:
|
|
99
|
+
success = consumer.upload()
|
|
100
|
+
self.assertFalse(success)
|
|
101
|
+
self.assertTrue(q.empty())
|
|
102
|
+
q.join()
|
|
103
|
+
self.assertTrue(
|
|
104
|
+
any('error in on_error callback' in message for message in logs.output)
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
def test_on_error_exception_does_not_stop_consumer(self):
|
|
108
|
+
q = Queue()
|
|
109
|
+
|
|
110
|
+
def on_error(error, batch):
|
|
111
|
+
raise RuntimeError('callback failed')
|
|
112
|
+
|
|
113
|
+
consumer = Consumer(
|
|
114
|
+
q, TEST_WRITE_KEY, on_error=on_error, retries=0, upload_interval=0.1
|
|
115
|
+
)
|
|
116
|
+
with mock.patch(
|
|
117
|
+
'hightouch.htevents.consumer.post', side_effect=Exception('upload failed')
|
|
118
|
+
):
|
|
119
|
+
with self.assertLogs('hightouch', level='ERROR'):
|
|
120
|
+
consumer.start()
|
|
121
|
+
q.put({'type': 'track', 'event': 'e1', 'userId': 'userId'})
|
|
122
|
+
q.join()
|
|
123
|
+
q.put({'type': 'track', 'event': 'e2', 'userId': 'userId'})
|
|
124
|
+
q.join()
|
|
125
|
+
self.assertTrue(consumer.is_alive())
|
|
126
|
+
consumer.pause()
|
|
127
|
+
consumer.join(timeout=2)
|
|
128
|
+
|
|
52
129
|
def test_upload_interval(self):
|
|
53
130
|
# Put _n_ items in the queue, pausing a little bit more than
|
|
54
131
|
# _upload_interval_ after each one.
|
hightouch/htevents/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.0.
|
|
1
|
+
VERSION = '0.0.4'
|
|
File without changes
|
|
File without changes
|