
import apache_beam as beam

from error.error_handling import ErrorHandler
from models.execution import Execution


class MegalistaUploader(beam.DoFn):
  """
  General DoFn to be used as supper for DoFn uploaders.
  Add error notification capabilities.
  """

  def __init__(self, error_handler: ErrorHandler):
    super().__init__()
    self._error_handler = error_handler

  def _add_error(self, execution: Execution, error_message: str):
    self._error_handler.add_error(execution, error_message)

  def teardown(self):
    self._error_handler.notify_errors()


import apache_beam as beam

from error.error_handling import ErrorHandler
from models.execution import Execution


class MegalistaUploader(beam.DoFn):
  """
  General DoFn to be used as supper for DoFn uploaders.
  Add error notification capabilities.
  """

  def __init__(self, error_handler: ErrorHandler):
    super().__init__()
    self._error_handler = error_handler

  def _add_error(self, execution: Execution, error_message: str):
    self._error_handler.add_error(execution, error_message)

  def finish_bundle(self):
    self._error_handler.notify_errors()

Change the notifier to be sent on finish_bundle instead of teardown
Change the notifier to be sent on finish_bundle instead of teardown

Change-Id: I6b80b1d0431b0fe285a5b59e9a33199bf8bd3510

  
  import apache_beam as beam
  
  from error.error_handling import ErrorHandler
  from models.execution import Execution
  
  
  class MegalistaUploader(beam.DoFn):
    """
    General DoFn to be used as supper for DoFn uploaders.
    Add error notification capabilities.
    """
  
    def __init__(self, error_handler: ErrorHandler):
      super().__init__()
      self._error_handler = error_handler
  
    def _add_error(self, execution: Execution, error_message: str):
      self._error_handler.add_error(execution, error_message)
  
-   def teardown(self):
+   def finish_bundle(self):
      self._error_handler.notify_errors()
  
Change the notifier to be sent on finish_bundle instead of teardown
## Code Before:

import apache_beam as beam

from error.error_handling import ErrorHandler
from models.execution import Execution


class MegalistaUploader(beam.DoFn):
  """
  General DoFn to be used as supper for DoFn uploaders.
  Add error notification capabilities.
  """

  def __init__(self, error_handler: ErrorHandler):
    super().__init__()
    self._error_handler = error_handler

  def _add_error(self, execution: Execution, error_message: str):
    self._error_handler.add_error(execution, error_message)

  def teardown(self):
    self._error_handler.notify_errors()

## Instruction:
Change the notifier to be sent on finish_bundle instead of teardown
## Code After:

import apache_beam as beam

from error.error_handling import ErrorHandler
from models.execution import Execution


class MegalistaUploader(beam.DoFn):
  """
  General DoFn to be used as supper for DoFn uploaders.
  Add error notification capabilities.
  """

  def __init__(self, error_handler: ErrorHandler):
    super().__init__()
    self._error_handler = error_handler

  def _add_error(self, execution: Execution, error_message: str):
    self._error_handler.add_error(execution, error_message)

  def finish_bundle(self):
    self._error_handler.notify_errors()
