Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing linkcheck CICD #2240

Merged
merged 23 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/linkchecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ env:
PYANSYS_OFF_SCREEN: True
DPF_START_SERVER: False
DPF_PORT: 21002
DISPLAY: ':99.0'

jobs:
linkchecker:
Expand Down Expand Up @@ -83,14 +82,24 @@ jobs:

- name: LinkCheck
run: |
make -C doc linkcheck SPHINXOPTS="-j auto -W --keep-going"

xvfb-run make -C doc linkcheck SPHINXOPTS="-j auto -W --keep-going"
- name: "Display linkchecker results"
if: always()
run: |
echo "::group:: Display linkcher output" && cat doc/*/output.txt && echo "::endgroup::" || echo "Failed to display the output file."

- name: "Upload HTML Documentation"
uses: actions/upload-artifact@v3
if: always()
with:
name: documentation-html
path: doc/_build/html
retention-days: 7

- name: "Upload artifacts"
uses: actions/upload-artifact@v3
if: always()
with:
name: output
path: doc/**/output.txt
Expand Down
40 changes: 24 additions & 16 deletions doc/source/api/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,40 @@ Example

.. TO BE MODIFIED

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
tests that you can find in the `test directory <pymapdl_tests_>`_.
The `test_component.py <pymapdl_test_component_>`_ file contains
the unit tests and integration tests of the
:class:`ComponentManager <ansys.mapdl.core.component.ComponentManager>`.
These are just some of the many tests that you can find in the
`test directory <pymapdl_tests_>`_.

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

.. code:: python

import numpy as np
from ansys.math.core.math import AnsMath
import pytest


@fixture
def mm():
return AnsMath()
# 'cube_geom_and_mesh' is another fixture defined in 'conftest.py'
@pytest.fixture(scope="function")
def basic_components(mapdl, cube_geom_and_mesh):
"""Given a model in 'cube_geom_and_mesh', let's define some components to work with later."""
mapdl.components["mycomp1"] = "NODE", [1, 2, 3]
mapdl.components["mycomp2"] = "KP", [1, 3]

mapdl.cmsel("s", "mycomp1")
mapdl.cmsel("a", "mycomp2")

def test_rand(mm): # pass the 'mm' fixture as an argument.
w = mm.rand(10)
assert w.size == 10 # if it is False, AssertionError is raised

def test_dunder_methods_keys(mapdl, basic_components):
assert ["MYCOMP1", "MYCOMP2"] == list(mapdl.components.list())


def test_dunder_methods_types(mapdl, basic_components):
assert ["NODE", "KP"] == list(mapdl.components.types())


def test_dunder_methods_items(mapdl, basic_components):
assert [("MYCOMP1", "NODE"), ("MYCOMP2", "KP")] == list(mapdl.components.items())

def test_matrix_addition(mm):
m1 = mm.rand(10, 10)
m2 = mm.rand(10, 10)
m3 = m1 + m2
assert np.allclose(m1.asarray() + m2.asarray(), m3.asarray())
# if it is False, AssertionError is raised

For further explanations, see the `pytest documentation <pytest_>`_.
10 changes: 9 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,16 @@
}

