Skip to content

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

@ProGamerGov

Description

@ProGamerGov

🐛 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:

  • Using an exact path in the API docs, like what was done for the Linear Models: https://captum.ai/api/utilities.html#linear-models
  • Changing the file path so that the visualization.py file's location matches the way it's called: captum/attr/visualization.py
  • Importing the needed functions in visualization.py directly, though this would remove the visualization part of the import path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions