pytorch / captum

Model interpretability and understanding for PyTorch
https://captum.ai
BSD 3-Clause "New" or "Revised" License
4.96k stars 499 forks source link

`captum.attr.visualization` is missing the Sphinx viewcode source link #990

Open ProGamerGov opened 2 years ago

ProGamerGov commented 2 years ago

šŸ› Bug

The captum.attr.visualization module is missing the link to its source code. I traced the issue with Sphinx's viewcode extension, and discovered that it gives the following warning.

No module named 'captum.attr.visualization'

In viewcode extension, the _get_full_modname function inside doctree_read returns None, and then skips generating the source docs. Inside the _get_full_modname function, a function called get_full_modname is run and it attempts to use importlib's import_module function to get the paths to the files

https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/viewcode.py#L116 https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/__init__.py#L242.

from importlib import import_module
module = import_module("captum.attr.visualization") # Fails

You can see that its missing it's link to the source code here: https://captum.ai/api/utilities.html#visualization

And the file being used is here: https://github.com/pytorch/captum/blob/master/captum/attr/_utils/visualization.py

I discovered this issue while trying to figure out why it's happening in the Optim module code.


Possible solutions for this issue are:

ProGamerGov commented 2 years ago

This Sphinx PR will fix this issue, if it gets merged: https://github.com/sphinx-doc/sphinx/pull/10766