apache/beam · error · RuntimeError

No proto files found in

Error message

No proto files found in %s. / Not in apache git tree, unable to find proto definitions.

What it means

generate_proto_files discovers Beam's .proto files relative to the git tree (PROJECT_ROOT/model etc.). If none are found, it raises RuntimeError with a message distinguishing 'No proto files found' (in the tree, protos deleted/moved) from 'Not in apache git tree' (e.g. running from a pip-installed package or tarball without sources).

Solutions

  1. Clone the full apache/beam git repository and run the script from its sdks/python directory.
  2. Verify model/ and sdks/python/proto paths exist relative to PROJECT_ROOT.
  3. Skip regeneration if you only need pre-generated protos (they ship with the package).

Example fix

// before
pip install apache-beam && python -c 'import gen_protos'
// after
git clone https://github.com/apache/beam.git && cd beam/sdks/python && python gen_protos.py
Defensive patterns

Strategy: validation

Validate before calling

import os
model = os.path.join(os.getcwd(), '..', '..', 'model')
assert os.path.isdir(model) and any(f.endswith('.proto') for _, _, fs in os.walk(model) for f in fs), \
    'run gen_protos.py from a full apache/beam git checkout'

Type guard

def in_beam_git_tree():
    import os
    return os.path.isdir(os.path.join(os.getcwd(), '..', '..', 'model'))

Try / catch

try:
    generate_proto_files()
except RuntimeError as e:
    if 'Not in apache git tree' in str(e):
        print('Clone apache/beam sources before regenerating protos')

Prevention

When it happens

Trigger: Running gen_protos.py outside a full Apache Beam git checkout (e.g. from an installed wheel or extracted sdist), or inside the tree but with the model/ proto directories missing or moved.

Common situations: Attempting regeneration from a released Beam package; working in a shallow/partial clone or after removing submodule/model directories.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/9a1cc2a5f465575c. Report an issue: GitHub.

Appendix: source

Thrown at sdks/python/gen_protos.py:445

      proto_file for d in proto_dirs for proto_file in find_by_ext(d, '.proto')
  ]

  out_files = list(find_by_ext(PYTHON_OUTPUT_PATH, '_pb2.py'))

  if out_files and not proto_files and not force:
    # We have out_files but no protos; assume they're up-to-date.
    # This is actually the common case (e.g. installation from an sdist).
    LOG.info('No proto files; using existing generated files.')
    return

  elif not out_files and not proto_files:
    model = os.path.join(PROJECT_ROOT, 'model')
    if os.path.exists(model):
      error_msg = 'No proto files found in %s.' % proto_dirs
    else:
      error_msg = 'Not in apache git tree, unable to find proto definitions.'

    raise RuntimeError(error_msg)

  if force:
    regenerate_reason = 'forced'
  elif not out_files:
    regenerate_reason = 'no output files'
  elif len(out_files) < len(proto_files):
    regenerate_reason = 'not enough output files'
  elif (min(os.path.getmtime(path) for path in out_files) <= max(
      os.path.getmtime(path)
      for path in proto_files + [os.path.realpath(__file__)])):
    regenerate_reason = 'output files are out-of-date'
  elif len(out_files) > len(proto_files):
    regenerate_reason = 'output files without corresponding .proto files'
    # too many output files: probably due to switching between git branches.
    # remove them so they don't trigger constant regeneration.
    for out_file in out_files:
      os.remove(out_file)
  else:

View on GitHub (pinned to 12126d8942)