4

We want to debug Python tests in TensorFlow such as sparse_split_op_test and string_to_hash_bucket_op_test

The other c++ tests we could debug using gdb, however we cannot find a way to debug python tests.

Is there a way in which we can debug specific python test case run via Bazel test command (for example, bazel test //tensorflow/python/kernel_tests:sparse_split_op_test)

1 Answer 1

3

I would first build the test:

bazel build //tensorflow/python/kernel_tests:sparse_split_op_test

Then use pdb on the resulting Python binary:

pdb bazel-bin/tensorflow/python/kernel_tests/sparse_split_op_test

That seems to work for me stepping through the first few lines of the test.

Sign up to request clarification or add additional context in comments.

3 Comments

Don't forget to re-build the file every time you make a change.
Fair point. More recently I've just been inserting import pdb; pdb.set_trace() and using bazel run, which keeps everything up to date. bazel test gets in the way of the REPL.
doesn't work if you're referencing $TEST_TMPDIR in your tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.