3

I wish to inspect the code inside a (pip installed) module that I've imported (called transformers if it is relevant). So right now what I am doing is putting breakpoint() where relevant in the site_package location and calling the module inside test.py.

from transformers import AutoModel, AutoTokenizer, EncoderDecoderModel

However, Ideally I wish to set and remove breakpoints on the fly as I inspect the code, as I could normally do with a python module I wrote. Wondering if there is something similar for external libraries.

Alternate Solution

I would equally be happy if I could write breakpoint() where I need it to be on the fly. I used to do this with Jupyter with my own modules by adding the following two lines:

%load_ext autoreload
%autoreload 2

However, this did not work for an external library when I added in new breakpoints.

0

2 Answers 2

3

You can add "justMyCode": false, in the launch.json file as the default value of it is true.

You can refer to here for more details.

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

1 Comment

this works OK for regular Python files, but did not hel wiht Jupyter. Perhaps there are some additional parameters needed in launch.json. I tested with jupyter running in WSL.
2

Use an IDE such as PyCharm or Visual Studio Code.

I use Jetbrains CLion that allows me to view external libraries code by right clicking -> Go To -> Declaration or usage.

See this answer.

To do your breakpoint() function, you will have to modify the external library code.

As mentionned here, you should never modify an external library code. Alternatively, with an IDE you will be able to put breakpoints by clicking the line where you want to put a breakpoint.

But if you still want to edit the code, you should install the module with the -e option.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.