hotglue-singer-sdk 1.0.2__py3-none-any.whl → 1.0.7__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.
@@ -74,6 +74,11 @@ class HotglueBaseSink(Rest):
74
74
 
75
75
  # remove failed records from the previous state so retrigger retries those records
76
76
  if self.previous_state:
77
+ if not self.previous_state.get("bookmarks"):
78
+ self.previous_state["bookmarks"] = {}
79
+ if not self.previous_state.get("summary"):
80
+ self.previous_state["summary"] = {}
81
+
77
82
  for stream in self.previous_state["bookmarks"]:
78
83
  self.previous_state["bookmarks"][stream] = [record for record in self.previous_state["bookmarks"][stream] if record.get("success") != False]
79
84
  for stream in self.previous_state["summary"]:
@@ -89,7 +94,7 @@ class HotglueBaseSink(Rest):
89
94
 
90
95
  # if previous state exists, add the hashes to the processed_hashes
91
96
  if self.previous_state:
92
- self.processed_hashes.extend([record["hash"] for record in self.previous_state["bookmarks"][self.name] if record.get("hash")])
97
+ self.processed_hashes.extend([record["hash"] for record in self.previous_state.get("bookmarks", {}).get(self.name, []) if record.get("hash")])
93
98
 
94
99
  # get the full target state
95
100
  target_state = self._target._latest_state
@@ -174,6 +179,14 @@ class HotglueSink(HotglueBaseSink, RecordSink):
174
179
  def preprocess_record(self, record: dict, context: dict) -> dict:
175
180
  raise NotImplementedError()
176
181
 
182
+
183
+ def _get_error_classification_metadata(self, error: Exception) -> dict:
184
+ if isinstance(error, (InvalidCredentialsError)):
185
+ return {"hg_error_class": InvalidCredentialsError.__name__}
186
+ elif isinstance(error, (InvalidPayloadError)):
187
+ return {"hg_error_class": InvalidPayloadError.__name__}
188
+ return {}
189
+
177
190
  def process_record(self, record: dict, context: dict) -> None:
178
191
  """Process the record."""
179
192
  if not self.latest_state:
@@ -197,8 +210,7 @@ class HotglueSink(HotglueBaseSink, RecordSink):
197
210
  success = False
198
211
  self.logger.exception(f"Preprocess record error {str(e)}")
199
212
  state_updates['error'] = str(e)
200
- if isinstance(e, (InvalidCredentialsError, InvalidPayloadError)):
201
- state_updates['hg_error_class'] = e.__class__.__name__
213
+ state_updates.update(self._get_error_classification_metadata(e))
202
214
 
203
215
  if success is not False:
204
216
 
@@ -226,8 +238,8 @@ class HotglueSink(HotglueBaseSink, RecordSink):
226
238
  except Exception as e:
227
239
  self.logger.exception(f"Upsert record error {str(e)}")
228
240
  state_updates['error'] = str(e)
229
- if isinstance(e, (InvalidCredentialsError, InvalidPayloadError)):
230
- state_updates['hg_error_class'] = e.__class__.__name__
241
+ success = False
242
+ state_updates.update(self._get_error_classification_metadata(e))
231
243
 
232
244
 
233
245
  if success:
@@ -1,5 +1,6 @@
1
1
  """HotglueTarget target class."""
2
2
 
3
+ from __future__ import annotations
3
4
  import click
4
5
  import copy
5
6
  import time
@@ -220,6 +221,18 @@ class TargetHotglue(Target):
220
221
  ):
221
222
  continue
222
223
 
224
+ ref_external_id = record.get(field)
225
+ if ref_external_id:
226
+ sink_bookmarks = (self._latest_state or {}).get("bookmarks", {}).get(object_name)
227
+ cur_record_state = next(
228
+ (x for x in sink_bookmarks if x.get("externalId") == ref_external_id),
229
+ None
230
+ ) if sink_bookmarks else None
231
+
232
+ if cur_record_state and cur_record_state.get("id"):
233
+ record[field] = cur_record_state.get("id")
234
+ continue
235
+
223
236
  relation_snapshot = None
224
237
 
225
238
  relation_path_csv = f"{SNAPSHOT_DIR}/{object_name}_{flow_id}.snapshot.csv"
