class_docstr: TFX interactive context for interactive TFX notebook development.
  
  Note: these APIs are **experimental** and major changes to interface and
  functionality are expected.
class_docstr_tok: ["TFX","interactive","context","for","interactive","TFX","notebook","development",".","Note",":","these","APIs","are","*","*","experimental","*","*","and","major","changes","to","interface","and","functionality","are","expected","."]
docstr: Exports a notebook to a .py file as a runnable pipeline.
  
  Args:
    notebook_filepath: String path of the notebook file, e.g.
      '/path/to/notebook.ipynb'.
    export_filepath: String path for the exported pipeline python file, e.g.
      '/path/to/exported_pipeline.py'.
    runner_type: String indicating type of runner, e.g. 'beam', 'airflow'.
docstr_tok: ["Exports","a","notebook","to","a",".py","file","as","a","runnable","pipeline",".","Args",":","notebook_filepath",":","String","path","of","the","notebook","file",",","e.g",".","'\/path\/to\/notebook.ipynb","'",".","export_filepath",":","String","path","for","the","exported","pipeline","python","file",",","e.g",".","'\/path\/to\/exported_pipeline.py","'",".","runner_type",":","String","indicating","type","of","runner",",","e.g",".","'beam","'",",","'airflow","'","."]
code: def export_to_pipeline(
      self,
      notebook_filepath: str,
      export_filepath: str,
      runner_type: str,
  ):
      """Exports a notebook to a .py file as a runnable pipeline.
  
      Args:
        notebook_filepath: String path of the notebook file, e.g.
          '/path/to/notebook.ipynb'.
        export_filepath: String path for the exported pipeline python file, e.g.
          '/path/to/exported_pipeline.py'.
        runner_type: String indicating type of runner, e.g. 'beam', 'airflow'.
      """
      if runner_type not in ["beam", "airflow"]:
          raise ValueError("Invalid runner_type: %s" % runner_type)
  
      absl.logging.info(
          "Exporting contents of %s to %s with %s runner.",
          notebook_filepath,
          export_filepath,
          runner_type,
      )
  
      with open(notebook_filepath) as notebook_f, open(
          export_filepath, "w"
      ) as export_f:
          notebook = nbformat.read(notebook_f, nbformat.NO_CONVERT)
          cells = notebook["cells"]
          code_cells = (
              cell for cell in cells if cell["cell_type"] == "code"
          )
          sources = []
          num_skipped_cells = 0
          for code_cell in code_cells:
              cell_source = code_cell["source"]
              if cell_source.lstrip().startswith(
                  _SKIP_FOR_EXPORT_MAGIC
              ):
                  num_skipped_cells += 1
                  continue
  
              # Filter out all line/cell magics using `%` prefix and command line
              # invocations (e.g. !pip install ...).
              # Note: This will not work for magics invoked without the prefix when
              # %automagic is set.
              sources.append(
                  (
                      "\n".join(
                          line
                          for line in cell_source.split("\n")
                          if not (
                              line.lstrip().startswith(_MAGIC_PREFIX)
                              or line.lstrip().startswith(
                                  _CMD_LINE_PREFIX
                              )
                          )
                      )
                  )
              )
  
          jinja_env = jinja2.Environment(
              loader=jinja2.PackageLoader(
                  __package__, package_path=_EXPORT_TEMPLATES_DIR
              )
          )
          template_name = "export_%s.tmpl" % runner_type
          # TODO(b/142326292): Consider parameterizing the other variables names
          # present in the export templates.
          rendered_template = jinja_env.get_template(
              template_name
          ).render(
              {
                  "notebook_content": "\n\n".join(sources),
              }
          )
          export_f.write(rendered_template)
          absl.logging.info(
              '%d cell(s) marked with "%s", skipped.',
              num_skipped_cells,
              _SKIP_FOR_EXPORT_MAGIC,
          )
  
imports: import datetime
  import html
  import os
  import tempfile
  from typing import List, Optional
  import absl
  import jinja2
  import nbformat
  from tfx import types
  from tfx.dsl.components.base import base_component
  from tfx.dsl.components.base import base_node
  from tfx.orchestration import data_types
  from tfx.orchestration import metadata
  from tfx.orchestration.experimental.interactive import execution_result
  from tfx.orchestration.experimental.interactive import notebook_formatters
  from tfx.orchestration.experimental.interactive import notebook_utils
  from tfx.orchestration.experimental.interactive import standard_visualizations
  from tfx.orchestration.experimental.interactive import visualizations
  from tfx.orchestration.launcher import in_process_component_launcher
  from tfx.utils import telemetry_utils
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 3 for calling the InteractiveContext obj's underlying member method code with example usage: obj.export_to_pipeline(notebook_filepath, export_filepath, runner_type) without return types