1

Inside the tensorflow/models/tutorials/rnn/translate folder, we have a few files including __init__.py and BUILD.

Without __init__.py and BUILD files, the translate script can still manage to run.

What is the purpose of __init__.py and BUILD here? Are we supposed to install or build it using these two files?

mrry
  • 125,488
  • 26
  • 399
  • 400
Daniel
  • 1,428
  • 3
  • 16
  • 35

1 Answers1

2

The BUILD file supports using Bazel for hermetic building and testing of the model code. In particular a BUILD file is present in that directory to define the integration test translate_test.py and its dependencies, so that we can run it on continuous integration system (e.g. Jenkins).

The __init__.py file causes Python to treat that directory as a package. See this question for a discussion of why __init__.py is often present in a Python source directory. While this file is not strictly necessary to invoke translate.py directly from that directory, it is necessary if we want to import the code from translate.py into a different module.

(Note that when you run a Python binary through Bazel, the build system will automatically generate __init__.py files if they are missing. However, TensorFlow's repositories often have explicit __init__.py files in Python source directories so that you can run the code without invoking Bazel.)

Community
  • 1
  • 1
mrry
  • 125,488
  • 26
  • 399
  • 400