fix mock pkgs in docs (#4591)

* fix mock pkgs in docs

* sphinx

* CI

Co-authored-by: chaton <thomas@grid.ai>
This commit is contained in:
Jirka Borovec 2020-11-10 14:57:21 +01:00 committed by GitHub
parent 343d19fa86
commit abf1d4b992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View File

@ -8,7 +8,7 @@ on: # Trigger the workflow on push or pull request, but only for the master bra
branches: [master, "release/*"]
jobs:
check-docs:
sphinx-check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
@ -48,6 +48,7 @@ jobs:
# python -m pip install --upgrade --user pip
pip install --requirement requirements.txt --upgrade-strategy only-if-needed --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --quiet
pip install --requirement requirements/extra.txt
pip install --requirement requirements/loggers.txt
pip install --requirement requirements/docs.txt
python --version
pip --version

View File

@ -304,22 +304,23 @@ def package_list_from_file(file):
return mocked_packages
# define mapping from PyPI names to python imports
PACKAGE_MAPPING = {
'Pillow': 'PIL',
'opencv-python': 'cv2',
'PyYAML': 'yaml',
'comet-ml': 'comet_ml',
'neptune-client': 'neptune',
}
MOCK_PACKAGES = []
if SPHINX_MOCK_REQUIREMENTS:
# mock also base packages when we are on RTD since we don't install them there
MOCK_PACKAGES += package_list_from_file(os.path.join(PATH_ROOT, 'requirements.txt'))
MOCK_PACKAGES += package_list_from_file(os.path.join(PATH_ROOT, 'requirements/extra.txt'))
MOCK_PACKAGES += package_list_from_file(os.path.join(PATH_ROOT, 'requirements/loggers.txt'))
MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES]
MOCK_MANUAL_PACKAGES = [
'torchvision',
'PIL',
# packages with different package name compare to import name
'yaml',
'comet_ml',
'neptune',
]
autodoc_mock_imports = MOCK_PACKAGES + MOCK_MANUAL_PACKAGES
autodoc_mock_imports = MOCK_PACKAGES
autosummary_generate = True