omnata-plugin-runtime 0.4.3__tar.gz → 0.4.4__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.4.3
3
+ Version: 0.4.4
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "omnata-plugin-runtime"
3
- version = "0.4.3"
3
+ version = "0.4.4"
4
4
  description = "Classes and common runtime components for building and running Omnata Plugins"
5
5
  authors = ["James Weakley <james.weakley@omnata.com>"]
6
6
  readme = "README.md"
@@ -427,7 +427,7 @@ class SyncRequest(ABC):
427
427
  """
428
428
  return not self._thread_cancellation_token.wait(seconds)
429
429
 
430
- def update_activity(self, current_activity: str):
430
+ def update_activity(self, current_activity: str) -> Dict:
431
431
  """
432
432
  Provides an update to the user on what's happening inside the sync run. It should
433
433
  be used before commencing a potential long-running phase, like polling and waiting or
@@ -436,11 +436,11 @@ class SyncRequest(ABC):
436
436
  Avoid lengthy diagnostic messages, anything like this should be logged the normal way.
437
437
  """
438
438
  logger.info(f"Activity update: {current_activity}")
439
- self._plugin_message(
439
+ return self._plugin_message(
440
440
  PluginMessageCurrentActivity(current_activity=current_activity)
441
441
  )
442
442
 
443
- def _plugin_message(self, message: PluginMessage) -> Dict:
443
+ def _plugin_message(self, message: PluginMessage, ignore_errors:bool = True) -> Dict:
444
444
  """
445
445
  Sends a message back to the plugin. This is used to send back the results of a sync run.
446
446
  """
@@ -456,9 +456,13 @@ class SyncRequest(ABC):
456
456
  ).collect()
457
457
  )
458
458
  except Exception as e:
459
- logger.error(
460
- f"Error sending plugin message: {e}", exc_info=True, stack_info=True
461
- )
459
+ if ignore_errors:
460
+ logger.error(
461
+ f"Error sending plugin message: {e}", exc_info=True, stack_info=True
462
+ )
463
+ return None
464
+ else:
465
+ raise e
462
466
 
463
467
 
464
468
  class HttpRateLimiting:
@@ -978,7 +982,7 @@ class InboundSyncRequest(SyncRequest):
978
982
  # so we need to make sure all the results are applied first
979
983
  self.apply_progress_updates()
980
984
 
981
- def apply_progress_updates(self):
985
+ def apply_progress_updates(self, ignore_errors:bool = True):
982
986
  """
983
987
  Sends a message to the plugin with the current progress of the sync run, if it has changed since last time.
984
988
  """
@@ -989,10 +993,14 @@ class InboundSyncRequest(SyncRequest):
989
993
  total_records_estimate=self._total_records_estimate
990
994
  )
991
995
  if self._last_stream_progress_update is None or new_progress_update != self._last_stream_progress_update:
992
- self._plugin_message(
993
- message=new_progress_update
996
+ result = self._plugin_message(
997
+ message=new_progress_update,
998
+ ignore_errors=ignore_errors
994
999
  )
1000
+ if result is None:
1001
+ return False
995
1002
  self._last_stream_progress_update = new_progress_update
1003
+ return True
996
1004
 
997
1005
  def apply_cancellation(self):
998
1006
  """
@@ -221,7 +221,8 @@ class PluginEntrypoint:
221
221
  logger.info("Calling apply_rate_limit_state")
222
222
  inbound_sync_request.apply_rate_limit_state()
223
223
  logger.info("Calling apply_progress_updates")
224
- inbound_sync_request.apply_progress_updates()
224
+ # we can't ignore errors here, because the sync engine needs to get the progress updates before we return
225
+ inbound_sync_request.apply_progress_updates(ignore_errors=False)
225
226
  if inbound_sync_request.deadline_reached:
226
227
  # if we actually hit the deadline, this is flagged by the cancellation checking worker and the cancellation
227
228
  # token is set. We throw it here as an error since that's currently how it flows back to the engine with a DELAYED state