Contributing to TensorFlow (python)

708 views
Skip to first unread message

Tyler Rubin

unread,
Dec 19, 2015, 10:37:42 PM12/19/15
to Discuss
Hey all, 
 I'm interested in fixing a bug that I found with nested While calls in the python implementation (possibly any nested ControlFlowOp), but I am confused as to how to get my dev environment set up. I uninstalled the pip binary because I wanted to run my debugging code against the TensorFlow source that I'm trying to modify. It seems that you can run unit tests through bazel, and it's highly suggested that this is the only way to do it from this message in the top level _init_.py: 

Error importing tensorflow.  Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.

But it seems like it would take a very long time if we need to recompile all the kernels every time we want to test a change in the python interface. Is there another way to test live changes? Any guidance would be much appreciated.

Thanks,
Tyler

Mark Daoust

unread,
Dec 20, 2015, 7:07:05 AM12/20/15
to Tyler Rubin, Discuss
Issue #520 sounds like it will fix the "recompile all the kernels" part of your question:

https://github.com/tensorflow/tensorflow/issues/520



Mark Daoust

--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/eadb2da5-abab-4a0c-b3ea-f4e064038962%40tensorflow.org.

Vijay Vasudevan

unread,
Dec 20, 2015, 12:53:42 PM12/20/15
to Mark Daoust, Tyler Rubin, Discuss
Changing only python files *shouldn't* require recompiling all the kernels: only changing a kernel file or a lower-level infrastructure file should require that.

That being said:

1) Yes, bazel is probably the best way to test a specific target right now

2) We do want to improve the build targets to be a bit more fine-grained, at least for testing.

Tyler Rubin

unread,
Dec 20, 2015, 5:29:42 PM12/20/15
to Discuss
Thank you guys. I'm still slightly confused. When you say bazel is probably the best way to go, does that mean that there is another way or there is not? I'd like to use debug mode of an IDE if at all possible. If there's a path towards making it work without bazel, perhaps I can help move the project in that direction?

Thanks,
Tyler

Vijay Vasudevan

unread,
Dec 20, 2015, 6:12:25 PM12/20/15
to Tyler Rubin, Discuss
On Sun, Dec 20, 2015 at 2:29 PM, Tyler Rubin <tru...@gmail.com> wrote:
Thank you guys. I'm still slightly confused. When you say bazel is probably the best way to go, does that mean that there is another way or there is not? I'd like to use debug mode of an IDE if at all possible.

For this, one option is to just build the test target using bazel and then run the resulting executable test in a debugger.

If there's a path towards making it work without bazel, perhaps I can help move the project in that direction?

https://github.com/tensorflow/tensorflow/issues/380 might be relevant and is already being worked on, I believe.
 

Tyler Rubin

unread,
Dec 20, 2015, 6:22:21 PM12/20/15
to Discuss, v...@google.com
Thanks Vijay. Maybe I'm not fully understanding how this all works together, and if that's the case I apologize. Specifically for the modifications to the python interface, are you saying that for any change we make to the python code, to run the debugger we first have to generate the wheel through bazel and then pip install it so that the module with the change is available to the interpreter?

Vijay Vasudevan

unread,
Dec 20, 2015, 6:38:17 PM12/20/15
to Tyler Rubin, Discuss
On Sun, Dec 20, 2015 at 3:22 PM, Tyler Rubin <tru...@gmail.com> wrote:
Thanks Vijay. Maybe I'm not fully understanding how this all works together, and if that's the case I apologize. Specifically for the modifications to the python interface, are you saying that for any change we make to the python code, to run the debugger we first have to generate the wheel through bazel

If you're not changing any C++ code, then in most cases you can just run the unittest directly whenever you change the python code.  E.g.,

1) Change python file (say, control_flow_ops.py)
2) bazel-bin/tensorflow/python/kernel_tests/control_flow_ops_test.py
(run inside a debugger if needed)

Repeat 1 and 2
 
and then pip install it so that the module with the change is available to the interpreter?

No need to pip install for development, only "deployment".

Tyler Rubin

unread,
Dec 20, 2015, 6:55:18 PM12/20/15
to Discuss, v...@google.com
Oh awesome. I guess my main question then is how do you perform 2) bazel-bin/tensorflow/python/kernel_tests/control_flow_ops_test.py inside the debugger?

Thanks,
Tyler
Reply all
Reply to author
Forward
0 new messages