Skip to content

Commit 5fc8ef1

Browse files
docs: examples are not being uploaded as assets (.py/.ipynb) (#1268)
Co-authored-by: pyansys-ci-bot <pyansys.github.bot@ansys.com>
1 parent a4ec588 commit 5fc8ef1

File tree

6 files changed

+95
-13
lines changed

6 files changed

+95
-13
lines changed

.github/workflows/ci_cd.yml

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,28 @@ jobs:
267267
group: pyansys-self-hosted
268268
labels: [Windows, pygeometry]
269269
steps:
270+
- uses: actions/checkout@v4
271+
272+
- name: Set up Python
273+
uses: actions/setup-python@v5
274+
with:
275+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
276+
270277
- name: Set up headless display
271278
uses: pyvista/setup-headless-display-action@v2
272279

280+
- name: Create Python venv
281+
run: |
282+
python -m venv .venv
283+
.\.venv\Scripts\Activate.ps1
284+
285+
- name: Install packages for documentation build
286+
run: |
287+
.\.venv\Scripts\Activate.ps1
288+
python -m pip install --upgrade pip
289+
pip install --upgrade build wheel
290+
pip install .[doc]
291+
273292
- name: Login to GitHub Container Registry
274293
uses: docker/login-action@v3
275294
with:
@@ -285,14 +304,49 @@ jobs:
285304
run:
286305
echo "ANSRV_GEO_LICENSE_SERVER=${{ secrets.INTERNAL_LICENSE_SERVER }}" | Out-File -FilePath $env:GITHUB_ENV -Append
287306

288-
- name: Start Geometry service
289-
run: docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ${{ env.ANSRV_GEO_IMAGE_WINDOWS_TAG }}
307+
- name: Start Geometry service and verify start
308+
run: |
309+
.\.venv\Scripts\Activate.ps1
310+
docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ${{ env.ANSRV_GEO_IMAGE_WINDOWS_TAG }}
311+
python -c "from ansys.geometry.core.connection.validate import validate; validate()"
312+
313+
- name: Check links
314+
run: |
315+
.\.venv\Scripts\Activate.ps1
316+
cd doc
317+
.\make.bat linkcheck
318+
319+
- name: Build the documentation (HTML)
320+
run: |
321+
.\.venv\Scripts\Activate.ps1
322+
cd doc
323+
.\make.bat html
324+
325+
- name: Build the documentation (PDF)
326+
run: |
327+
.\.venv\Scripts\Activate.ps1
328+
cd doc
329+
.\make.bat pdf
330+
331+
- name: Add assets to HTML docs
332+
run: |
333+
zip -r documentation-html.zip .\doc\_build\html
334+
mv documentation-html.zip .\doc\_build\html\_static\assets\download\
335+
cp doc/_build/latex/ansys-geometry-core.pdf .\doc\_build\html\_static\assets\download\
290336
291-
- name: Run Ansys documentation building action
292-
uses: ansys/actions/doc-build@v6
337+
- name: Upload HTML documentation
338+
uses: actions/upload-artifact@v4
293339
with:
294-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
295-
add-pdf-html-docs-as-assets: true
340+
name: documentation-html
341+
path: doc/_build/html
342+
retention-days: 7
343+
344+
- name: Upload PDF documentation
345+
uses: actions/upload-artifact@v4
346+
with:
347+
name: documentation-pdf
348+
path: doc/_build/latex/ansys-geometry-core*.pdf
349+
retention-days: 7
296350

297351
- name: Stop the Geometry service
298352
if: always()
@@ -310,6 +364,7 @@ jobs:
310364
docker rm $dockerContainers
311365
}
312366
367+
313368
# =================================================================================================
314369
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUNNING ON SELF-HOSTED RUNNER ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
315370
# =================================================================================================

doc/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ pdf:
3232

