omnata-plugin-runtime 0.3.22a66__py3-none-any.whl → 0.3.23__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.
@@ -20,6 +20,7 @@ import json
20
20
  import queue
21
21
  import threading
22
22
  import time
23
+ import hashlib
23
24
  from abc import ABC, abstractmethod
24
25
  from decimal import Decimal
25
26
  from functools import partial, wraps, reduce
@@ -1181,6 +1182,9 @@ class InboundSyncRequest(SyncRequest):
1181
1182
  else:
1182
1183
  results_df["APP_IDENTIFIER"] = None
1183
1184
  if primary_key_field is not None:
1185
+ if isinstance(primary_key_field,list) and len(primary_key_field) == 1:
1186
+ # don't hash it if it's just a single value
1187
+ primary_key_field = primary_key_field[0]
1184
1188
  if isinstance(primary_key_field,list):
1185
1189
  primary_key_fields = cast(List[str],primary_key_field)
1186
1190
  primary_key_fields = sorted(primary_key_fields)
@@ -1196,8 +1200,8 @@ class InboundSyncRequest(SyncRequest):
1196
1200
  raise ValueError(
1197
1201
  f"Primary key fields '{primary_key_fields}' were not present in all records for stream {stream_name}"
1198
1202
  )
1199
- # concatenate the primary key fields to form the APP_IDENTIFIER
1200
- results_df["APP_IDENTIFIER"] = results_df["RECORD_DATA"].apply(lambda x: "-".join([str(field) for field in primary_key_fields]))
1203
+ # hash all of the primary key fields
1204
+ results_df["APP_IDENTIFIER"] = results_df["RECORD_DATA"].apply(lambda x: self.get_hash([str(x[field]) for field in primary_key_fields]))
1201
1205
  else:
1202
1206
  # the primary key field could contain a nested field, so we need to check for that
1203
1207
  # we need to check that each record in the results contains the primary key field
@@ -1256,6 +1260,16 @@ class InboundSyncRequest(SyncRequest):
1256
1260
  ["APP_IDENTIFIER", "STREAM_NAME", "RECORD_DATA", "RETRIEVE_DATE", "IS_DELETED"]
1257
1261
  )
1258
1262
  ]
1263
+
1264
+ def get_hash(self, keys:List[str]) -> str:
1265
+ """
1266
+ Creates a hash from a list of keys.
1267
+ The function will join the keys with an underscore and then create a
1268
+ SHA256 hash from the string. The function will return the hash as a string.
1269
+ """
1270
+ key_string = "_".join(keys)
1271
+ hash_object = hashlib.sha256(key_string.encode())
1272
+ return hash_object.hexdigest()
1259
1273
 
1260
1274
  def _apply_results_dataframe(self, stream_names: List[str], results_df: pandas.DataFrame):
1261
1275
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.3.22a66
3
+ Version: 0.3.23
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  Author: James Weakley
6
6
  Author-email: james.weakley@omnata.com
@@ -3,10 +3,10 @@ omnata_plugin_runtime/api.py,sha256=_N5ok5LN7GDO4J9n3yduXp3tpjmhpySY__U2baiygrs,
3
3
  omnata_plugin_runtime/configuration.py,sha256=7cMekoY8CeZAJHpASU6tCMidF55Hzfr7CD74jtebqIY,35742
4
4
  omnata_plugin_runtime/forms.py,sha256=pw_aKVsXSz47EP8PFBI3VDwdSN5IjvZxp8JTjO1V130,18421
5
5
  omnata_plugin_runtime/logging.py,sha256=bn7eKoNWvtuyTk7RTwBS9UARMtqkiICtgMtzq3KA2V0,3272
6
- omnata_plugin_runtime/omnata_plugin.py,sha256=qT_ILp47Y0Na3ts7lQR0rlHd5n7DZZ0EbFMkW06JwQo,102159
6
+ omnata_plugin_runtime/omnata_plugin.py,sha256=EaGIQdq_gcmH2loTluTa0T3YxuUhDNZTQIItzYXtZxE,102783
7
7
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=s-SrUnXaS6FaBq1igiJhcCB3Md_a6op-dp_g1H_55QU,27736
8
8
  omnata_plugin_runtime/rate_limiting.py,sha256=se6MftQI5NrVHaLb1hByPCgAESPQhkAgIG7KIU1clDU,16562
9
- omnata_plugin_runtime-0.3.22a66.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- omnata_plugin_runtime-0.3.22a66.dist-info/METADATA,sha256=kXXYPQoia3W6E2x3OmgF8v9vQnMdGOtt4aY-h7D0lPE,1604
11
- omnata_plugin_runtime-0.3.22a66.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- omnata_plugin_runtime-0.3.22a66.dist-info/RECORD,,
9
+ omnata_plugin_runtime-0.3.23.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ omnata_plugin_runtime-0.3.23.dist-info/METADATA,sha256=bpam49U-bEspKOBjj2_3XKS_DypxeIKT128MkjkKFqU,1601
11
+ omnata_plugin_runtime-0.3.23.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ omnata_plugin_runtime-0.3.23.dist-info/RECORD,,