tensorflow / tensorflow/tensorboard

Inferred logdir for `tf.summary.trace_export` broken

Open
#4,468 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core:summaries plugin:graph plugin:graph:profile type:bug
Dominant language
TypeScript
Stars
7.2k
Forks
1.7k
Avg merge
4d 22h
Merged PRs (30d)
1

Description

Feature added in https://github.com/tensorflow/tensorflow/pull/35340,
but I have no evidence that it ever worked (it has no tests, and is
broken in TensorFlow 2.2.0 through head). Simple repro:

import tensorflow as tf

writer = tf.summary.create_file_writer("logs")
with writer.as_default():
    tf.summary.trace_on(profiler=True)
    tf.summary.trace_export("test", step=0)

The last line fails with:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    tf.summary.trace_export("test", step=0)
  File "/usr/local/google/home/wchargin/virtualenv/tf-nightly-20201214-py3.8/lib/python3.8/site-packages/tensorflow/python/ops/summary_ops_v2.py", line 1314, in trace_export
    _profiler.save(profiler_outdir, _profiler.stop())
  File "/usr/local/google/home/wchargin/virtualenv/tf-nightly-20201214-py3.8/lib/python3.8/site-packages/tensorflow/python/util/deprecation.py", line 337, in new_func
    return func(*args, **kwargs)
  File "/usr/local/google/home/wchargin/virtualenv/tf-nightly-20201214-py3.8/lib/python3.8/site-packages/tensorflow/python/eager/profiler.py", line 147, in save
    plugin_dir = os.path.join(
  File "/usr/lib/python3.8/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not tensorflow.python.framework.ops.EagerTensor

(The error is slightly different in TensorFlow 2.2.0 on Python 3.5, but
that’s just because of the Python version difference.)

Stepping with pdb shows that logdir on line R1234 of that PR is set
to <tf.Tensor: shape=(), dtype=string, numpy=b'logs'>, which
explains why the later call to os.path.join(logdir, ...) would fail in
the internals of _profiler.save.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the Python example, then inspect trace_export in tensorflow/python/ops/summary_ops_v2.py and the path handling in tensorflow/python/eager/profiler.py. Add coverage for inferred logdir behavior and verify that the example completes without passing an EagerTensor to the filesystem path operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.