From edf3e9d132da15cb9f75d06dcb4da62bda571f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Morais?= <146729917+SMoraisAnsys@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:11:54 +0200 Subject: [PATCH 1/2] CHORE: Update docs' CI and dependencies (#169) --- .github/workflows/ci_cd.yml | 79 +++---------------------------------- doc/Makefile | 23 +++++++---- doc/make.bat | 12 ++++++ doc/source/conf.py | 39 ++++-------------- pyproject.toml | 2 +- 5 files changed, 42 insertions(+), 113 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 2493eaf4..65fd773e 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -19,9 +19,7 @@ env: LIBRARY_NAME: 'ansys-aedt-toolkits-common' LIBRARY_NAMESPACE: 'ansys.aedt.toolkits.common' ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} - MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} - MEILISEARCH_HOST_URL: ${{ vars.MEILISEARCH_HOST_URL }} - MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }} + ON_CI: True concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -53,78 +51,13 @@ jobs: needs: [ doc-style ] timeout-minutes: 10 steps: - - uses: actions/checkout@v4 - - - name: "Set up Python" - uses: ansys/actions/_setup-python@main + - name: Build documentation + uses: ansys/actions/doc-build@v8 with: python-version: ${{ env.MAIN_PYTHON_VERSION }} - use-cache: false - - - name: 'Create virtual env' - run: | - python -m venv .venv - - - name: "Update pip" - run: | - . .venv\Scripts\Activate.ps1 - python -m pip install pip -U - python -m pip install wheel setuptools -U - python -c "import sys; print(sys.executable)" - - - name: Install common toolkit with doc dependencies - run: | - . .venv\Scripts\Activate.ps1 - pip install . - pip install .[doc] - - - name: Uninstall conflicting CI packages - run: | - .venv\Scripts\Activate.ps1 - pip uninstall vtk pypandoc -y - - - name: Install CI related dependencies - run: | - .venv\Scripts\Activate.ps1 - pip install --extra-index-url https://wheels.vtk.org vtk-osmesa==9.2.20230527.dev0 - pip install "pypandoc-binary>=1.10.0,<1.14" - - - name: Retrieve common toolkit version - run: | - . .venv\Scripts\Activate.ps1 - echo "Common Toolkit version is: $(python -c "from ansys.aedt.toolkits.common import __version__; print(); print(__version__)")" - - - name: Build the documentation (HTML) - run: | - .\.venv\Scripts\Activate.ps1 - cd doc - .\make.bat html - - - name: Build the documentation (PDF) - run: | - .\.venv\Scripts\Activate.ps1 - cd doc - .\make.bat pdf - - - name: Add assets to HTML docs - run: | - zip -r documentation-html.zip .\doc\_build\html - mv documentation-html.zip .\doc\_build\html\_static\assets\download\ - cp doc/_build/latex/ansys-aedt-toolkits-common.pdf .\doc\_build\html\_static\assets\download\ - - - name: Upload HTML Documentation artifact - uses: actions/upload-artifact@v4 - with: - name: documentation-html - path: doc/_build/html - retention-days: 1 - - - name: Upload PDF Documentation artifact - uses: actions/upload-artifact@v4 - with: - name: documentation-pdf - path: doc/_build/latex/*.pdf - retention-days: 7 + use-python-cache: false + add-pdf-html-docs-as-assets: true + check-links: true smoke-tests: name: "Build and Smoke tests" diff --git a/doc/Makefile b/doc/Makefile index 1b6af1a4..061db320 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -14,23 +14,32 @@ help: .PHONY: help Makefile -clean: - rm -rf $(BUILDDIR)/* - rm -rf examples/ - find . -type d -name "_autosummary" -exec rm -rf {} + +.install-deps: + @pip freeze | grep -q "vtk-osmesa" && is_vtk_osmesa_installed="yes" || is_vtk_osmesa_installed="no" + @if [ "${ON_CI}" = "True" ] && [ "$$is_vtk_osmesa_installed" != "yes" ]; then \ + @echo "Removing vtk to avoid conflicts with vtk-osmesa needed for CI/CD"; \ + pip uninstall --yes vtk; \ + @echo "Installing vtk-osmesa"; \ + pip install --extra-index-url https://wheels.vtk.org vtk-osmesa; \ + fi # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile +%: .install-deps Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +clean: .install-deps + rm -rf $(BUILDDIR)/* + rm -rf examples/ + find . -type d -name "_autosummary" -exec rm -rf {} + + # build html docs in parallel using all available CPUs # WARNING: this is a resource hog -html: +html: .install-deps $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -j auto # Build pdf docs. -pdf: +pdf: .install-deps @$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true (test -f $(BUILDDIR)/latex/ansys-aedt-toolkits-common.pdf && echo pdf exists) || exit 1 diff --git a/doc/make.bat b/doc/make.bat index 8b401058..7b7dbf69 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -13,6 +13,18 @@ if "%SPHINXOPTS%" == "" ( set SOURCEDIR=source set BUILDDIR=_build +REM This LOCs are used to uninstall and install specific package(s) during CI/CD +for /f %%i in ('pip freeze ^| findstr /c:"vtk-osmesa"') do set is_vtk_osmesa_installed=%%i +if NOT "%is_vtk_osmesa_installed%" == "vtk-osmesa" if "%ON_CI%" == "true" ( + @ECHO ON + echo "Removing vtk to avoid conflicts with vtk-osmesa" + @ECHO OFF + pip uninstall --yes vtk + @ECHO ON + echo "Installing vtk-osmesa" + @ECHO OFF + pip install --extra-index-url https://wheels.vtk.org vtk-osmesa) + if "%1" == "" goto help if "%1" == "clean" goto clean if "%1" == "pdf" goto pdf diff --git a/doc/source/conf.py b/doc/source/conf.py index ee52e001..1be3aa61 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -51,30 +51,6 @@ # Sphinx event hooks -def check_example_error(app, pagename, templatename, context, doctree): - """Log an error if the execution of an example as a notebook triggered an error. - - Since the documentation build might not stop if the execution of a notebook triggered - an error, we use a flag to log that an error is spotted in the html page context. - """ - # Check if the HTML contains an error message - if pagename.startswith("examples") and not pagename.endswith("/index"): - if any( - map( - lambda msg: msg in context["body"], - ["UsageError", "NameError", "DeadKernelError", "NotebookError"], - ) - ): - logger.error(f"An error was detected in file {pagename}") - app.builder.config.html_context["build_error"] = True - - -def check_build_finished_without_error(app, exception): - """Check that no error is detected along the documentation build process.""" - if app.builder.config.html_context.get("build_error", False): - raise Exception("Build failed due to an error in html-page-context") - - def check_pandoc_installed(app): """Ensure that pandoc is installed""" import pypandoc @@ -92,8 +68,6 @@ def check_pandoc_installed(app): def setup(app): app.connect("builder-inited", check_pandoc_installed) - app.connect("html-page-context", check_example_error) - app.connect("build-finished", check_build_finished_without_error) print(__version__) @@ -145,12 +119,6 @@ def setup(app): "icon": "fa fa-file-pdf fa-fw", }, ], - "use_meilisearch": { - "api_key": os.getenv("MEILISEARCH_PUBLIC_API_KEY", ""), - "index_uids": { - f"pyaedt-toolkits-common-v{get_version_match(__version__).replace('.', '-')}": "AEDT TOOLKITS COMMON API", - }, - }, } # Sphinx extensions @@ -196,6 +164,13 @@ def setup(app): # type, unless multiple values are being returned" } +# Removing check on repo lines of code as using line numbers as anchor is not working +linkcheck_ignore = [ + "https://github.com/ansys/pyaedt-toolkits-common/blob/main/src/ansys/aedt/toolkits/common/ui/" + "actions_generic.py#L165", + "https://github.com/ansys/pyaedt-toolkits-common/blob/main/src/ansys/aedt/toolkits/common/ui/" + "actions_generic.py#L143", +] # static path html_static_path = ["_static"] diff --git a/pyproject.toml b/pyproject.toml index e504bd00..755f6637 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ doc = [ "pyaedt[all]>=0.10.0,<0.12", "recommonmark>=0.7.0,<0.8", "pyside6==6.7.3", - "ansys-sphinx-theme>=0.10.0,<1.1", + "ansys-sphinx-theme>=0.10.0,<1.2", "numpydoc>=1.5.0,<1.9", "Sphinx>=7.1.0,<8.2", "sphinx-copybutton>=0.5.0,<0.6", From 099a4b97d407a05ba409be1790de149d35d0837a Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:00:17 +0200 Subject: [PATCH 2/2] Update list installed versions (#173) --- src/ansys/aedt/toolkits/common/backend/api.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ansys/aedt/toolkits/common/backend/api.py b/src/ansys/aedt/toolkits/common/backend/api.py index f6556c8d..7e71daed 100644 --- a/src/ansys/aedt/toolkits/common/backend/api.py +++ b/src/ansys/aedt/toolkits/common/backend/api.py @@ -34,7 +34,6 @@ import ansys.aedt.core from ansys.aedt.core import Desktop from ansys.aedt.core.generic.general_methods import active_sessions -from ansys.aedt.core.misc import list_installed_ansysem if ansys.aedt.core.__version__ <= "0.11.0": from ansys.aedt.core.misc import list_installed_ansysem