diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30f1396175..543cc91b08 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,7 @@ env: MAPDL_PACKAGE: ghcr.io/ansys/mapdl ON_CI: True PYTEST_ARGUMENTS: '-vvv -ra --durations=10 --maxfail=3 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html' + BUILD_CHEATSHEET: True # Following env vars when changed will "reset" the mentioned cache, # by changing the cache file name. It is rendered as ...-v%RESET_XXX%-... diff --git a/doc/changelog.d/3460.miscellaneous.md b/doc/changelog.d/3460.miscellaneous.md new file mode 100644 index 0000000000..47a89a2618 --- /dev/null +++ b/doc/changelog.d/3460.miscellaneous.md @@ -0,0 +1 @@ +feat: having two global flags. One for visualizer and one for pyvista \ No newline at end of file diff --git a/doc/changelog.d/3468.fixed.md b/doc/changelog.d/3468.fixed.md new file mode 100644 index 0000000000..ab369c1e41 --- /dev/null +++ b/doc/changelog.d/3468.fixed.md @@ -0,0 +1 @@ +fix: add ``build cheatsheet`` as env variable within doc-build \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index b7f6cb287e..03bdeecd86 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -327,13 +327,17 @@ "json_url": f"https://{cname}/versions.json", "version_match": switcher_version, }, - "cheatsheet": { +} + +BUILD_CHEATSHEET = os.environ.get("BUILD_CHEATSHEET", "false").lower() == "true" + +if BUILD_CHEATSHEET: + html_theme_options["cheatsheet"] = { "file": "cheat_sheet/cheat_sheet.qmd", "title": "PyMAPDL cheat sheet", "version": f"v{version}", "pages": ["getting_started/learning"], - }, -} + } html_context = { "display_github": True, # Integrate GitHub diff --git a/src/ansys/mapdl/core/__init__.py b/src/ansys/mapdl/core/__init__.py index 6e2a224da3..6c50de1e1b 100644 --- a/src/ansys/mapdl/core/__init__.py +++ b/src/ansys/mapdl/core/__init__.py @@ -79,15 +79,23 @@ _LOCAL_PORTS = [] -# Per contract with Sphinx-Gallery, this method must be available at top level try: - import pyvista + from ansys.tools.visualization_interface import Plotter + + _HAS_VISUALIZER = True +except ModuleNotFoundError: # pragma: no cover + LOG.debug("The module 'ansys-tools-visualization_interface' is not installed.") + _HAS_VISUALIZER = False + +try: + import pyvista as pv _HAS_PYVISTA = True except ModuleNotFoundError: # pragma: no cover - LOG.debug("The module 'PyVista' is not installed.") + LOG.debug("The module 'pyvista' is not installed.") _HAS_PYVISTA = False + try: import importlib.metadata as importlib_metadata except ModuleNotFoundError: # pragma: no cover @@ -124,7 +132,7 @@ _HAS_ANSYS = _check_has_ansys() -if _HAS_PYVISTA: +if _HAS_VISUALIZER: from ansys.mapdl.core.plotting.theme import _apply_default_theme _apply_default_theme() diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index e87791e397..c4e37ee54d 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -41,7 +41,7 @@ from ansys.mapdl import core as pymapdl from ansys.mapdl.core import LOG as logger -from ansys.mapdl.core import _HAS_PYVISTA +from ansys.mapdl.core import _HAS_VISUALIZER from ansys.mapdl.core.commands import ( CMD_BC_LISTING, CMD_LISTING, @@ -255,7 +255,7 @@ def __init__( self._mute = False self._save_selection_obj = None - if _HAS_PYVISTA: + if _HAS_VISUALIZER: if use_vtk is not None: # pragma: no cover self._use_vtk = use_vtk else: @@ -263,7 +263,7 @@ def __init__( else: # pragma: no cover if use_vtk: raise ModuleNotFoundError( - "Using the keyword argument 'use_vtk' requires having Pyvista installed." + "Using the keyword argument 'use_vtk' requires having 'ansys-tools-visualization_interface' installed." ) else: self._use_vtk = False @@ -1142,7 +1142,6 @@ def _lockfile(self): def _mesh(self) -> "Archive": """Write entire archive to ASCII and read it in as an ``ansys.mapdl.core.Archive``""" - # lazy import here to avoid loading pyvista and vtk from ansys.mapdl.reader import Archive if self._archive_cache is None: diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index 27a5f3f06c..abdd55c027 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -31,7 +31,7 @@ from numpy.typing import DTypeLike, NDArray from ansys.mapdl.core import LOG as logger -from ansys.mapdl.core import _HAS_PYVISTA +from ansys.mapdl.core import _HAS_VISUALIZER from ansys.mapdl.core.commands import CommandListingOutput from ansys.mapdl.core.errors import ( CommandDeprecated, @@ -425,7 +425,7 @@ def kplot( HPT - Plots only those keypoints that are hard points. vtk : bool, optional - Plot the currently selected lines using ``pyvista``. + Plot the currently selected lines using ``ansys-tools-visualization_interface``. show_keypoint_numbering : bool, optional Display keypoint numbers when ``vtk=True``. @@ -439,9 +439,9 @@ def kplot( if vtk is None: vtk = self._use_vtk elif vtk is True: - if not _HAS_PYVISTA: # pragma: no cover + if not _HAS_VISUALIZER: # pragma: no cover raise ModuleNotFoundError( - "Using the keyword argument 'vtk' requires having Pyvista installed." + "Using the keyword argument 'vtk' requires having 'ansys-tools-visualization_interface' installed." ) if vtk: from ansys.mapdl.core.plotting.visualizer import MapdlPlotter @@ -500,7 +500,7 @@ def lplot( NINC are ignored and display all selected lines [LSEL]. vtk : bool, optional - Plot the currently selected lines using ``pyvista``. + Plot the currently selected lines using ``ansys-tools-visualization_interface``. show_line_numbering : bool, optional Display line and keypoint numbers when ``vtk=True``. @@ -531,9 +531,9 @@ def lplot( if vtk is None: vtk = self._use_vtk elif vtk is True: - if not _HAS_PYVISTA: # pragma: no cover + if not _HAS_VISUALIZER: # pragma: no cover raise ModuleNotFoundError( - "Using the keyword argument 'vtk' requires having Pyvista installed." + "Using the keyword argument 'vtk' requires having 'ansys-tools-visualization_interface' installed." ) if vtk: @@ -658,8 +658,8 @@ def aplot( when ``vtk=True``. vtk : bool, optional - Plot the currently selected areas using ``pyvista``. As - this creates a temporary surface mesh, this may have a + Plot the currently selected areas using ``ansys-tools-visualization_interface``. + As this creates a temporary surface mesh, this may have a long execution time for large meshes. quality : int, optional @@ -715,9 +715,9 @@ def aplot( if vtk is None: vtk = self._use_vtk elif vtk is True: - if not _HAS_PYVISTA: # pragma: no cover + if not _HAS_VISUALIZER: # pragma: no cover raise ModuleNotFoundError( - "Using the keyword argument 'vtk' requires having Pyvista installed." + "Using the keyword argument 'vtk' requires having 'ansys-tools-visualization_interface' installed." ) if vtk: @@ -891,8 +891,8 @@ def vplot( to .075). Ignored when ``vtk=True``. vtk : bool, optional - Plot the currently selected volumes using ``pyvista``. As - this creates a temporary surface mesh, this may have a + Plot the currently selected volumes using ``ansys-tools-visualization_interface``. + As this creates a temporary surface mesh, this may have a long execution time for large meshes. quality : int, optional @@ -917,9 +917,9 @@ def vplot( if vtk is None: vtk = self._use_vtk elif vtk is True: - if not _HAS_PYVISTA: # pragma: no cover + if not _HAS_VISUALIZER: # pragma: no cover raise ModuleNotFoundError( - "Using the keyword argument 'vtk' requires having Pyvista installed." + "Using the keyword argument 'vtk' requires having 'ansys-tools-visualization_interface' installed." ) if vtk: @@ -1096,12 +1096,12 @@ def nplot(self, nnum="", vtk=None, **kwargs): vtk = self._use_vtk if vtk is True: - if _HAS_PYVISTA: + if _HAS_VISUALIZER: # lazy import here to avoid top level import import pyvista as pv else: # pragma: no cover raise ModuleNotFoundError( - "Using the keyword argument 'vtk' requires having Pyvista installed." + "Using the keyword argument 'vtk' requires having 'ansys-tools-visualization_interface' installed." ) if "knum" in kwargs: @@ -1152,7 +1152,7 @@ def eplot(self, show_node_numbering=False, vtk=None, **kwargs): Parameters ---------- vtk : bool, optional - Plot the currently selected elements using ``pyvista``. + Plot the currently selected elements using ``ansys-tools-visualization_interface``. Defaults to current ``use_vtk`` setting. show_node_numbering : bool, optional @@ -1238,9 +1238,9 @@ def eplot(self, show_node_numbering=False, vtk=None, **kwargs): if vtk is None: vtk = self._use_vtk elif vtk is True: - if not _HAS_PYVISTA: # pragma: no cover + if not _HAS_VISUALIZER: # pragma: no cover raise ModuleNotFoundError( - "Using the keyword argument 'vtk' requires having Pyvista installed." + "Using the keyword argument 'vtk' requires having 'ansys-tools-visualization_interface' installed." ) if vtk: diff --git a/src/ansys/mapdl/core/misc.py b/src/ansys/mapdl/core/misc.py index 2a4529bd5a..f732f9712e 100644 --- a/src/ansys/mapdl/core/misc.py +++ b/src/ansys/mapdl/core/misc.py @@ -336,10 +336,18 @@ def __init__( "ansys.api.mapdl.v0", # ansys-api-mapdl-v0 "ansys.mapdl.reader", # ansys-mapdl-reader "google.protobuf", # protobuf library + "ansys-math-core", ] # Optional packages - optional = ["matplotlib", "pyvista", "pyiges", "tqdm"] + optional = [ + "matplotlib", + "pyvista", + "pyiges", + "tqdm", + "ansys-tools-visualization_interface", + "pandas", + ] if _HAS_PYANSYS_REPORT: # Combine all packages into one diff --git a/src/ansys/mapdl/core/plotting/__init__.py b/src/ansys/mapdl/core/plotting/__init__.py index 0939c45e6f..88dcdee1f1 100644 --- a/src/ansys/mapdl/core/plotting/__init__.py +++ b/src/ansys/mapdl/core/plotting/__init__.py @@ -19,7 +19,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from ansys.mapdl.core import _HAS_PYVISTA +from ansys.mapdl.core import _HAS_VISUALIZER from ansys.mapdl.core.plotting.consts import ( # noqa: F401 ALLOWED_TARGETS, BC_D, @@ -30,6 +30,6 @@ POINT_SIZE, ) -if _HAS_PYVISTA: +if _HAS_VISUALIZER: from ansys.mapdl.core.plotting.theme import MapdlTheme # noqa: F401 from ansys.mapdl.core.plotting.visualizer import MapdlPlotter # noqa: F401 diff --git a/src/ansys/mapdl/core/plotting/visualizer.py b/src/ansys/mapdl/core/plotting/visualizer.py index a513c50800..605e454ade 100644 --- a/src/ansys/mapdl/core/plotting/visualizer.py +++ b/src/ansys/mapdl/core/plotting/visualizer.py @@ -29,7 +29,7 @@ import numpy as np from numpy.typing import NDArray -from ansys.mapdl.core import _HAS_PYVISTA +from ansys.mapdl.core import _HAS_VISUALIZER from ansys.mapdl.core.misc import get_bounding_box from ansys.mapdl.core.plotting.consts import ( ALLOWED_TARGETS, @@ -42,7 +42,7 @@ ) from ansys.mapdl.core.plotting.theme import MapdlTheme -if _HAS_PYVISTA: +if _HAS_VISUALIZER: import pyvista as pv from ansys.mapdl.core.plotting.plotting_defaults import DefaultSymbol diff --git a/src/ansys/mapdl/core/post.py b/src/ansys/mapdl/core/post.py index ec77ffd2f7..f665d46930 100644 --- a/src/ansys/mapdl/core/post.py +++ b/src/ansys/mapdl/core/post.py @@ -25,11 +25,11 @@ import numpy as np -from ansys.mapdl.core import _HAS_PYVISTA +from ansys.mapdl.core import _HAS_VISUALIZER from ansys.mapdl.core.errors import MapdlRuntimeError from ansys.mapdl.core.misc import requires_package, supress_logging -if _HAS_PYVISTA: +if _HAS_VISUALIZER: from ansys.mapdl.core.plotting.visualizer import MapdlPlotter COMPONENT_STRESS_TYPE = ["X", "Y", "Z", "XY", "YZ", "XZ"]