docstr: Tests task generation when a node registers a failed execution.
docstr_tok: ["Tests","task","generation","when","a","node","registers","a","failed","execution","."]
code: def test_node_failed(self, fail_fast):
      """Tests task generation when a node registers a failed execution."""
      test_utils.fake_example_gen_run(
          self._mlmd_connection, self._example_gen, 1, 1
      )
  
      [stats_gen_task] = self._generate_and_test(
          False,
          num_initial_executions=1,
          num_tasks_generated=1,
          num_new_executions=1,
          num_active_executions=1,
          ignore_update_node_state_tasks=True,
          fail_fast=fail_fast,
      )
      self.assertEqual(
          task_lib.NodeUid.from_node(self._pipeline, self._stats_gen),
          stats_gen_task.node_uid,
      )
      with self._mlmd_connection as m:
          with mlmd_state.mlmd_execution_atomic_op(
              m, stats_gen_task.execution_id
          ) as stats_gen_exec:
              # Fail stats-gen execution.
              stats_gen_exec.last_known_state = (
                  metadata_store_pb2.Execution.FAILED
              )
              data_types_utils.set_metadata_value(
                  stats_gen_exec.custom_properties[
                      constants.EXECUTION_ERROR_CODE_KEY
                  ],
                  status_lib.Code.UNAVAILABLE,
              )
              data_types_utils.set_metadata_value(
                  stats_gen_exec.custom_properties[
                      constants.EXECUTION_ERROR_MSG_KEY
                  ],
                  "foobar error",
              )
  
      # Test generation of FinalizePipelineTask.
      [update_node_state_task, finalize_task] = self._generate_and_test(
          True,
          num_initial_executions=2,
          num_tasks_generated=2,
          num_new_executions=0,
          num_active_executions=0,
          fail_fast=fail_fast,
      )
      self.assertIsInstance(
          update_node_state_task, task_lib.UpdateNodeStateTask
      )
      self.assertEqual(
          "my_statistics_gen", update_node_state_task.node_uid.node_id
      )
      self.assertEqual(
          pstate.NodeState.FAILED, update_node_state_task.state
      )
      self.assertEqual(
          status_lib.Code.UNAVAILABLE,
          update_node_state_task.status.code,
      )
      self.assertRegexMatch(
          update_node_state_task.status.message, ["foobar error"]
      )
      self.assertIsInstance(
          finalize_task, task_lib.FinalizePipelineTask
      )
      self.assertEqual(
          status_lib.Code.UNAVAILABLE, finalize_task.status.code
      )
      self.assertRegexMatch(
          finalize_task.status.message, ["foobar error"]
      )
  
imports: import itertools
  import os
  from typing import Literal
  import uuid
  from absl.testing import parameterized
  from absl.testing.absltest import mock
  import tensorflow
  from tfx.dsl.compiler import constants
  from tfx.orchestration import data_types_utils
  from tfx.orchestration.experimental.core import constants
  from tfx.orchestration.experimental.core import mlmd_state
  from tfx.orchestration.experimental.core import pipeline_state
  from tfx.orchestration.experimental.core import service_jobs
  from tfx.orchestration.experimental.core import sync_pipeline_task_gen
  from tfx.orchestration.experimental.core import task
  from tfx.orchestration.experimental.core import task_gen_utils
  from tfx.orchestration.experimental.core import task_queue
  from tfx.orchestration.experimental.core import test_utils
  from tfx.orchestration.experimental.core.testing import test_sync_pipeline
  from tfx.orchestration import mlmd_connection_manager
  from tfx.orchestration.portable import runtime_parameter_utils
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.utils import status
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 17 for calling the SyncPipelineTaskGeneratorTest obj's underlying member method code with example usage: obj.test_node_failed(fail_fast) without return types