Page MenuHomePhabricator

Pywikibot documentation is blank
Closed, ResolvedPublic

Description

Steps to reproduce

  1. Open https://doc.wikimedia.org/pywikibot/api_ref/pywikibot.html#pywikibot-page-module

Current behavior
The content of documentation is completely missing. I am pretty sure there was a content at 1 January, 2018

Configuration
Firefox 57

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Xqt triaged this task as Medium priority.
Xqt removed Xqt as the assignee of this task.Jan 20 2018, 5:32 PM

No idea yet. doc subfolder content hasn't been changed since 20th december.

This comment was removed by Xqt.
Legoktm subscribed.

https://integration.wikimedia.org/ci/job/pywikibot-core-tox-publish/151/consoleFull has a bunch of issues related to 14:44:01 PermissionError: [Errno 13] Permission denied: '/nonexistent' which is probably why this broke during the switch over to docker for Python jobs.

Yes, I think this happened after https://gerrit.wikimedia.org/r/#/c/404448/ merged.

I still have no Idea what is that /nonexistent :/

And the real exception was that autodoc in sphinx couldn't import pywikibot modules

WARNING: autodoc: failed to import module 'pywikibot'; the following exception was raised:
14:44:00 Traceback (most recent call last):
14:44:00   File "/src/.tox/doc/lib/python3.4/site-packages/sphinx/ext/autodoc.py", line 385, in import_object
14:44:00     __import__(self.modname)
14:44:00   File "/src/pywikibot/__init__.py", line 37, in <module>
14:44:00     from pywikibot import config2 as config
14:44:00   File "/src/pywikibot/config2.py", line 370, in <module>
14:44:00     _base_dir = get_base_dir()
14:44:00   File "/src/pywikibot/config2.py", line 344, in get_base_dir
14:44:00     os.makedirs(dir, mode=private_files_permission)
14:44:00   File "/src/.tox/doc/lib/python3.4/os.py", line 227, in makedirs
14:44:00     makedirs(head, mode, exist_ok)
14:44:00   File "/src/.tox/doc/lib/python3.4/os.py", line 237, in makedirs
14:44:00     mkdir(name, mode)
14:44:00 PermissionError: [Errno 13] Permission denied: '/nonexistent'

@Legoktm @rafidaslam Well, I thought https://gerrit.wikimedia.org/r/#/c/403436/ could solve the issue, but maybe you are right. Look on lines 73 and 94 in https://gerrit.wikimedia.org/r/#/c/404448/. The source of doc is changed here, is that correct? (@hashar)

Change 409574 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] doc/conf.py: Use the parent of the current file, not the parent of cwd

https://gerrit.wikimedia.org/r/409574

Change 409574 merged by jenkins-bot:
[pywikibot/core@master] doc/conf.py: Use the parent of the current file, not the parent of cwd

https://gerrit.wikimedia.org/r/409574

The previous change didn't help.

Also noticed that the documentation build at http://pywikibot.readthedocs.io/en/latest/ is very outdated.
The last successful build is 2 years and 7 months old?
If we are not going to maintain that, it's perhaps better to delete it or make it private. @jayvdb @valhallasw

The previous change didn't help.

Maybe the issue is in the commit I mentioned above?

Also noticed that the documentation build at http://pywikibot.readthedocs.io/en/latest/ is very outdated.
The last successful build is 2 years and 7 months old?
If we are not going to maintain that, it's perhaps better to delete it or make it private. @jayvdb @valhallasw

Yeah, this should be either kept updated or deleted once for all

Also noticed that the documentation build at http://pywikibot.readthedocs.io/en/latest/ is very outdated.
The last successful build is 2 years and 7 months old?
If we are not going to maintain that, it's perhaps better to delete it or make it private. @jayvdb @valhallasw

It gets a code from jayvdb's fork on GitHub, which isn't updated since May 2017 (per T186206 I guess?)

Maybe the issue is in the commit I mentioned above?

Honestly, I don't know :) Right now, I'm trying to make sense of the log file. We have the following error:

00:00:33.283  /src/docs/api_ref/pywikibot.rst:4: WARNING: autodoc: failed to import module 'pywikibot'; the following exception was raised:
00:00:33.283  Traceback (most recent call last):
00:00:33.283    File "/src/.tox/doc/lib/python3.4/site-packages/sphinx/ext/autodoc.py", line 658, in import_object
00:00:33.284      __import__(self.modname)
00:00:33.284    File "/src/pywikibot/__init__.py", line 37, in <module>
00:00:33.284      from pywikibot import config2 as config
00:00:33.284    File "/src/pywikibot/config2.py", line 372, in <module>
00:00:33.284      _base_dir = get_base_dir()
00:00:33.284    File "/src/pywikibot/config2.py", line 344, in get_base_dir
00:00:33.285      os.makedirs(dir, mode=private_files_permission)
00:00:33.285    File "/src/.tox/doc/lib/python3.4/os.py", line 227, in makedirs
00:00:33.285      makedirs(head, mode, exist_ok)
00:00:33.285    File "/src/.tox/doc/lib/python3.4/os.py", line 237, in makedirs
00:00:33.285      mkdir(name, mode)
00:00:33.285  PermissionError: [Errno 13] Permission denied: '/nonexistent'

