Skip to content

Commit

Permalink
Merge branch 'main' into release/0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys committed Oct 21, 2024
2 parents 801f928 + 099a4b9 commit e5db873
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 114 deletions.
79 changes: 6 additions & 73 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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"
Expand Down
23 changes: 16 additions & 7 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 7 additions & 32 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/ansys/aedt/toolkits/common/backend/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e5db873

Please sign in to comment.