Skip to content

Commit 569e7ea

Browse files
authored
Fixing linkcheck CICD (#2240)
* Attemp to fix linkcheck * Omitting github pymapdl links * fixing linkchecker again * Attempting to fix xvfb error * Increasing timeout for doc build * Skiping blocking link * Adding exceptions * Adding missing docstrings * Fixing docstrings * Adding always and removing make html * Replacing unit test example * Adding missing import * Removing circular import. * Adding missing typing. * Fixing link * Using tuple init to avoid init error
1 parent 36ed287 commit 569e7ea

File tree

12 files changed

+138
-42
lines changed

12 files changed

+138
-42
lines changed

.github/workflows/linkchecker.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ env:
1717
PYANSYS_OFF_SCREEN: True
1818
DPF_START_SERVER: False
1919
DPF_PORT: 21002
20-
DISPLAY: ':99.0'
2120

2221
jobs:
2322
linkchecker:
@@ -83,14 +82,24 @@ jobs:
8382
8483
- name: LinkCheck
8584
run: |
86-
make -C doc linkcheck SPHINXOPTS="-j auto -W --keep-going"
87-
85+
xvfb-run make -C doc linkcheck SPHINXOPTS="-j auto -W --keep-going"
86+
8887
- name: "Display linkchecker results"
88+
if: always()
8989
run: |
9090
echo "::group:: Display linkcher output" && cat doc/*/output.txt && echo "::endgroup::" || echo "Failed to display the output file."
9191
92+
- name: "Upload HTML Documentation"
93+
uses: actions/upload-artifact@v3
94+
if: always()
95+
with:
96+
name: documentation-html
97+
path: doc/_build/html
98+
retention-days: 7
99+
92100
- name: "Upload artifacts"
93101
uses: actions/upload-artifact@v3
102+
if: always()
94103
with:
95104
name: output
96105
path: doc/**/output.txt

doc/source/api/unit_testing.rst

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,32 +135,40 @@ Example
135135

136136
.. TO BE MODIFIED
137137
138-
The `test_math.py <pymapdl_test_math_>`_ file contains the unit tests and integration tests of the `ansys.math.core.math module <pymapdl_user_guide_math_>`_. These are just some of the many
139-
tests that you can find in the `test directory <pymapdl_tests_>`_.
138+
The `test_component.py <pymapdl_test_component_>`_ file contains
139+
the unit tests and integration tests of the
140+
:class:`ComponentManager <ansys.mapdl.core.component.ComponentManager>`.
141+
These are just some of the many tests that you can find in the
142+
`test directory <pymapdl_tests_>`_.
140143

141144
Here are some examples of how you use ``pytest``:
142145

143146
.. code:: python
144147
145-
import numpy as np
146-
from ansys.math.core.math import AnsMath
148+
import pytest
147149
148150
149-
@fixture
150-
def mm():
151-
return AnsMath()
151+
# 'cube_geom_and_mesh' is another fixture defined in 'conftest.py'
152+
@pytest.fixture(scope="function")
153+
def basic_components(mapdl, cube_geom_and_mesh):
154+
"""Given a model in 'cube_geom_and_mesh', let's define some components to work with later."""
155+
mapdl.components["mycomp1"] = "NODE", [1, 2, 3]
156+
mapdl.components["mycomp2"] = "KP", [1, 3]
152157
158+
mapdl.cmsel("s", "mycomp1")
159+
mapdl.cmsel("a", "mycomp2")
153160
154-
def test_rand(mm): # pass the 'mm' fixture as an argument.
155-
w = mm.rand(10)
156-
assert w.size == 10 # if it is False, AssertionError is raised
157161
162+
def test_dunder_methods_keys(mapdl, basic_components):
163+
assert ["MYCOMP1", "MYCOMP2"] == list(mapdl.components.list())
164+
165+
166+
def test_dunder_methods_types(mapdl, basic_components):
167+
assert ["NODE", "KP"] == list(mapdl.components.types())
168+
169+
170+
def test_dunder_methods_items(mapdl, basic_components):
171+
assert [("MYCOMP1", "NODE"), ("MYCOMP2", "KP")] == list(mapdl.components.items())
158172
159-
def test_matrix_addition(mm):
160-
m1 = mm.rand(10, 10)
161-
m2 = mm.rand(10, 10)
162-
m3 = m1 + m2
163-
assert np.allclose(m1.asarray() + m2.asarray(), m3.asarray())
164-
# if it is False, AssertionError is raised
165173
166174
For further explanations, see the `pytest documentation <pytest_>`_.

doc/source/conf.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,16 @@
193193
}
194194