This error message is repeated over 300 times.

It seems that sphinx is unable to import pywikibot modules because every time it tries to import a module, the config2.py is loaded and it tries to create the user-config directory and it fails because it lacks the permissions.

That's strange because conf.py sets PYWIKIBOT2_NO_USER_CONFIG environment variable to 1 which is expected to disable that part of config2... I'm going to propose a change to skip the PermissionError and see what happens.

Change 409700 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] config2.py: Handle PermissionError while creating user-config directory

https://gerrit.wikimedia.org/r/409700

I see. I also don't really understand why os env variable is ignored, I feel like it is hardcoded by tox.ini's testenv and can not be changed somehow or it is hardcoded after conf.py is processed? Let's try to avoid PermissionsError and see, what we'll get

Change 409700 merged by jenkins-bot:
[pywikibot/core@master] config2.py: Handle PermissionError while creating user-config directory

https://gerrit.wikimedia.org/r/409700

Xqt claimed this task.

Thanks Dalba!

Dvorapa reopened this task as Open.EditedFeb 11 2018, 7:43 PM

Is it? Still missing are pywikibot modules (Page, Site, comms, compat)

Hmm, now we have a ton of warnings:

/src/docs/api_ref/pywikibot.rst:129: WARNING: toctree references unknown document 'api_ref/pywikibot.Page.content_model'
/src/docs/api_ref/pywikibot.rst:129: WARNING: toctree references unknown document 'api_ref/pywikibot.Page.data_repository'
/src/docs/api_ref/pywikibot.rst:129: WARNING: toctree references unknown document 'api_ref/pywikibot.Page.depth'
...

Seems like a relative path issue. Could be due to the source change that @Dvorapa was pointing out. I'm wondering if we could fix this by changing the working directory in conf.py? Patch coming...

Change 409713 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] conf.py: Change the current working directory to docs directory

https://gerrit.wikimedia.org/r/409713

Yeah, this looks like rel path issue. But wouldn't changing working directory break the other half that currently builds correctly?

@Dalba: The PermissionError was the root cause of blank documentation. This rel path issue existed even before, as you can see e.g. in commit L10N Update languages_by_size (21 November 2017). I would say we hadn't noticed half of the documentation is missing, until the issue with PermissionError popped out.

Change 409713 merged by jenkins-bot:
[pywikibot/core@master] conf.py: Change the current working directory to docs directory

https://gerrit.wikimedia.org/r/409713

Yeah, this looks like rel path issue. But wouldn't changing working directory break the other half that currently builds correctly?

Even if that happens, at least we will know for sure that it is a relative path issue.

@Dalba: The PermissionError was the root cause of blank documentation. This rel path issue existed even before, as you can see e.g. in commit L10N Update languages_by_size (21 November 2017). I would say we didn't notice half of the documentation is missing, until the issue with PermissionError popped out.

I see. So this part is probably unrelated to Docker migration. Good to know.

Ok, the main part looks solved. Missing are only docs for some scripts, which I believe have error in their doc comments (a problem we could detect in console)

Ok, the main part looks solved. Missing are only docs for some scripts, which I believe have error in their doc comments (a problem we could detect in console)

The funny thing is that I was actually going to change the working directory to docs (as the subject of https://gerrit.wikimedia.org/r/#/c/409713/ suggests) but instead of os.chdir(docs_dir) I've used os.chdir(repo_dir). Now that it has worked I'm not sure if I should correct that typo...

Thanks @Dalba! :)

And thanks back to you, resolving this issue wouldn't have been possible without yours and @Xqt's help and reviews.

Ok, the main part looks solved. Missing are only docs for some scripts, which I believe have error in their doc comments (a problem we could detect in console)

The funny thing is that I was actually going to change the working directory to docs (as the subject of https://gerrit.wikimedia.org/r/#/c/409713/ suggests) but instead of os.chdir(docs_dir) I've used os.chdir(repo_dir). Now that it has worked I'm not sure if I should correct that typo...

I noticed but wasn't sure if it is desired or just typo :D Finally it solved also T168831 and maybe helped with T109557, so would be ok just to leave it as is?

OK, let me analyze the current state.
Thanks to @Dalba solved issues are:

  • docs are back
  • vast majority of docs is built successfully and presented online

But there are still issues (I will create separate tasks):

  • readthedocs docs are horribly outdated (T187008)
  • still there are many (probably rel path related) warnings in console (T187009)
  • a really tiny part of scripts still doesn't build successfully (e.g. harvest_template.py, should be easy to solve)