code: def testPipelineSchema(self):
      pipeline_path = os.path.join(
          self._testdata_dir, "test_pipeline_local_2.py"
      )
      pipeline_name = "chicago_taxi_local"
  
      # Try getting schema without creating pipeline.
      result = self.runner.invoke(
          cli_group,
          [
              "pipeline",
              "schema",
              "--engine",
              "local",
              "--pipeline_name",
              pipeline_name,
          ],
      )
      self.assertIn("CLI", result.output)
      self.assertIn("Getting latest schema.", result.output)
      self.assertIn(
          'Pipeline "{}" does not exist.'.format(pipeline_name),
          result.output,
      )
  
      # Create a pipeline.
      self._valid_create_and_check(pipeline_path, pipeline_name)
  
      # Try getting schema without creating a pipeline run.
      result = self.runner.invoke(
          cli_group,
          [
              "pipeline",
              "schema",
              "--engine",
              "local",
              "--pipeline_name",
              pipeline_name,
          ],
      )
      self.assertIn("CLI", result.output)
      self.assertIn("Getting latest schema.", result.output)
      self.assertIn(
          "Create a run before inferring schema. If pipeline is already running, then wait for it to successfully finish.",
          result.output,
      )
  
      # Run pipeline.
      self._valid_run_and_check(pipeline_name)
  
      # Try inferring schema without SchemaGen component.
      result = self.runner.invoke(
          cli_group,
          [
              "pipeline",
              "schema",
              "--engine",
              "local",
              "--pipeline_name",
              pipeline_name,
          ],
      )
      self.assertIn("CLI", result.output)
      self.assertIn("Getting latest schema.", result.output)
      self.assertIn(
          "Either SchemaGen component does not exist or pipeline is still running. If pipeline is running, then wait for it to successfully finish.",
          result.output,
      )
  
      # Create a pipeline.
      pipeline_path = os.path.join(
          self._testdata_dir, "test_pipeline_local_3.py"
      )
      pipeline_name = "chicago_taxi_local_v2"
      self._valid_create_and_check(pipeline_path, pipeline_name)
  
      # Run pipeline
      self._valid_run_and_check(pipeline_name)
  
      # Infer Schema when pipeline runs for the first time.
      schema_path = os.path.join(os.getcwd(), "schema.pbtxt")
      result = self.runner.invoke(
          cli_group,
          [
              "pipeline",
              "schema",
              "--engine",
              "local",
              "--pipeline_name",
              pipeline_name,
          ],
      )
      self.assertIn("CLI", result.output)
      self.assertIn("Getting latest schema.", result.output)
      self.assertTrue(fileio.exists(schema_path))
      self.assertIn(
          "Path to schema: {}".format(schema_path), result.output
      )
      self.assertIn(
          "*********SCHEMA FOR {}**********".format(
              pipeline_name.upper()
          ),
          result.output,
      )
  
imports: import codecs
  import locale
  import os
  from absl import logging
  from click import testing
  import tensorflow
  from tfx.dsl.io import fileio
  from tfx.tools.cli.cli_main import cli_group
  from tfx.utils import io_utils
  from tfx.utils import test_case_utils
label_desc: Use image node_id 8 for calling the CliLocalEndToEndTest obj's underlying member method code with example usage: obj.testPipelineSchema() without return types