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

Renaming LocalMapdlPool class #2907

Merged
merged 1 commit into from
Mar 19, 2024
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
2 changes: 1 addition & 1 deletion doc/source/api/pool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Local MAPDL pool
.. autosummary::
:toctree: _autosummary

pool.LocalMapdlPool
pool.MapdlPool
14 changes: 7 additions & 7 deletions doc/source/user_guide/pool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Create a pool of MAPDL instances
================================

PyMAPDL contains the :class:`LocalMapdlPool <ansys.mapdl.core.pool.LocalMapdlPool>`
PyMAPDL contains the :class:`MapdlPool <ansys.mapdl.core.pool.MapdlPool>`
class to simplify creating multiple local instances of the
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>`
class for batch processing. This can be used for the batch processing of a
Expand All @@ -14,8 +14,8 @@ This code creates a pool:

.. code:: pycon

>>> from ansys.mapdl.core import LocalMapdlPool
>>> pool = LocalMapdlPool(10)
>>> from ansys.mapdl.core import MapdlPool
>>> pool = MapdlPool(10)
'MAPDL Pool with 10 active instances'
>>> pool.exit(block=True)

Expand All @@ -27,7 +27,7 @@ at the current directory within their own isolated directories:

>>> import os
>>> my_path = os.getcmd()
>>> pool = LocalMapdlPool(10, nproc=1, run_location=my_path)
>>> pool = MapdlPool(10, nproc=1, run_location=my_path)
Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s]

You can access each individual MAPDL instance with this code:
Expand All @@ -46,7 +46,7 @@ Run a set of input files
------------------------

You can use the pool to run a set of pre-generated input files using the
:func:`run_batch <ansys.mapdl.core.LocalMapdlPool.run_batch>` method. For
:func:`run_batch <ansys.mapdl.core.MapdlPool.run_batch>` method. For
example, this code would run the first set of 20 verification files:

.. code:: pycon
Expand All @@ -63,7 +63,7 @@ Run a user function

You can use the pool to run a custom user function on each MAPDL
instance over a set of inputs. As in the example for the
:func:`run_batch <ansys.mapdl.core.LocalMapdlPool.run_batch>` function,
:func:`run_batch <ansys.mapdl.core.MapdlPool.run_batch>` function,
the following code uses a set of verification files. However, it implements
it as a function and outputs the final routine instead of the text
output from MAPDL.
Expand Down Expand Up @@ -103,7 +103,7 @@ Close the PyMAPDL pool
----------------------

You can close the PyMAPDL pool with the
:meth:`pool.exit() <ansys.mapdl.core.LocalMapdlPool.exit>` command.
:meth:`pool.exit() <ansys.mapdl.core.MapdlPool.exit>` command.

.. code:: pycon

Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

from ansys.mapdl.core.mapdl_grpc import MapdlGrpc as Mapdl
from ansys.mapdl.core.misc import Information, Report, _check_has_ansys
from ansys.mapdl.core.pool import LocalMapdlPool
from ansys.mapdl.core.pool import MapdlPool
from ansys.mapdl.core.theme import MapdlTheme, _apply_default_theme

_HAS_ANSYS = _check_has_ansys()
Expand Down
14 changes: 7 additions & 7 deletions src/ansys/mapdl/core/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def available_ports(n_ports: int, starting_port: int = MAPDL_DEFAULT_PORT) -> Li
return ports


class LocalMapdlPool:
class MapdlPool:
"""Create a pool of MAPDL instances.

.. note::
Expand Down Expand Up @@ -133,28 +133,28 @@ class LocalMapdlPool:
Simply create a pool of 10 instances to run in the temporary
directory.

>>> from ansys.mapdl.core import LocalMapdlPool
>>> pool = LocalMapdlPool(10)
>>> from ansys.mapdl.core import MapdlPool
>>> pool = MapdlPool(10)
Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s]

Create several instances with 1 CPU each running at the current
directory within their own isolated directories.

>>> import os
>>> my_path = os.getcmd()
>>> pool = LocalMapdlPool(10, nproc=1, run_location=my_path)
>>> pool = MapdlPool(10, nproc=1, run_location=my_path)
Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s]

Create a pool while specifying the MAPDL executable in Windows.

>>> exec_file = 'C:/Program Files/ANSYS Inc/v212/ansys/bin/winx64/ANSYS212.exe'
>>> pool = LocalMapdlPool(10, exec_file=exec_file)
>>> pool = MapdlPool(10, exec_file=exec_file)
Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s]

Create a pool while specifying the MAPDL executable in Linux.

>>> exec_file = '/ansys_inc/v211/ansys/bin/ansys211'
>>> pool = LocalMapdlPool(10, exec_file=exec_file)
>>> pool = MapdlPool(10, exec_file=exec_file)
Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s]

"""
Expand Down Expand Up @@ -230,7 +230,7 @@ def __init__(
# Checking version
if _HAS_ATP:
if version_from_path("mapdl", exec_file) < 211:
raise VersionError("LocalMapdlPool requires MAPDL 2021R1 or later.")
raise VersionError("MapdlPool requires MAPDL 2021R1 or later.")

self._exec_file = exec_file

Expand Down
16 changes: 8 additions & 8 deletions tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
else:
EXEC_FILE = os.environ.get("PYMAPDL_MAPDL_EXEC")

from ansys.mapdl.core import LocalMapdlPool, examples
from ansys.mapdl.core import MapdlPool, examples
from ansys.mapdl.core.errors import VersionError
from conftest import QUICK_LAUNCH_SWITCHES, requires

Expand Down Expand Up @@ -72,7 +72,7 @@ def pool(tmpdir_factory):

if ON_LOCAL:

mapdl_pool = LocalMapdlPool(
mapdl_pool = MapdlPool(
2,
license_server_check=False,
run_location=run_path,
Expand All @@ -85,7 +85,7 @@ def pool(tmpdir_factory):
else:
port2 = os.environ.get("PYMAPDL_PORT2", 50057)

mapdl_pool = LocalMapdlPool(
mapdl_pool = MapdlPool(
2,
license_server_check=False,
start_instance=False,
Expand Down Expand Up @@ -117,7 +117,7 @@ def pool(tmpdir_factory):
@skip_requires_194
def test_invalid_exec():
with pytest.raises(VersionError):
LocalMapdlPool(
MapdlPool(
4,
nproc=NPROC,
exec_file="/usr/ansys_inc/v194/ansys/bin/mapdl",
Expand Down Expand Up @@ -268,7 +268,7 @@ def test_directory_names_default(pool):
@requires("local")
@skip_if_ignore_pool
def test_directory_names_custom_string(tmpdir):
pool = LocalMapdlPool(
pool = MapdlPool(
2,
exec_file=EXEC_FILE,
run_location=tmpdir,
Expand Down Expand Up @@ -296,7 +296,7 @@ def myfun(i):
else:
return "Other_instance"

pool = LocalMapdlPool(
pool = MapdlPool(
3,
exec_file=EXEC_FILE,
nproc=NPROC,
Expand All @@ -315,7 +315,7 @@ def myfun(i):

def test_num_instances():
with pytest.raises(ValueError, match="least 1 instance"):
pool = LocalMapdlPool(
pool = MapdlPool(
0,
exec_file=EXEC_FILE,
nproc=NPROC,
Expand All @@ -325,7 +325,7 @@ def test_num_instances():

@skip_if_ignore_pool
def test_only_one_instance():
pool = LocalMapdlPool(
pool = MapdlPool(
1,
exec_file=EXEC_FILE,
nproc=NPROC,
Expand Down
Loading