# Broken anchors:
linkcheck_exclude_documents = ["index"]
linkcheck_anchors_ignore_for_url = ["https://docs.pyvista.org/api/*"]
linkcheck_ignore = [
"https://github.com/ansys/pymapdl/*",
"https://mapdl.docs.pyansys.com/*",
"https://ansysaccount.b2clogin.com/*", # behind payfirewall
"https://ansyshelp.ansys.com/*", # behind payfirewall
]
linkcheck_anchors_ignore = [
# these anchors are picked by linkcheck as broken but thye are not.
# these anchors are picked by linkcheck as broken but they are not.
"firewall-rules",
"pyvista.Plotter",
"pyvista.UnstructuredGrid",
Expand Down
6 changes: 3 additions & 3 deletions doc/source/getting_started/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ in your console (or the output file):
Using ``docker-compose`` to launch MAPDL
----------------------------------------

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

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

Using the `docker-compose.yml <pymapdl_docker_compose_base_>`_ file is recommended.
Expand Down
6 changes: 3 additions & 3 deletions doc/source/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
.. _pyansys_core: [email protected]

.. #Other projects
.. _dpf_core_gh: https://github.com/ansys/DPF-Core
.. _dpf_post_gh: https://github.com/ansys/DPF-Post
.. _dpf_core_gh: https://github.com/ansys/pydpf-core
.. _dpf_post_gh: https://github.com/ansys/pydpf-post
.. _dpf_core_docs: https://dpf.docs.pyansys.com
.. _dpf_post_docs: https://post.docs.pyansys.com
.. _legacy_reader_docs: https://reader.docs.pyansys.com/
Expand Down Expand Up @@ -121,7 +121,7 @@
.. _pymapdl_dev_docs: https://mapdl.docs.pyansys.com/version/dev/
.. _pymapdl_discussions: https://github.com/ansys/PyMAPDL/discussions
.. _pymapdl_tests: https://github.com/ansys/pymapdl/tree/main/tests
.. _pymapdl_test_math: https://github.com/ansys/pymapdl/blob/main/tests/test_math.py
.. _pymapdl_test_component: https://github.com/ansys/pymapdl/blob/main/tests/test_component.py
.. _pymapdl_user_guide_math: https://mapdl.docs.pyansys.com/version/dev/user_guide/math.html
.. _mapdl_fixture: https://github.com/ansys/pymapdl/blob/fb5fb8b6201253f1bd56bdabee60a29abee8c7d8/tests/conftest.py#L254
.. _pymapdl_examples: https://github.com/ansys/pymapdl/tree/main/examples
Expand Down
4 changes: 2 additions & 2 deletions doc/source/substitutions.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. |pyansyscontact| replace:: `PyAnsys Core team <pyansys_core_>`_
.. |pyansyscontact| replace:: `PyAnsys Core team <[email protected]>`_

.. |pyansyscontactemail| replace:: pyansys_core_
.. |pyansyscontactemail| replace:: [email protected]

.. # define a hard line break for HTML
.. |bl| raw:: html
Expand Down
2 changes: 1 addition & 1 deletion examples/00-mapdl-examples/cyclic_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def gen_sector(mapdl, sectors):
# in favor of DPF, but we can use this for now for some great animations.
#
# For more details regarding cyclic result post processing, see:
# - `Understanding Nodal Diameters from a Cyclic Model Analysis <https://reader.docs.pyansys.com/examples/01-cyclic_results/academic_sector_nd.html>`_
# - `Understanding Nodal Diameters from a Cyclic Model Analysis <https://reader.docs.pyansys.com/version/stable/examples/01-cyclic_results/academic_sector_nd.html>`_
# - `Cyclic symmetry examples <https://dpf.docs.pyansys.com/version/stable/examples/11-cyclic-symmetry/index.html>`_

# grab the result object from MAPDL
Expand Down
27 changes: 23 additions & 4 deletions src/ansys/mapdl/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import numpy as np
from numpy.typing import NDArray

from ansys.mapdl.core import Mapdl
from ansys.mapdl.core.errors import ComponentDoesNotExits, ComponentIsNotSelected
from ansys.mapdl.core.mapdl import _MapdlCore

if TYPE_CHECKING: # pragma: no cover
import logging
Expand Down Expand Up @@ -108,6 +108,13 @@ class Component(tuple):
[1, 2, 3]
"""

def __init__(self, *args, **kwargs):
"""Component object"""
# Using tuple init because using object.__init__
# For more information visit:
# https://stackoverflow.com/questions/47627298/how-is-tuple-init-different-from-super-init-in-a-subclass-of-tuple
tuple.__init__(*args, **kwargs)

def __new__(
cls,
type_: ENTITIES_TYP,
Expand Down Expand Up @@ -195,11 +202,23 @@ class ComponentManager:
Component(type='KP', items=(1, 2, 3))
"""

def __init__(self, mapdl: _MapdlCore) -> None:
def __init__(self, mapdl: Mapdl) -> None:
"""Component Manager.

Component manager of an
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.

Parameters
----------
mapdl : ansys.mapdl.core.Mapdl
Mapdl instance which this class references to.
"""
from ansys.mapdl.core.mapdl import _MapdlCore

if not isinstance(mapdl, _MapdlCore):
raise TypeError("Must be implemented from MAPDL class")

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

@property
def _mapdl(self) -> _MapdlCore:
def _mapdl(self) -> Mapdl:
"""Return the weakly referenced instance of mapdl"""
return self._mapdl_weakref()

Expand Down
19 changes: 14 additions & 5 deletions src/ansys/mapdl/core/krylov.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

import numpy as np

from ansys.mapdl.core import Mapdl
from ansys.mapdl.core.errors import MapdlRuntimeError

from .mapdl_grpc import MapdlGrpc


class KrylovSolver:
"""Abstract mapdl krylov class. Created from a ``Mapdl`` instance.
Expand Down Expand Up @@ -46,9 +45,19 @@ class KrylovSolver:

"""

def __init__(self, mapdl):
if not isinstance(mapdl, MapdlGrpc): # pragma: no cover
raise TypeError("``mapdl`` must be a MapdlGrpc instance")
def __init__(self, mapdl: Mapdl):
"""Krylov analysis

Abstract mapdl krylov class. Created from an
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.

Parameters
----------
mapdl : ansys.mapdl.core.Mapdl
Mapdl instance which this class references to.
"""
if not isinstance(mapdl, Mapdl): # pragma: no cover
raise TypeError("``mapdl`` must be an Mapdl class instance")
self._mapdl_weakref = weakref.ref(mapdl)
self.mm = self._mapdl.math
self.jobname = self._mapdl.jobname
Expand Down
27 changes: 25 additions & 2 deletions src/ansys/mapdl/core/mapdl_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from numpy.typing import NDArray
import pyvista as pv

from ansys.mapdl.core import _HAS_PYVISTA
from ansys.mapdl.core import _HAS_PYVISTA, Mapdl
from ansys.mapdl.core.errors import ComponentNoData, VersionError

if _HAS_PYVISTA:
Expand Down Expand Up @@ -131,7 +131,17 @@ class Geometry:

"""

def __init__(self, mapdl):
def __init__(self, mapdl: Mapdl):
"""Geometry manager

Class to help to manage geometry representations in an
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.

Parameters
----------
mapdl : ansys.mapdl.core.Mapdl
Mapdl instance which this class references to.
"""
from ansys.mapdl.core.mapdl import _MapdlCore

if not isinstance(mapdl, _MapdlCore):
Expand Down Expand Up @@ -1494,6 +1504,19 @@ class LegacyGeometry(Geometry):
selection within MAPDL.
"""

def __init__(self, mapdl: Mapdl):
"""Legacy geometry manager

Class to help to manage geometry representations in an
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.

Parameters
----------
mapdl : ansys.mapdl.core.Mapdl
Mapdl instance which this class references to.
"""
super().__init__(mapdl)

def keypoints(self) -> np.array: # type: ignore
"""Keypoint coordinates"""
return super().get_keypoints(return_as_array=True)
Expand Down
12 changes: 11 additions & 1 deletion src/ansys/mapdl/core/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,17 @@ class Parameters:

"""

def __init__(self, mapdl):
def __init__(self, mapdl: _MapdlCore):
"""Parameters manager

Class to help to manage parameters in an
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.

Parameters
----------
mapdl : ansys.mapdl.core.Mapdl
Mapdl instance which this class references to.
"""
if not isinstance(mapdl, _MapdlCore):
raise TypeError("Must be implemented from MAPDL class")
self._mapdl_weakref = weakref.ref(mapdl)
Expand Down
12 changes: 11 additions & 1 deletion src/ansys/mapdl/core/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ class Solution:
1.0
"""

def __init__(self, mapdl):
def __init__(self, mapdl: _MapdlCore):
"""Solution manager

Class to help to manage the solution configuration in an
:class:`Mapdl instance <ansys.mapdl.core.Mapdl>` instance.

Parameters
----------
mapdl : ansys.mapdl.core.Mapdl
Mapdl instance which this class references to.
"""
if not isinstance(mapdl, _MapdlCore):
raise TypeError("Must be implemented from MAPDL class")
self._mapdl_weakref = weakref.ref(mapdl)
Expand Down