events-sdk-python 0.0.2__tar.gz → 0.0.4__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 (26) hide show
  1. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/PKG-INFO +5 -4
  2. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/events_sdk_python.egg-info/PKG-INFO +5 -4
  3. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/events_sdk_python.egg-info/requires.txt +2 -2
  4. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/consumer.py +6 -2
  5. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/test/consumer.py +77 -0
  6. events_sdk_python-0.0.4/hightouch/htevents/version.py +1 -0
  7. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/pyproject.toml +3 -3
  8. events-sdk-python-0.0.2/hightouch/htevents/version.py +0 -1
  9. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/LICENSE +0 -0
  10. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/README.md +0 -0
  11. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/events_sdk_python.egg-info/SOURCES.txt +0 -0
  12. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/events_sdk_python.egg-info/dependency_links.txt +0 -0
  13. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/events_sdk_python.egg-info/top_level.txt +0 -0
  14. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/__init__.py +0 -0
  15. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/client.py +0 -0
  16. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/oauth_manager.py +0 -0
  17. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/request.py +0 -0
  18. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/test/__init__.py +0 -0
  19. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/test/client.py +0 -0
  20. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/test/constants.py +0 -0
  21. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/test/module.py +0 -0
  22. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/test/oauth.py +0 -0
  23. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/test/request.py +0 -0
  24. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/test/utils.py +0 -0
  25. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/hightouch/htevents/utils.py +0 -0
  26. {events-sdk-python-0.0.2 → events_sdk_python-0.0.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: events-sdk-python
3
- Version: 0.0.2
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
@@ -67,11 +67,12 @@ License-File: LICENSE
67
67
  Requires-Dist: requests~=2.7
68
68
  Requires-Dist: backoff~=2.1
69
69
  Requires-Dist: python-dateutil~=2.2
70
+ Requires-Dist: PyJWT<3.0,>=2.0
71
+ Requires-Dist: pyjwt[crypto]
70
72
  Provides-Extra: dev
71
- Requires-Dist: PyJWT~=2.8; extra == "dev"
72
- Requires-Dist: pyjwt[crypto]; extra == "dev"
73
73
  Requires-Dist: mock==2.0.0; extra == "dev"
74
74
  Requires-Dist: ruff==0.1.4; extra == "dev"
75
+ Dynamic: license-file
75
76
 
76
77
  # Events SDK Python
77
78
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: events-sdk-python
3
- Version: 0.0.2
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
@@ -67,11 +67,12 @@ License-File: LICENSE
67
67
  Requires-Dist: requests~=2.7
68
68
  Requires-Dist: backoff~=2.1
69
69
  Requires-Dist: python-dateutil~=2.2
70
+ Requires-Dist: PyJWT<3.0,>=2.0
71
+ Requires-Dist: pyjwt[crypto]
70
72
  Provides-Extra: dev
71
- Requires-Dist: PyJWT~=2.8; extra == "dev"
72
- Requires-Dist: pyjwt[crypto]; extra == "dev"
73
73
  Requires-Dist: mock==2.0.0; extra == "dev"
74
74
  Requires-Dist: ruff==0.1.4; extra == "dev"
75
+ Dynamic: license-file
75
76
 
76
77
  # Events SDK Python
77
78
 
@@ -1,9 +1,9 @@
1
1
  requests~=2.7
2
2
  backoff~=2.1
3
3
  python-dateutil~=2.2
4
+ PyJWT<3.0,>=2.0
5
+ pyjwt[crypto]
4
6
 
5
7
  [dev]
6
- PyJWT~=2.8
7
- pyjwt[crypto]
8
8
  mock==2.0.0
9
9
  ruff==0.1.4
@@ -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
- self.on_error(e, batch)
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
- return success
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.
@@ -0,0 +1 @@
1
+ VERSION = '0.0.4'
@@ -8,7 +8,7 @@ include = ["hightouch*"]
8
8
 
9
9
  [project]
10
10
  name = "events-sdk-python"
11
- version = "0.0.2"
11
+ version = "0.0.4"
12
12
  description = "Events SDK Python for Hightouch event collection."
13
13
  readme = "README.md"
14
14
  authors = [{ name = "Hightouch", email = "engineering@hightouch.com" }]
@@ -31,13 +31,13 @@ dependencies = [
31
31
  "requests~=2.7",
32
32
  "backoff~=2.1",
33
33
  "python-dateutil~=2.2",
34
+ "PyJWT>=2.0,<3.0",
35
+ "pyjwt[crypto]",
34
36
  ]
35
37
  requires-python = ">=3.6"
36
38
 
37
39
  [project.optional-dependencies]
38
40
  dev = [
39
- "PyJWT~=2.8",
40
- "pyjwt[crypto]",
41
41
  "mock==2.0.0",
42
42
  "ruff==0.1.4",
43
43
  ]
@@ -1 +0,0 @@
1
- VERSION = '0.0.2'