From 7c9ac45dfed81cd807ce0863c2d24f233b655a7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:34:19 +0000 Subject: [PATCH 01/12] Bump sphinx from 7.1.0 to 8.1.3 in /requirements Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 7.1.0 to 8.1.3. - [Release notes](https://github.com/sphinx-doc/sphinx/releases) - [Changelog](https://github.com/sphinx-doc/sphinx/blob/v8.1.3/CHANGES.rst) - [Commits](https://github.com/sphinx-doc/sphinx/compare/v7.1.0...v8.1.3) --- updated-dependencies: - dependency-name: sphinx dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements/requirements_docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt index abf486f3bd0..97d3dbbdc61 100644 --- a/requirements/requirements_docs.txt +++ b/requirements/requirements_docs.txt @@ -7,7 +7,7 @@ nbsphinx==0.9.5 pypandoc==1.14 pytest-sphinx==0.6.3 pyvista==0.44.1 -sphinx==7.1.0 +sphinx==8.1.3 sphinx-copybutton==0.5.2 sphinx-gallery==0.18.0 sphinx-notfound-page==1.0.4 From 0d3b3c795e1d72a8945469aeb0f4cb3e11b0e064 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Garrido Date: Mon, 2 Dec 2024 09:07:02 +0100 Subject: [PATCH 02/12] ci: add tox.ini file --- .gitignore | 3 ++ tox.ini | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index cab916ab122..decf91fbfa8 100644 --- a/.gitignore +++ b/.gitignore @@ -192,3 +192,6 @@ src/ansys/grpc/ # C extensions *.so + +# Ignore auto-generated API reference +doc/source/api diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000000..dc3ff118061 --- /dev/null +++ b/tox.ini @@ -0,0 +1,87 @@ +[tox] +description = Default tox environments list +envlist = + code-style + doc-style-{linux,windows} + doc-{links,html,pdf} + dist +skip_missing_interpreters = true +isolated_build = true +isolated_build_env = build + +[testenv] +description = Checks for project testing with desired extras +basepython = + test39: python3.9 + test310: python3.10 + test311: python3.11 + test312: python3.12 + {style,doc,dist}: python3 +passenv = +setenv = + PYTHONUNBUFFERED = yes +deps = + -r{toxinidir}/requirements/requirements_test.txt +commands = + pytest {toxinidir}/tests + +[testenv:code-style] +description = Checks project code style +skip_install = true +deps = + pre-commit +commands = + pre-commit install + pre-commit run --all-files --show-diff-on-failure + +[testenv:doc-style-{linux,windows}] +description = Checks project documentation style +skip_install = true +allowlist_externals = + find + vale + bash + cmd +platform = + linux: linux + windows: win32 +commands = + linux: bash -c 'rst_files=$(find {toxinidir}/doc/source -type f -name "*.rst" ! -path "doc/source/api/*") && py_files=$(find {toxinidir}/examples -type f -name "*.py" ! -name "*_*") && vale_files="$rst_files $py_files" && vale sync --config="{toxinidir}/doc/.vale.ini" && vale --config="{toxinidir}/doc/.vale.ini" $rst_files' + windows: cmd /c "for /r {toxinidir}\doc\source %i in (*.rst) do @echo %i | findstr /v /i \doc\source\api\ > tmp_rst_files.txt" + windows: cmd /c "for /r {toxinidir}\examples %i in (*.py) do @echo %i | findstr /v /i *_* >> tmp_py_files.txt" + windows: cmd /c "setlocal enabledelayedexpansion && for /f %i in (tmp_rst_files.txt) do @set vale_files=!vale_files! %i && for /f %i in (tmp_py_files.txt) do @set vale_files=!vale_files! %i && vale sync --config="{toxinidir}\doc\.vale.ini" && vale --config="{toxinidir}\doc\.vale.ini" !rst_files! && endlocal" + +[testenv:doc-{clean,links,html,pdf}] +description = Check if documentation generates properly +allowlist_externals = + pdflatex +setenv = + SOURCE_DIR = doc/source + BUILD_DIR = doc/_build + STATIC_DIR = doc/source/_static + SPHINX_APIDOC_OPTIONS=inherited-members + links: BUILDER = linkcheck + html: BUILDER = html + pdf: BUILDER = latex + links,html,pdf: BUILDER_OPTS = --color -v -j auto -W --keep-going +deps = + -r{toxinidir}/requirements/requirements_docs.txt +commands = + # Remove rendered documentation and additional static files + clean: python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" "{toxinidir}/{env:BUILD_DIR}" + clean: python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" "{toxinidir}/{env:STATIC_DIR}/artifacts" + + # Render documentation with desired builder + links,html,pdf: sphinx-apidoc -o {toxinidir}/doc/source/api {toxinidir}/src/ansys {toxinidir}/src/ansys/dpf/core/log.py \ + {toxinidir}/src/ansys/dpf/core/help.py {toxinidir}/src/ansys/dpf/core/mapping_types.py {toxinidir}/src/ansys/dpf/core/ipconfig.py \ + {toxinidir}/src/ansys/dpf/core/field_base.py {toxinidir}/src/ansys/dpf/core/cache.py {toxinidir}/src/ansys/dpf/core/misc.py \ + {toxinidir}/src/ansys/dpf/core/check_version.py {toxinidir}/src/ansys/dpf/core/operators/build.py {toxinidir}/src/ansys/dpf/core/operators/specification.py \ + {toxinidir}/src/ansys/dpf/core/vtk_helper.py {toxinidir}/src/ansys/dpf/core/label_space.py {toxinidir}/src/ansys/dpf/core/examples/python_plugins/* \ + {toxinidir}/src/ansys/dpf/core/examples/examples.py {toxinidir}/src/ansys/dpf/gate/* {toxinidir}/src/ansys/dpf/gatebin/* {toxinidir}/src/ansys/grpc/dpf/* \ + {toxinidir}/src/ansys/dpf/core/property_fields_container.py \ + -f --implicit-namespaces --separate --no-headings + links,html,pdf: sphinx-build -d "{toxworkdir}/doc_doctree" {env:SOURCE_DIR} "{toxinidir}/{env:BUILD_DIR}/{env:BUILDER}" {env:BUILDER_OPTS} -b {env:BUILDER} + + # PDF documentation + pdf: pdflatex -interaction=nonstopmode -output-directory="{toxinidir}/{env:BUILD_DIR}/{env:BUILDER}" {toxinidir}/{env:BUILD_DIR}/{env:BUILDER}/ansys-dpf-core.tex + From 8169bc5e4129d6c8a34c67d833c37ff1b50fc1e4 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Garrido Date: Mon, 2 Dec 2024 09:42:22 +0100 Subject: [PATCH 03/12] fix: tox.ini syntax and gitignore --- .gitignore | 2 ++ tox.ini | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index decf91fbfa8..5d3337388ac 100644 --- a/.gitignore +++ b/.gitignore @@ -195,3 +195,5 @@ src/ansys/grpc/ # Ignore auto-generated API reference doc/source/api +doc/source/examples +doc/source/images/auto-generated diff --git a/tox.ini b/tox.ini index dc3ff118061..71fc5d36b81 100644 --- a/tox.ini +++ b/tox.ini @@ -55,6 +55,8 @@ commands = description = Check if documentation generates properly allowlist_externals = pdflatex +passenv = + ANSYSLMD_LICENSE_FILE setenv = SOURCE_DIR = doc/source BUILD_DIR = doc/_build @@ -63,7 +65,7 @@ setenv = links: BUILDER = linkcheck html: BUILDER = html pdf: BUILDER = latex - links,html,pdf: BUILDER_OPTS = --color -v -j auto -W --keep-going + links,html,pdf: BUILDER_OPTS = --color -v --keep-going deps = -r{toxinidir}/requirements/requirements_docs.txt commands = From 0ed9e8011aba27776faa68253a7f0cc36a550b0a Mon Sep 17 00:00:00 2001 From: moe-ad Date: Mon, 2 Dec 2024 09:43:04 +0100 Subject: [PATCH 04/12] fix: ignoring failing files results in successful doc build. --- doc/source/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/source/conf.py b/doc/source/conf.py index 7390890e9c3..7483142d794 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -62,6 +62,9 @@ ignored_pattern += f"|{example_name}" ignored_pattern += "|11-server_types.py" ignored_pattern += "|06-distributed_stress_averaging.py" +ignored_pattern += "|00-wrapping_numpy_capabilities.py" +ignored_pattern += "|01-package_python_operators.py" +ignored_pattern += "|02-python_operators_with_dependencies.py" ignored_pattern += r")" # -- General configuration --------------------------------------------------- From 85dda6e7cce049c18b59df79e21d6074dcae4216 Mon Sep 17 00:00:00 2001 From: moe-ad Date: Mon, 2 Dec 2024 16:31:10 +0100 Subject: [PATCH 05/12] docs: added some hooks for troubleshooting the issue --- doc/source/conf.py | 90 +++++++++++++++++++++++++++++- requirements/requirements_docs.txt | 1 + 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 7483142d794..f4116e267f2 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -5,6 +5,8 @@ import numpy as np import pyvista +import sphinx +from sphinx.util import logging from ansys.dpf.core import __version__, server, server_factory from ansys.dpf.core.examples import get_example_required_minimum_dpf_version from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_light_mode, pyansys_logo_dark_mode @@ -158,7 +160,7 @@ def reset_servers(gallery_conf, fname, when): try: # check whether the process name matches if proc_name in proc.name(): - # proc.kill() + proc.kill() nb_procs += 1 except psutil.NoSuchProcess: pass @@ -326,3 +328,89 @@ def reset_servers(gallery_conf, fname, when): # A list of files that should not be packed into the epub file. epub_exclude_files = ["search.html"] + + +def check_global_servers_and_close(app: sphinx.application.Sphinx, exception: Exception) -> None: + from ansys.dpf.core import server, _server_instances + import copy + import psutil + import gc + + gc.collect + + # Server instances are different from processes. + # Ideally just closing the servers => no running processes + # Server instances should be closed first + if _server_instances: + print(f"{len(_server_instances)} dpf server instances found running") + print("Closing server instances") + + copy_instances = copy.deepcopy(_server_instances) + for instance in copy_instances: + try: + if hasattr(instance(), "shutdown"): + instance().shutdown() + except Exception as e: + print(e.args) + pass + server.shutdown_global_server() + print(f"{len(_server_instances)} dpf server instances found running after closing") + else: + print("no server instances found running") + + # Subsequently check running processes and close + proc_name = "Ans.Dpf.Grpc" + nb_procs = 0 + for proc in psutil.process_iter(): + try: + # check whether the process name matches + if proc_name in proc.name(): + proc.kill() + nb_procs += 1 + except psutil.NoSuchProcess: + pass + + # Check if processes were actually killed + if nb_procs: + print(f"Killed {nb_procs} {proc_name} processes.") + else: + print(f"No processes were found running") + +# def reset_server_after_sphinx_gallery(app: sphinx.application.Sphinx, exception: Exception) -> None: +# """ +# Stop running dpf servers before regardless of documentation build sucess. + +# Parameters +# ---------- +# app : sphinx.application.Sphinx +# Sphinx application instance containing the all the doc build configuration. + +# """ +# from ansys.dpf.core import server + +# logger = logging.getLogger(__name__) + +# try: +# server.check_global_servers_and_close() +# except exception: +# if "Extension error" in str(exception): +# server.check_global_servers_and_close() +# logger.warning("An error occurred during sphinx gallery execution") +# raise exception +# else: +# logger.warning("An error outside sphinx gallery execution occurred") +# raise exception + + +def setup(app: sphinx.application.Sphinx) -> None: + """ + Run hook function(s) during the documentation build. + + Parameters + ---------- + app : sphinx.application.Sphinx + Sphinx application instance containing the all the doc build configuration. + """ + + app.connect("builder-inited", check_global_servers_and_close) + app.connect("build-finished", check_global_servers_and_close) \ No newline at end of file diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt index aa8c1c6025f..8e283d93be4 100644 --- a/requirements/requirements_docs.txt +++ b/requirements/requirements_docs.txt @@ -15,3 +15,4 @@ sphinx-reredirects==0.1.3 sphinx_design==0.6.1 sphinxcontrib-napoleon==0.7 vtk==9.3.1 +jupyterlab==4.3.1 From bbe1c69efd7694dce44fac1ca6541a44357c649e Mon Sep 17 00:00:00 2001 From: moe-ad Date: Tue, 3 Dec 2024 05:59:38 +0100 Subject: [PATCH 06/12] fix: updated server and process closing logic after sphinx-gallery execution --- doc/source/conf.py | 54 +++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index f4116e267f2..24d83d908ec 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -64,8 +64,8 @@ ignored_pattern += f"|{example_name}" ignored_pattern += "|11-server_types.py" ignored_pattern += "|06-distributed_stress_averaging.py" -ignored_pattern += "|00-wrapping_numpy_capabilities.py" -ignored_pattern += "|01-package_python_operators.py" +# ignored_pattern += "|00-wrapping_numpy_capabilities.py" +# ignored_pattern += "|01-package_python_operators.py" ignored_pattern += "|02-python_operators_with_dependencies.py" ignored_pattern += r")" @@ -330,7 +330,7 @@ def reset_servers(gallery_conf, fname, when): epub_exclude_files = ["search.html"] -def check_global_servers_and_close(app: sphinx.application.Sphinx, exception: Exception) -> None: +def close_live_servers_and_processes(app: sphinx.application.Sphinx) -> None: from ansys.dpf.core import server, _server_instances import copy import psutil @@ -339,24 +339,27 @@ def check_global_servers_and_close(app: sphinx.application.Sphinx, exception: Ex gc.collect # Server instances are different from processes. - # Ideally just closing the servers => no running processes + # Ideally no running servers => no running processes # Server instances should be closed first - if _server_instances: - print(f"{len(_server_instances)} dpf server instances found running") - print("Closing server instances") + running_servers = sum([1 if instance().live else 0 for instance in _server_instances]) + if running_servers: + print(f"{running_servers} live dpf servers found") + print("Closing servers") copy_instances = copy.deepcopy(_server_instances) for instance in copy_instances: try: - if hasattr(instance(), "shutdown"): - instance().shutdown() + instance_object = instance() + if hasattr(instance_object, "shutdown"): + instance_object.shutdown() except Exception as e: print(e.args) pass server.shutdown_global_server() - print(f"{len(_server_instances)} dpf server instances found running after closing") + running_servers = sum([1 if instance().live else 0 for instance in _server_instances]) + print(f"Found {running_servers} live dpf servers after closing") else: - print("no server instances found running") + print("No live dpf servers found") # Subsequently check running processes and close proc_name = "Ans.Dpf.Grpc" @@ -376,32 +379,6 @@ def check_global_servers_and_close(app: sphinx.application.Sphinx, exception: Ex else: print(f"No processes were found running") -# def reset_server_after_sphinx_gallery(app: sphinx.application.Sphinx, exception: Exception) -> None: -# """ -# Stop running dpf servers before regardless of documentation build sucess. - -# Parameters -# ---------- -# app : sphinx.application.Sphinx -# Sphinx application instance containing the all the doc build configuration. - -# """ -# from ansys.dpf.core import server - -# logger = logging.getLogger(__name__) - -# try: -# server.check_global_servers_and_close() -# except exception: -# if "Extension error" in str(exception): -# server.check_global_servers_and_close() -# logger.warning("An error occurred during sphinx gallery execution") -# raise exception -# else: -# logger.warning("An error outside sphinx gallery execution occurred") -# raise exception - - def setup(app: sphinx.application.Sphinx) -> None: """ Run hook function(s) during the documentation build. @@ -412,5 +389,4 @@ def setup(app: sphinx.application.Sphinx) -> None: Sphinx application instance containing the all the doc build configuration. """ - app.connect("builder-inited", check_global_servers_and_close) - app.connect("build-finished", check_global_servers_and_close) \ No newline at end of file + app.connect("builder-inited", close_live_servers_and_processes) \ No newline at end of file From 2373a6f182a30891e3749b7bd733c1b4380c3d85 Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 11 Dec 2024 14:19:26 +0100 Subject: [PATCH 07/12] fix: modified function checking server closure after sphinx gallery execution --- doc/source/conf.py | 42 +++++------------------------- requirements/requirements_docs.txt | 1 - 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 24d83d908ec..a5721b59957 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,12 +1,10 @@ import os -import sys from glob import glob from datetime import datetime import numpy as np import pyvista import sphinx -from sphinx.util import logging from ansys.dpf.core import __version__, server, server_factory from ansys.dpf.core.examples import get_example_required_minimum_dpf_version from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_light_mode, pyansys_logo_dark_mode @@ -331,37 +329,15 @@ def reset_servers(gallery_conf, fname, when): def close_live_servers_and_processes(app: sphinx.application.Sphinx) -> None: - from ansys.dpf.core import server, _server_instances - import copy + # Adapted from reset_servers() function, so this can be called after + # sphinx gallery finishes execution import psutil + from ansys.dpf.core import server import gc - gc.collect - - # Server instances are different from processes. - # Ideally no running servers => no running processes - # Server instances should be closed first - running_servers = sum([1 if instance().live else 0 for instance in _server_instances]) - if running_servers: - print(f"{running_servers} live dpf servers found") - print("Closing servers") - - copy_instances = copy.deepcopy(_server_instances) - for instance in copy_instances: - try: - instance_object = instance() - if hasattr(instance_object, "shutdown"): - instance_object.shutdown() - except Exception as e: - print(e.args) - pass - server.shutdown_global_server() - running_servers = sum([1 if instance().live else 0 for instance in _server_instances]) - print(f"Found {running_servers} live dpf servers after closing") - else: - print("No live dpf servers found") - - # Subsequently check running processes and close + gc.collect() + server.shutdown_all_session_servers() + proc_name = "Ans.Dpf.Grpc" nb_procs = 0 for proc in psutil.process_iter(): @@ -373,12 +349,6 @@ def close_live_servers_and_processes(app: sphinx.application.Sphinx) -> None: except psutil.NoSuchProcess: pass - # Check if processes were actually killed - if nb_procs: - print(f"Killed {nb_procs} {proc_name} processes.") - else: - print(f"No processes were found running") - def setup(app: sphinx.application.Sphinx) -> None: """ Run hook function(s) during the documentation build. diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt index 8e283d93be4..aa8c1c6025f 100644 --- a/requirements/requirements_docs.txt +++ b/requirements/requirements_docs.txt @@ -15,4 +15,3 @@ sphinx-reredirects==0.1.3 sphinx_design==0.6.1 sphinxcontrib-napoleon==0.7 vtk==9.3.1 -jupyterlab==4.3.1 From 902df6c89d5d9ba3e9a551488148f154a8fe1be9 Mon Sep 17 00:00:00 2001 From: moe-ad Date: Thu, 12 Dec 2024 13:02:33 +0100 Subject: [PATCH 08/12] fix: added ipykernel to address 'No python3 ...' error --- requirements/requirements_docs.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt index aa8c1c6025f..afa9d982804 100644 --- a/requirements/requirements_docs.txt +++ b/requirements/requirements_docs.txt @@ -3,6 +3,7 @@ enum-tools[sphinx]==0.12.0 graphviz==0.20.1 imageio==2.36.0 imageio-ffmpeg==0.5.1 +ipykernel==6.29.5 nbsphinx==0.9.5 pypandoc==1.14 pytest-sphinx==0.6.3 From 9bb195f184d716a29ede795ef46bb560ed8b6849 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:42:41 +0100 Subject: [PATCH 09/12] fix: build issues --- requirements/requirements_docs.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt index afa9d982804..77fc3c6053d 100644 --- a/requirements/requirements_docs.txt +++ b/requirements/requirements_docs.txt @@ -1,4 +1,5 @@ ansys-sphinx-theme==1.2.2 +astroid==3.3.8 enum-tools[sphinx]==0.12.0 graphviz==0.20.1 imageio==2.36.0 From e548f07eadd8e9194d98a1c5817896200cb10ec3 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:45:45 +0100 Subject: [PATCH 10/12] Update requirements/requirements_docs.txt --- requirements/requirements_docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt index 9043a936f97..2e580a2fd41 100644 --- a/requirements/requirements_docs.txt +++ b/requirements/requirements_docs.txt @@ -3,7 +3,7 @@ enum-tools[sphinx]==0.12.0 graphviz==0.20.1 imageio==2.36.0 imageio-ffmpeg==0.5.1 -nbsphinx==0.9.5 +nbsphinx==0.9.6 pypandoc==1.14 pytest-sphinx==0.6.3 pyvista==0.44.2 From f5ac3a1d14bca075981cf6807f2998bc65868e1c Mon Sep 17 00:00:00 2001 From: moe-ad Date: Tue, 11 Feb 2025 16:12:23 +0100 Subject: [PATCH 11/12] fix: activate failing example --- doc/source/conf.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 5db6f31ef9c..6cb5c2157c9 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,13 +1,19 @@ -import os -from glob import glob from datetime import datetime +from glob import glob +import os +from ansys_sphinx_theme import ( + ansys_favicon, + get_version_match, + pyansys_logo_dark_mode, + pyansys_logo_light_mode, +) import numpy as np import pyvista import sphinx + from ansys.dpf.core import __version__, server, server_factory from ansys.dpf.core.examples import get_example_required_minimum_dpf_version -from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_light_mode, pyansys_logo_dark_mode # Manage errors pyvista.set_error_output_file("errors.txt") @@ -62,9 +68,6 @@ ignored_pattern += f"|{example_name}" ignored_pattern += "|11-server_types.py" ignored_pattern += "|06-distributed_stress_averaging.py" -# ignored_pattern += "|00-wrapping_numpy_capabilities.py" -# ignored_pattern += "|01-package_python_operators.py" -ignored_pattern += "|02-python_operators_with_dependencies.py" ignored_pattern += r")" # Autoapi ignore pattern @@ -164,9 +167,11 @@ def reset_servers(gallery_conf, fname, when): + import gc + import psutil + from ansys.dpf.core import server - import gc gc.collect() server.shutdown_all_session_servers() @@ -262,7 +267,7 @@ def reset_servers(gallery_conf, fname, when): # Configuration for Sphinx autoapi suppress_warnings = [ - "autoapi.python_import_resolution", # Todo: remove suppression of this warning in the future + "autoapi.python_import_resolution", # TODO: remove suppression of this warning in the future #1967 "design.grid", "config.cache", "design.fa-build", @@ -375,9 +380,11 @@ def reset_servers(gallery_conf, fname, when): def close_live_servers_and_processes(app: sphinx.application.Sphinx) -> None: # Adapted from reset_servers() function, so this can be called after # sphinx gallery finishes execution + import gc + import psutil + from ansys.dpf.core import server - import gc gc.collect() server.shutdown_all_session_servers() From 5c8a0900ad3dce8289b5af9a6f50f62a237ce13b Mon Sep 17 00:00:00 2001 From: moe-ad Date: Mon, 17 Feb 2025 12:14:02 +0100 Subject: [PATCH 12/12] fix: remove reset servers logic --- doc/source/conf.py | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 6cb5c2157c9..b9f6f7810d4 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -10,7 +10,6 @@ ) import numpy as np import pyvista -import sphinx from ansys.dpf.core import __version__, server, server_factory from ansys.dpf.core.examples import get_example_required_minimum_dpf_version @@ -374,40 +373,4 @@ def reset_servers(gallery_conf, fname, when): # epub_uid = '' # A list of files that should not be packed into the epub file. -epub_exclude_files = ["search.html"] - - -def close_live_servers_and_processes(app: sphinx.application.Sphinx) -> None: - # Adapted from reset_servers() function, so this can be called after - # sphinx gallery finishes execution - import gc - - import psutil - - from ansys.dpf.core import server - - gc.collect() - server.shutdown_all_session_servers() - - proc_name = "Ans.Dpf.Grpc" - nb_procs = 0 - for proc in psutil.process_iter(): - try: - # check whether the process name matches - if proc_name in proc.name(): - proc.kill() - nb_procs += 1 - except psutil.NoSuchProcess: - pass - -def setup(app: sphinx.application.Sphinx) -> None: - """ - Run hook function(s) during the documentation build. - - Parameters - ---------- - app : sphinx.application.Sphinx - Sphinx application instance containing the all the doc build configuration. - """ - - app.connect("builder-inited", close_live_servers_and_processes) \ No newline at end of file +epub_exclude_files = ["search.html"] \ No newline at end of file