omnata-plugin-runtime 0.4.0a90__py3-none-any.whl → 0.4.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1327,9 +1315,8 @@ class InboundSyncRequest(SyncRequest):
1327
1315
  """
1328
1316
  if len(results_df) > 0:
1329
1317
  with self._snowflake_query_lock:
1330
- attempts_remaining = 12
1331
- while attempts_remaining > 0:
1332
- 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:
1333
1320
  logger.info(
1334
1321
  f"Applying {len(results_df)} results to {self._full_results_table_name}"
1335
1322
  )
@@ -1358,18 +1345,6 @@ class InboundSyncRequest(SyncRequest):
1358
1345
  # )
1359
1346
  for stream_name in stream_names:
1360
1347
  self._results_exist[stream_name] = True
1361
- return
1362
- except Exception as e:
1363
- if 'is being committed' not in str(e):
1364
- raise e
1365
- logger.error(
1366
- f"Transaction clash writing results to table {self._full_results_table_name}: {e}"
1367
- )
1368
- attempts_remaining -= 1
1369
- time.sleep(5)
1370
- raise ValueError(
1371
- f"Failed to write results to table {self._full_results_table_name} after {attempts_remaining} attempts"
1372
- )
1373
1348
  else:
1374
1349
  logger.info("Results dataframe is empty, not applying")
1375
1350
 
@@ -1387,9 +1362,8 @@ class InboundSyncRequest(SyncRequest):
1387
1362
  """
1388
1363
  if len(results_df) > 0:
1389
1364
  with self._snowflake_query_lock:
1390
- attempts_remaining = 12
1391
- while attempts_remaining > 0:
1392
- 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:
1393
1367
  logger.info(
1394
1368
  f"Applying {len(results_df)} criteria deletes to {self._criteria_deletes_table_name}"
1395
1369
  )
@@ -1409,17 +1383,6 @@ class InboundSyncRequest(SyncRequest):
1409
1383
  f"Wrote {nrows} rows and {nchunks} chunks to table {self._criteria_deletes_table_name}"
1410
1384
  )
1411
1385
  return
1412
- except Exception as e:
1413
- if 'is being committed' not in str(e):
1414
- raise e
1415
- logger.error(
1416
- f"Transaction clash writing results to table {self._full_results_table_name}: {e}"
1417
- )
1418
- attempts_remaining -= 1
1419
- time.sleep(5)
1420
- raise ValueError(
1421
- f"Failed to write results to table {self._full_results_table_name} after {attempts_remaining} attempts"
1422
- )
1423
1386
  else:
1424
1387
  logger.info("Results dataframe is empty, not applying")
1425
1388
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.4.0a90
3
+ Version: 0.4.1
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=mJ5NHtenbLpkN0w9JSfb3jQVFShi8RDnsePAoF75b5E,108444
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.0a90.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- omnata_plugin_runtime-0.4.0a90.dist-info/METADATA,sha256=WxKUgmiDnEV4ytmWaB6uHuSi1hA9tFXSnxIIuKta2hI,1603
11
- omnata_plugin_runtime-0.4.0a90.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- omnata_plugin_runtime-0.4.0a90.dist-info/RECORD,,
9
+ omnata_plugin_runtime-0.4.1.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ omnata_plugin_runtime-0.4.1.dist-info/METADATA,sha256=atvdP56cS91SH4dcgcdhCHq1AeTvQuVjSyJrz4FSTdA,1638
11
+ omnata_plugin_runtime-0.4.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ omnata_plugin_runtime-0.4.1.dist-info/RECORD,,