@@ -421,7 +434,7 @@ class TargetHotglue(Target):
421
434
  """
422
435
  self.logger.info(f"Target '{self.name}' is listening for input from tap.")
423
436
 
424
- stats: dict[str, int] = defaultdict(int)
437
+ stats: Dict[str, int] = defaultdict(int)
425
438
  for line in file_input:
426
439
  # Check if shutdown has been requested
427
440
  if hasattr(self, '_shutdown_requested') and self._shutdown_requested.is_set():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hotglue-singer-sdk
3
- Version: 1.0.2
3
+ Version: 1.0.7
4
4
  Summary: A framework for building Singer taps and targets
5
5
  License: Apache 2.0
6
6
  License-File: LICENSE
@@ -38,16 +38,16 @@ hotglue_singer_sdk/tap_base.py,sha256=7lRZt40GzsMOeMlpoivxaG1Jjs5yB8JeR66JZhrLqe
38
38
  hotglue_singer_sdk/target_base.py,sha256=QbBVXr6x5G3bgbPwpMG80ttL0TMOK8bjJCbJsa4AOFw,19130
39
39
  hotglue_singer_sdk/target_sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  hotglue_singer_sdk/target_sdk/auth.py,sha256=jU3yL5mtlf8p2VWsfoR_TaMjp8_APpQNPtPgHRIUIBc,3925
41
- hotglue_singer_sdk/target_sdk/client.py,sha256=9SZL-rLvFlAmZyStuMzjjwXnPauvJ8RxtCNg25kXeqY,10529
41
+ hotglue_singer_sdk/target_sdk/client.py,sha256=fVQVFHtmKn4W2KOALI9XIreX6IY1ji2JeI5lwEiI-jY,10996
42
42
  hotglue_singer_sdk/target_sdk/common.py,sha256=l2ldX1qXxbzvjeaicu0If0CUMV_bmX2OV5NSFMol_fM,333
43
43
  hotglue_singer_sdk/target_sdk/lambda.py,sha256=LyYFS39r0zmCBbUEEwcueLOWI2L2YiKlfob8-dU9jMs,3685
44
44
  hotglue_singer_sdk/target_sdk/rest.py,sha256=3PUOx7pWg7DfbMonu2wiiQqU5mcN49B-_1mvQVgL4Gc,3607
45
45
  hotglue_singer_sdk/target_sdk/sinks.py,sha256=-nm5hSLkfma6-BbBlZVJih7lwktQ7BRa9zw9TkmUdwo,464
46
- hotglue_singer_sdk/target_sdk/target.py,sha256=AyH1AIXmfLZYT-biq1aSBMkGC2OpQyCtCAYSBXia6Bs,22921
46
+ hotglue_singer_sdk/target_sdk/target.py,sha256=uVqmXmyIO-h3M8VCiZ1McPXczZj7EU0PO33DCOMyj5g,23559
47
47
  hotglue_singer_sdk/target_sdk/target_base.py,sha256=LyQQndYGlzu5LcIj-MMcmcjdGAmAYVgvdNAxvCgFpvk,22022
48
48
  hotglue_singer_sdk/testing.py,sha256=BifsP9X83pgKdfynI5CComchoRWEHpe81h-UfOwK_G0,5860
49
49
  hotglue_singer_sdk/typing.py,sha256=jTGFhON9uBZe9e0vHH6-6rjeD2YrpzolPiYigIuo7zU,16186
50
- hotglue_singer_sdk-1.0.2.dist-info/METADATA,sha256=3av4tDpNLnUzBEoYiKPJGdR6U0CbPB4yiCn2oTMyxC8,2376
51
- hotglue_singer_sdk-1.0.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
52
- hotglue_singer_sdk-1.0.2.dist-info/licenses/LICENSE,sha256=BGsDEGu628ZSlSfJzr3RshF0_KTW-E1Z--XnqjioYWg,11337
53
- hotglue_singer_sdk-1.0.2.dist-info/RECORD,,
50
+ hotglue_singer_sdk-1.0.7.dist-info/METADATA,sha256=qOmHWsMv3_4SEfAftosgA6zIyOLiI1Ki22EQx_4emuU,2376
51
+ hotglue_singer_sdk-1.0.7.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
52
+ hotglue_singer_sdk-1.0.7.dist-info/licenses/LICENSE,sha256=BGsDEGu628ZSlSfJzr3RshF0_KTW-E1Z--XnqjioYWg,11337
53
+ hotglue_singer_sdk-1.0.7.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.1
2
+ Generator: poetry-core 2.3.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any