195195
# Broken anchors:
196+
linkcheck_exclude_documents = ["index"]
197+
linkcheck_anchors_ignore_for_url = ["https://docs.pyvista.org/api/*"]
198+
linkcheck_ignore = [
199+
"https://github.com/ansys/pymapdl/*",
200+
"https://mapdl.docs.pyansys.com/*",
201+
"https://ansysaccount.b2clogin.com/*", # behind payfirewall
202+
"https://ansyshelp.ansys.com/*", # behind payfirewall
203+
]
196204
linkcheck_anchors_ignore = [
197-
# these anchors are picked by linkcheck as broken but thye are not.
205+
# these anchors are picked by linkcheck as broken but they are not.
198206
"firewall-rules",
199207
"pyvista.Plotter",
200208
"pyvista.UnstructuredGrid",

doc/source/getting_started/docker.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ in your console (or the output file):
195195
Using ``docker-compose`` to launch MAPDL
196196
----------------------------------------
197197

198-
You can also use the `docker-compose <docker_compose_>`_ command to launch MAPDL configured in
199-
a `docker-compose <docker_compose_>`_ file.
198+
You can also use the ``docker-compose`` command to launch MAPDL configured in
199+
a ``docker-compose`` file.
200200
This is useful if you want to load an already configured environment, or
201201
if you want to launch multiple instances of MAPDL or services.
202202

203203
For your convenience, the `docker <pymapdl_docker_dir_>`_ directory
204-
contains configured `docker-compose <docker_compose_>`_ files that you can
204+
contains configured ``docker-compose`` files that you can
205205
use.
206206

207207
Using the `docker-compose.yml <pymapdl_docker_compose_base_>`_ file is recommended.

doc/source/links.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
.. _pyansys_core: [email protected]
99

1010
.. #Other projects
11-
.. _dpf_core_gh: https://github.com/ansys/DPF-Core
12-
.. _dpf_post_gh: https://github.com/ansys/DPF-Post
11+
.. _dpf_core_gh: https://github.com/ansys/pydpf-core
12+
.. _dpf_post_gh: https://github.com/ansys/pydpf-post
1313
.. _dpf_core_docs: https://dpf.docs.pyansys.com
1414
.. _dpf_post_docs: https://post.docs.pyansys.com
1515
.. _legacy_reader_docs: https://reader.docs.pyansys.com/
@@ -121,7 +121,7 @@
121121
.. _pymapdl_dev_docs: https://mapdl.docs.pyansys.com/version/dev/
122122
.. _pymapdl_discussions: https://github.com/ansys/PyMAPDL/discussions
123123
.. _pymapdl_tests: https://github.com/ansys/pymapdl/tree/main/tests
124-
.. _pymapdl_test_math: https://github.com/ansys/pymapdl/blob/main/tests/test_math.py
124+
.. _pymapdl_test_component: https://github.com/ansys/pymapdl/blob/main/tests/test_component.py
125125
.. _pymapdl_user_guide_math: https://mapdl.docs.pyansys.com/version/dev/user_guide/math.html
126126
.. _mapdl_fixture: https://github.com/ansys/pymapdl/blob/fb5fb8b6201253f1bd56bdabee60a29abee8c7d8/tests/conftest.py#L254
127127
.. _pymapdl_examples: https://github.com/ansys/pymapdl/tree/main/examples

doc/source/substitutions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.. |pyansyscontact| replace:: `PyAnsys Core team <pyansys_core_>`_
1+
.. |pyansyscontact| replace:: `PyAnsys Core team <[email protected]>`_
22

3-
.. |pyansyscontactemail| replace:: pyansys_core_
3+
.. |pyansyscontactemail| replace:: [email protected]
44

55
.. # define a hard line break for HTML
66
.. |bl| raw:: html

examples/00-mapdl-examples/cyclic_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def gen_sector(mapdl, sectors):
168168
# in favor of DPF, but we can use this for now for some great animations.
169169
#
170170
# For more details regarding cyclic result post processing, see:
171-
# - `Understanding Nodal Diameters from a Cyclic Model Analysis <https://reader.docs.pyansys.com/examples/01-cyclic_results/academic_sector_nd.html>`_
171+
# - `Understanding Nodal Diameters from a Cyclic Model Analysis <https://reader.docs.pyansys.com/version/stable/examples/01-cyclic_results/academic_sector_nd.html>`_
172172
# - `Cyclic symmetry examples <https://dpf.docs.pyansys.com/version/stable/examples/11-cyclic-symmetry/index.html>`_
173173

174174
# grab the result object from MAPDL

src/ansys/mapdl/core/component.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import numpy as np
1818
from numpy.typing import NDArray
1919

20+
from ansys.mapdl.core import Mapdl
2021
from ansys.mapdl.core.errors import ComponentDoesNotExits, ComponentIsNotSelected
21-
from ansys.mapdl.core.mapdl import _MapdlCore
2222

2323
if TYPE_CHECKING: # pragma: no cover
2424
import logging
@@ -108,6 +108,13 @@ class Component(tuple):
108108
[1, 2, 3]
109109
"""
110110

111+
def __init__(self, *args, **kwargs):
112+
"""Component object"""
113+
# Using tuple init because using object.__init__
114+
# For more information visit:
115+
# https://stackoverflow.com/questions/47627298/how-is-tuple-init-different-from-super-init-in-a-subclass-of-tuple
116+
tuple.__init__(*args, **kwargs)
117+
111118
def __new__(
112119
cls,
113120
type_: ENTITIES_TYP,
@@ -195,11 +202,23 @@ class ComponentManager:
195202
Component(type='KP', items=(1, 2, 3))
196203
"""
197204

198-
def __init__(self, mapdl: _MapdlCore) -> None:
205+
def __init__(self, mapdl: Mapdl) -> None:
206+
"""Component Manager.
207+
208+
Component manager of an
209+
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.
210+
211+
Parameters
212+
----------
213+
mapdl : ansys.mapdl.core.Mapdl
214+
Mapdl instance which this class references to.
215+
"""
216+
from ansys.mapdl.core.mapdl import _MapdlCore
217+
199218
if not isinstance(mapdl, _MapdlCore):
200219
raise TypeError("Must be implemented from MAPDL class")
201220

202-
self._mapdl_weakref: weakref.ReferenceType[_MapdlCore] = weakref.ref(mapdl)
221+
self._mapdl_weakref: weakref.ReferenceType[Mapdl] = weakref.ref(mapdl)
203222
self.__comp: UNDERLYING_DICT = {}
204223
self._update_always: bool = True
205224
self._autoselect_components: bool = False # if True, PyMAPDL will try to select the CM first if it does not appear in the CMLIST output.
@@ -230,7 +249,7 @@ def default_entity_warning(self, value: bool):
230249
self._default_entity_warning = value
231250

232251
@property
233-
def _mapdl(self) -> _MapdlCore:
252+
def _mapdl(self) -> Mapdl:
234253
"""Return the weakly referenced instance of mapdl"""
235254
return self._mapdl_weakref()
236255

src/ansys/mapdl/core/krylov.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
import numpy as np
55

6+
from ansys.mapdl.core import Mapdl
67
from ansys.mapdl.core.errors import MapdlRuntimeError
78

8-
from .mapdl_grpc import MapdlGrpc
9-
109

1110
class KrylovSolver:
1211
"""Abstract mapdl krylov class. Created from a ``Mapdl`` instance.
@@ -46,9 +45,19 @@ class KrylovSolver:
4645
4746
"""
4847

49-
def __init__(self, mapdl):
50-
if not isinstance(mapdl, MapdlGrpc): # pragma: no cover
51-
raise TypeError("``mapdl`` must be a MapdlGrpc instance")
48+
def __init__(self, mapdl: Mapdl):
49+
"""Krylov analysis
50+
51+
Abstract mapdl krylov class. Created from an
52+
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.
53+
54+
Parameters
55+
----------
56+
mapdl : ansys.mapdl.core.Mapdl
57+
Mapdl instance which this class references to.
58+
"""
59+
if not isinstance(mapdl, Mapdl): # pragma: no cover
60+
raise TypeError("``mapdl`` must be an Mapdl class instance")
5261
self._mapdl_weakref = weakref.ref(mapdl)
5362
self.mm = self._mapdl.math
5463
self.jobname = self._mapdl.jobname

src/ansys/mapdl/core/mapdl_geometry.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from numpy.typing import NDArray
99
import pyvista as pv
1010

11-
from ansys.mapdl.core import _HAS_PYVISTA
11+
from ansys.mapdl.core import _HAS_PYVISTA, Mapdl
1212
from ansys.mapdl.core.errors import ComponentNoData, VersionError
1313

1414
if _HAS_PYVISTA:
@@ -131,7 +131,17 @@ class Geometry:
131131
132132
"""
133133

134-
def __init__(self, mapdl):
134+
def __init__(self, mapdl: Mapdl):
135+
"""Geometry manager
136+
137+
Class to help to manage geometry representations in an
138+
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.
139+
140+
Parameters
141+
----------
142+
mapdl : ansys.mapdl.core.Mapdl
143+
Mapdl instance which this class references to.
144+
"""
135145
from ansys.mapdl.core.mapdl import _MapdlCore
136146

137147
if not isinstance(mapdl, _MapdlCore):
@@ -1494,6 +1504,19 @@ class LegacyGeometry(Geometry):
14941504
selection within MAPDL.
14951505
"""
14961506

1507+
def __init__(self, mapdl: Mapdl):
1508+
"""Legacy geometry manager
1509+
1510+
Class to help to manage geometry representations in an
1511+
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.
1512+
1513+
Parameters
1514+
----------
1515+
mapdl : ansys.mapdl.core.Mapdl
1516+
Mapdl instance which this class references to.
1517+
"""
1518+
super().__init__(mapdl)
1519+
14971520
def keypoints(self) -> np.array: # type: ignore
14981521
"""Keypoint coordinates"""
14991522
return super().get_keypoints(return_as_array=True)

src/ansys/mapdl/core/parameters.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,17 @@ class Parameters:
7777
7878
"""
7979

80-
def __init__(self, mapdl):
80+
def __init__(self, mapdl: _MapdlCore):
81+
"""Parameters manager
82+
83+
Class to help to manage parameters in an
84+
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.
85+
86+
Parameters
87+
----------
88+
mapdl : ansys.mapdl.core.Mapdl
89+
Mapdl instance which this class references to.
90+
"""
8191
if not isinstance(mapdl, _MapdlCore):
8292
raise TypeError("Must be implemented from MAPDL class")
8393
self._mapdl_weakref = weakref.ref(mapdl)

src/ansys/mapdl/core/solution.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ class Solution:
2323
1.0
2424
"""
2525

26-
def __init__(self, mapdl):
26+
def __init__(self, mapdl: _MapdlCore):
27+
"""Solution manager
28+
29+
Class to help to manage the solution configuration in an
30+
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.
31+
32+
Parameters
33+
----------
34+
mapdl : ansys.mapdl.core.Mapdl
35+
Mapdl instance which this class references to.
36+
"""
2737
if not isinstance(mapdl, _MapdlCore):
2838
raise TypeError("Must be implemented from MAPDL class")
2939
self._mapdl_weakref = weakref.ref(mapdl)

0 commit comments

Comments
 (0)