docstr: Distributed TF cluster w/ InputMode.SPARK and exception after feeding
docstr_tok: ["Distributed","TF","cluster","w\/","InputMode.SPARK","and","exception","after","feeding"]
code: def test_inputmode_spark_late_exception(self):
      """Distributed TF cluster w/ InputMode.SPARK and exception after feeding"""
  
      def _map_fun(args, ctx):
          import tensorflow as tf
  
          tf_feed = TFNode.DataFeed(ctx.mgr, False)
          while not tf_feed.should_stop():
              batch = tf_feed.next_batch(10)
              if len(batch) > 0:
                  squares = tf.math.square(batch)
                  tf_feed.batch_results(squares.numpy())
  
          # simulate post-feed actions that raise an exception
          time.sleep(2)
          raise Exception("FAKE exception after feeding")
  
      input = [
          [x] for x in range(1000)
      ]  # set up input as tensors of shape [1] to match placeholder
      rdd = self.sc.parallelize(input, 10)
      with self.assertRaises(Exception):
          cluster = TFCluster.run(
              self.sc,
              _map_fun,
              tf_args={},
              num_executors=self.num_workers,
              num_ps=0,
              input_mode=TFCluster.InputMode.SPARK,
          )
          cluster.inference(rdd).count()
          cluster.shutdown(grace_secs=5)
  
file_path: TensorFlowOnSpark/tests/test_TFCluster.py
imports: import unittest
  import test
  import time
  from tensorflowonspark import TFCluster, TFNode
label_desc: Use image node_id 6 for calling the TFClusterTest obj's underlying member method code with example usage: obj.test_inputmode_spark_late_exception() without return types