omnata-plugin-runtime 0.4.0a89__py3-none-any.whl → 0.4.0a91__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.
@@ -40,6 +40,7 @@ from snowflake.connector.pandas_tools import write_pandas
40
40
  from snowflake.connector.version import VERSION
41
41
  from snowflake.snowpark import Session
42
42
  from snowflake.snowpark.functions import col
43
+ from tenacity import Retrying, stop_after_attempt, wait_fixed, retry_if_exception_message
43
44
 
44
45
  from .logging import OmnataPluginLogHandler
45
46
 
@@ -690,9 +691,8 @@ class OutboundSyncRequest(SyncRequest):
690
691
  logger.info("applying results to table")
691
692
  # use a random table name with a random string to avoid collisions
692
693
  with self._snowflake_query_lock:
693
- attempts_remaining = 12
694
- while attempts_remaining > 0:
695
- try:
694
+ for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*is being committed.*")):
695
+ with attempt:
696
696
  success, nchunks, nrows, _ = write_pandas(
697
697
  conn=self._session._conn._cursor.connection, # pylint: disable=protected-access
698
698
  df=self._preprocess_results_dataframe(results_df),
@@ -707,18 +707,6 @@ class OutboundSyncRequest(SyncRequest):
707
707
  logger.info(
708
708
  f"Wrote {nrows} rows and {nchunks} chunks to table {self._full_results_table_name}"
709
709
  )
710
- return
711
- except Exception as e:
712
- if 'is being committed' not in str(e):
713
- raise e
714
- logger.error(
715
- f"Transaction clash writing results to table {self._full_results_table_name}: {e}"
716
- )
717
- attempts_remaining -= 1
718
- time.sleep(5)
719
- raise ValueError(
720
- f"Failed to write results to table {self._full_results_table_name} after {attempts_remaining} attempts"
721
- )
722
710
 
723
711
  def __dataframe_wrapper(
724
712
  self, data_frame: pandas.DataFrame, render_jinja: bool = True
@@ -963,8 +951,6 @@ class InboundSyncRequest(SyncRequest):
963
951
  for stream_name in stream_names:
964
952
  self._apply_results[stream_name] = None
965
953
  self._apply_results = {}
966
- # update the inbound stream record counts, so we can see progress
967
- self.apply_progress_updates()
968
954
 
969
955
  # also take care of uploading delete requests
970
956
  if hasattr(self,'_apply_results_criteria_deletes') and self._apply_results_criteria_deletes is not None:
@@ -984,6 +970,12 @@ class InboundSyncRequest(SyncRequest):
984
970
  self._apply_criteria_deletes_dataframe(all_dfs)
985
971
  # clear the delete requests
986
972
  self._apply_results_criteria_deletes = {}
973
+
974
+
975
+ # update the inbound stream record counts, so we can see progress
976
+ # we do this last, because marking a stream as completed will cause the sync engine to process it
977
+ # so we need to make sure all the results are applied first
978
+ self.apply_progress_updates()
987
979
 
988
980
  def apply_progress_updates(self):
989
981
  """
@@ -1323,9 +1315,8 @@ class InboundSyncRequest(SyncRequest):
1323
1315
  """
1324
1316
  if len(results_df) > 0:
1325
1317
  with self._snowflake_query_lock:
1326
- attempts_remaining = 12
1327
- while attempts_remaining > 0:
1328
- try:
1318
+ for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*is being committed.*")):
1319
+ with attempt:
1329
1320
  logger.info(
1330
1321
  f"Applying {len(results_df)} results to {self._full_results_table_name}"
1331
1322
  )
@@ -1354,18 +1345,6 @@ class InboundSyncRequest(SyncRequest):
1354
1345
  # )
1355
1346
  for stream_name in stream_names:
1356
1347
  self._results_exist[stream_name] = True
1357
- return
1358
- except Exception as e:
1359
- if 'is being committed' not in str(e):
1360
- raise e
1361
- logger.error(
1362
- f"Transaction clash writing results to table {self._full_results_table_name}: {e}"
1363
- )
1364
- attempts_remaining -= 1
1365
- time.sleep(5)
1366
- raise ValueError(
1367
- f"Failed to write results to table {self._full_results_table_name} after {attempts_remaining} attempts"
1368
- )
1369
1348
  else:
1370
1349
  logger.info("Results dataframe is empty, not applying")
1371
1350
 
@@ -1383,9 +1362,8 @@ class InboundSyncRequest(SyncRequest):
1383
1362
  """
1384
1363
  if len(results_df) > 0:
1385
1364
  with self._snowflake_query_lock:
1386
- attempts_remaining = 12
1387
- while attempts_remaining > 0:
1388
- try:
1365
+ for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*is being committed.*")):
1366
+ with attempt:
1389
1367
  logger.info(
1390
1368
  f"Applying {len(results_df)} criteria deletes to {self._criteria_deletes_table_name}"
1391
1369
  )
@@ -1405,17 +1383,6 @@ class InboundSyncRequest(SyncRequest):
1405
1383
  f"Wrote {nrows} rows and {nchunks} chunks to table {self._criteria_deletes_table_name}"
1406
1384
  )
1407
1385
  return
1408
- except Exception as e:
1409
- if 'is being committed' not in str(e):
1410
- raise e
1411
- logger.error(
1412
- f"Transaction clash writing results to table {self._full_results_table_name}: {e}"
1413
- )
1414
- attempts_remaining -= 1
1415
- time.sleep(5)
1416
- raise ValueError(
1417
- f"Failed to write results to table {self._full_results_table_name} after {attempts_remaining} attempts"
1418
- )
1419
1386
  else:
1420
1387
  logger.info("Results dataframe is empty, not applying")
1421
1388
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.4.0a89
3
+ Version: 0.4.0a91
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
@@ -25,6 +25,7 @@ Requires-Dist: pytz (<=2023.3.post1)
25
25
  Requires-Dist: requests (>=2,<=2.31.0)
26
26
  Requires-Dist: setuptools (>=68.2.2)
27
27
  Requires-Dist: snowflake-snowpark-python (>=1,<2)
28
+ Requires-Dist: tenacity (>=8,<=8.2.2)
28
29
  Requires-Dist: tomlkit (>=0.11.1)
29
30
  Requires-Dist: urllib3 (<=2.1.0)
30
31
  Requires-Dist: wheel (<=0.41.2)
@@ -3,10 +3,10 @@ omnata_plugin_runtime/api.py,sha256=W79CsAcl127Dzy-XVS9CzvzsbS3IigVH4QAhFFDkaXg,
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=JJtpl8iKcTMgIOymkZh9yKMhZBemXQOGe8s8iJSw5Hk,108276
6
+ omnata_plugin_runtime/omnata_plugin.py,sha256=Jo56GU7R3yUWP0-Go_71P7sxD7XUE2Z0VwNc_eHi33w,107057
7
7
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=D2f0Qih7KTJNXIDYkA-E55RTEK_7Jtv9ySqspWxERVA,28272
8
8
  omnata_plugin_runtime/rate_limiting.py,sha256=29Hjsr0i1rE8jERVdIFGINfQfp_kI3PDft-IM_ZxvCA,21509
9
- omnata_plugin_runtime-0.4.0a89.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- omnata_plugin_runtime-0.4.0a89.dist-info/METADATA,sha256=LEkEREX1mBrQoSb6abHniwlf8gZfkBicmmzhbP_Glgw,1603
11
- omnata_plugin_runtime-0.4.0a89.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- omnata_plugin_runtime-0.4.0a89.dist-info/RECORD,,
9
+ omnata_plugin_runtime-0.4.0a91.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ omnata_plugin_runtime-0.4.0a91.dist-info/METADATA,sha256=YwD_HMJWQW6Zo3ucJyZOVitQr4VaC9n0cf4QVmgTRyk,1641
11
+ omnata_plugin_runtime-0.4.0a91.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ omnata_plugin_runtime-0.4.0a91.dist-info/RECORD,,