docstr: Tests stopped nodes are ignored when generating tasks.
docstr_tok: ["Tests","stopped","nodes","are","ignored","when","generating","tasks","."]
code: def test_task_generation_when_node_stopped(self, stop_stats_gen):
      """Tests stopped nodes are ignored when generating tasks."""
      test_utils.fake_example_gen_run(
          self._mlmd_connection, self._example_gen, 1, 1
      )
  
      num_initial_executions = 1
      if stop_stats_gen:
          num_tasks_generated = 0
          num_new_executions = 0
          num_active_executions = 0
          with self._mlmd_connection as m:
              pipeline_state = test_utils.get_or_create_pipeline_state(
                  m, self._pipeline
              )
              with pipeline_state:
                  with pipeline_state.node_state_update_context(
                      task_lib.NodeUid.from_node(
                          self._pipeline, self._stats_gen
                      )
                  ) as node_state:
                      node_state.update(
                          pstate.NodeState.STOPPING,
                          status_lib.Status(
                              code=status_lib.Code.CANCELLED
                          ),
                      )
      else:
          num_tasks_generated = 1
          num_new_executions = 1
          num_active_executions = 1
      tasks = self._generate_and_test(
          True,
          num_initial_executions=num_initial_executions,
          num_tasks_generated=num_tasks_generated,
          num_new_executions=num_new_executions,
          num_active_executions=num_active_executions,
          ignore_update_node_state_tasks=True,
      )
      self.assertLen(tasks, num_tasks_generated)
  
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 18 for calling the SyncPipelineTaskGeneratorTest obj's underlying member method code with example usage: obj.test_task_generation_when_node_stopped(stop_stats_gen) without return types