tensorflow: Error after running `python generate2.py --output_dir=/tmp/out`

System information

  • OS Platform and Distribution: Windows 10 1809 build: 17763.2300
  • Mobile device if the issue happens on mobile device:
  • TensorFlow installed from (source or binary):
  • TensorFlow version: 2.6.0
  • Python version: 3.9.7
  • Installed using virtualenv? pip? conda?: pip
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory: Got no GPU

Describe the problem Followed these instructions, but encountered the following error after running python generate2.py --output_dir=/tmp/out:

q

Provide the exact sequence of commands / steps that you executed before running into the problem

pip install git+https://github.com/tensorflow/docs

git clone https://github.com/tensorflow/tensorflow
cd tensorflow/tensorflow/tools/docs
python generate2.py --output_dir=/tmp/out

Any other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. tf.log

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Hi,

Thanks for your patience on this one.

So the code where it’s failing now is here:

https://github.com/tensorflow/docs/blob/6914e839f3b89d4d25c56277108ab2b8d1c18619/tools/tensorflow_docs/api_generator/parser.py#L588

Basically it’s trying to determine which file a python object was defined in, and then convert that to a URL pointing to github.

The code path is:

def get_defined_in(py_object,  parser_config) -> Optional[FileLocation]:
  base_dirs_and_prefixes = zip(parser_config.base_dir,
                               parser_config.code_url_prefix)
  obj_path = inspect.getfile(py_object)

  code_url_prefix = None
  for base_dir, temp_prefix in base_dirs_and_prefixes:
    rel_path = os.path.relpath(path=obj_path, start=base_dir)
    # A leading ".." indicates that the file is not inside `base_dir`, and
    # the search should continue.
    if rel_path.startswith('..'):
      continue
  • base_dirs_and_prefixes is a list of (directory, url) pairs.
  • obj_path is the file we found this object was defined in.

The code is trying to determine which “base directory” the source lives in, so it can apply the right URL prefix.

So I guess some of the code is installed on C: and some is installed on D:. So it’s trying to document an object it found on C, and it’s trying to check if that source file is in a directory on D. I think there’s a simple fix here using pathlib.Path.is_relative_to.

I’m sending a quick fix.

tensorflow/docs@01d385dda9778a426f4d1cc84c60917a21856816 is in, just waiting for tensorflow/docs#1991 and this should be resolved.

Quick update - I have a PR in the works to sort this out, but I still need to do some more testing to make sure I’ve got everything. Should be ready for review tomorrow.