3333
# Build HTML files and generate examples as .py files
3434
html:
35-
@$(SPHINXBUILD) -M linkcheck "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
3635
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
36+
37+
# Linkcheck
38+
linkcheck:
39+
@$(SPHINXBUILD) -M linkcheck "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/changelog.d/1268.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs: examples are not being uploaded as assets (.py/.ipynb)

doc/make.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ set APIDIR=api
1515
set BUILDDIR=_build
1616

1717
if "%1" == "" goto help
18+
if "%1" == "help" goto help
1819
if "%1" == "clean" goto clean
1920
if "%1" == "pdf" goto pdf
2021
if "%1" == "html" goto html
22+
if "%1" == "linkcheck" goto linkcheck
2123

2224
%SPHINXBUILD% >NUL 2>NUL
2325
if errorlevel 9009 (
@@ -35,9 +37,12 @@ if errorlevel 9009 (
3537
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
3638
goto end
3739

40+
:linkcheck
41+
%SPHINXBUILD% -M linkcheck %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
42+
goto end
43+
3844
:html
3945
%SPHINXBUILD% -M html %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
40-
%SPHINXBUILD% -M linkcheck %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
4146
goto end
4247

4348
:pdf

doc/source/conf.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
import requests
1919
import sphinx
2020
from sphinx.builders.latex import LaTeXBuilder
21+
from sphinx.util import logging
2122

2223
from ansys.geometry.core import __version__
2324

25+
# Convert notebooks into Python scripts and include them in the output files
26+
logger = logging.getLogger(__name__)
27+
28+
2429
# For some reason the global var is not working on doc build...
2530
# import ansys.tools.visualization_interface as viz_interface
2631
#
@@ -393,9 +398,15 @@ def convert_notebooks_to_scripts(app: sphinx.application.Sphinx, exception):
393398
import subprocess
394399

395400
examples_output_dir = Path(app.outdir) / "examples"
401+
if not examples_output_dir.exists():
402+
logger.info("No examples directory found, skipping conversion...")
403+
return
404+
396405
notebooks = examples_output_dir.glob("**/*.ipynb")
406+
count = 0
397407
for notebook in notebooks:
398-
print(f"Converting {notebook}") # using jupytext
408+
count += 1
409+
logger.info(f"Converting {notebook}") # using jupytext
399410
output = subprocess.run(
400411
[
401412
"jupytext",
@@ -410,8 +421,13 @@ def convert_notebooks_to_scripts(app: sphinx.application.Sphinx, exception):
410421
)
411422

412423
if output.returncode != 0:
413-
print(f"Error converting {notebook} to script")
414-
print(output.stderr)
424+
logger.error(f"Error converting {notebook} to script")
425+
logger.error(output.stderr)
426+
427+
if count == 0:
428+
logger.warning("No notebooks found to convert to scripts")
429+
else:
430+
logger.info(f"Converted {count} notebooks to scripts")
415431

416432

417433
def setup(app: sphinx.application.Sphinx):
@@ -423,7 +439,8 @@ def setup(app: sphinx.application.Sphinx):
423439
app : sphinx.application.Sphinx
424440
Sphinx instance containing all the configuration for the documentation build.
425441
"""
426-
# Convert notebooks into Python scripts and include them in the output files
442+
logger.info(f"Configuring Sphinx hooks...")
427443
if BUILD_EXAMPLES:
428444
# Run at the end of the build process
445+
logger.info("Connecting build-finished hook for converting notebooks to scripts...")
429446
app.connect("build-finished", convert_notebooks_to_scripts)

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ dependencies = [
3030
"beartype>=0.11.0,<0.19",
3131
"grpcio>=1.35.0,<2",
3232
"grpcio-health-checking>=1.45.0,<2",
33-
"numpy>=1.20.3,<3",
33+
"numpy>=1.20.3,<3; python_version>='3.10'",
34+
"numpy>=1.20.3,<2; python_version=='3.9'", # Remove when Python 3.9 support is dropped
3435
"Pint>=0.18,<1",
3536
"protobuf>=3.20.2,<6",
3637
"pyvista>=0.37.0,<1",

0 commit comments

Comments
 (0)