Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some warnings contain non-existing paths #9481

Closed
astrojuanlu opened this issue Jul 20, 2021 · 4 comments
Closed

Some warnings contain non-existing paths #9481

astrojuanlu opened this issue Jul 20, 2021 · 4 comments

Comments

@astrojuanlu
Copy link
Contributor

astrojuanlu commented Jul 20, 2021

Describe the bug

While investigating sktime/sktime#1181, I noticed that the warnings (turned into errors) contained some weird paths:

$ python -m sphinx -v -W -T -E -b html -d _build/doctrees -D language=en source/ _build/html
...                                                                                                                                                                                                          
  File "/usr/lib/python3.7/logging/__init__.py", line 751, in filter                                                                                                                                                                          
    result = f.filter(record)                                                                                          
  File "/home/juanlu/Projects/RTD/tmp/sktime/.venv/lib/python3.7/site-packages/sphinx/util/logging.py", line 421, in filter
    raise exc                                              
sphinx.errors.SphinxWarning: /home/juanlu/Projects/RTD/tmp/sktime/docs/source/source/api_reference/classification.rst.rst:16:autosummary: stub file not found 'sktime.classification.compose.ColumnEnsembleClassifier'. Check your autosummary_generate setting. 

Rather than /home/juanlu/Projects/RTD/tmp/sktime/docs/source/source/api_reference/classification.rst.rst, it should say /home/juanlu/Projects/RTD/tmp/sktime/docs/source/api_reference/classification.rst (notice the extra source/ segment and extra .rst extension).

After some debugging, I traced it to this function call:

(Pdb) p self.app.env.doc2path("source/api_reference/classification.rst")
'/home/juanlu/Projects/RTD/tmp/sktime/docs/source/source/api_reference/classification.rst.rst'

happening in these lines:

if isinstance(location, tuple):
docname, lineno = location
if docname and lineno:
record.location = '%s:%s' % (self.app.env.doc2path(docname), lineno)

How to Reproduce

$ git clone https://github.com/alan-turing-institute/sktime
$ cd sktime
$ pip install -r docs/requirements.txt  # Installation instructions taken from https://www.sktime.org/en/latest/contributing.html#id18
$ cd docs
$ python -m sphinx -v -W -T -E -b html -d _build/doctrees -D language=en source/ _build/html
# See error

Expected behavior

The error should contain an actual path, in this case /home/juanlu/Projects/RTD/tmp/sktime/docs/source/api_reference/classification.rst.

Your project

https://github.com/alan-turing-institute/sktime

Screenshots

No response

OS

Linux

Python version

3.7

Sphinx version

3.2.1

Sphinx extensions

sphinx.ext.autodoc, sphinx.ext.autosummary, others

Extra tools

No response

Additional context

sktime/sktime#1181

@tk0miya
Copy link
Member

tk0miya commented Jul 23, 2021

Hmm... it's strange. source/api_reference/classification.rst is not a name of document. So we need to investigate what code passes it to the doc2path.

(Pdb) p self.app.env.doc2path("source/api_reference/classification.rst")
'/home/juanlu/Projects/RTD/tmp/sktime/docs/source/source/api_reference/classification.rst.rst'

Unfortunately, I can't reproduce the error with the reported procedure.

FROM python:3.7-slim

RUN apt update; apt install -y build-essential curl git unzip vim
RUN git clone https://github.com/alan-turing-institute/sktime
WORKDIR /sktime
RUN pip3 install -r docs/requirements.txt
WORKDIR /sktime/docs
RUN python -m sphinx -v -W -T -E -b html -d _build/doctrees -D language=en source/ _build/html

Could you check the procedure please? It would be nice if you create a minimal reproducible example :-)

@tk0miya tk0miya added this to the 4.2.0 milestone Jul 23, 2021
@astrojuanlu
Copy link
Contributor Author

Right, I'm finding other problems with sktime now, and in any case the project is too big. I'll try to send a smaller reproducer.

@astrojuanlu
Copy link
Contributor Author

Hah, the problem I'm having is #7989 again :) I think I'll focus on that one first.

@astrojuanlu
Copy link
Contributor Author

Here is a simple reproducer: https://github.com/astrojuanlu/sphinx-autosummary-tracebacks/tree/weird-paths

(.venv) $ pip install -r requirements.txt
(.venv) $ python -c "from test_pkg import A; print(A)"
<class 'test_pkg.A'>
(.venv) $ make html
Running Sphinx v4.1.1
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [config changed ('autosummary_generate')] 2 added, 0 changed, 0 removed
reading sources... [100%] index
/home/juanlu/Projects/RTD/tmp/sphinx-autosummary-tracebacks/source/index.rst.rst:13: WARNING: autosummary: stub file not found 'test_pkg.A'. Check your autosummary_generate setting.
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/juanlu/Projects/RTD/tmp/sphinx-autosummary-tracebacks/source/autogen/test_pkg.A.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] index
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 2 warnings.

The HTML pages are in build/html.
(.venv) $ python -m sphinx -W -b html source/ build/html
Running Sphinx v4.1.1
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: [new config] 2 added, 0 changed, 0 removed
reading sources... [100%] index

Warning, treated as error:
/home/juanlu/Projects/RTD/tmp/sphinx-autosummary-tracebacks/source/index.rst.rst:13:autosummary: stub file not found 'test_pkg.A'. Check your autosummary_generate setting.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Jul 25, 2021
…filenames

`SphinxDirective.get_source_info()` returns the pair of fullpath of
source and current line number.  But our logging module expects one of
these:

* A string consists of fullpath and current line number
* A pair of docname and current line number

To show correct location for warnings, this adds `get_location()` method
that returns the former one.

Note: This also modifies C/C++ domains.
tk0miya added a commit that referenced this issue Jul 26, 2021
Fix #9481: autosummary: some warnings contain non-existing filenames
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants