Skip to content

Commit 508fb30

Browse files
committed
Edits based on
1 parent 4c7bc2e commit 508fb30

File tree

13 files changed

+106
-129
lines changed

13 files changed

+106
-129
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ The documentation has these sections:
4343
- `Getting started <https://ansys.tools.docs.pyansys.com/version/stable/getting_started/index.html>`_: Learn
4444
how to install Ansys Common Tools in user mode.
4545
- `User guide <https://ansys.tools.docs.pyansys.com/version/stable/user_guide/index.html>`_: Understand key
46-
concepts for implementing its set of tools in your workflows.
46+
concepts for implementing its tools in your workflows.
4747
- `API reference <https://ansys.tools.docs.pyansys.com/version/stable/api/index.html>`_: Understand how to
48-
use Python to interact programmatically with its set of tools.
48+
use Python to interact programmatically with its tools.
4949
- `Contribute <https://ansys.tools.docs.pyansys.com/version/stable/contributing.html>`_: Learn how to
5050
contribute to the Ansys Common Tools codebase or documentation.
5151

doc/.vale.ini

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ Vocab = ANSYS
2525
[*.{md,rst}]
2626

2727
# Apply the following styles
28-
[*.{rst}]
29-
30-
# Inline roles are ignored
31-
TokenIgnores = (:.*:`.*`)
32-
3328
BasedOnStyles = Vale, Google
3429
Vale.Terms = NO
3530
Google.Headings = NO
36-
SkippedScopes = script, style, pre, figure, code-block, literal-block
3731

32+
# Inline roles are ignored
33+
TokenIgnores = (:.*:`.*`)

doc/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Ansys Common Tools provides a collection of tools for the PyAnsys ecosystem.
2020
:link: user_guide/index
2121
:link-type: doc
2222

23-
Understand key concepts for implementing its set of tools
23+
Understand key concepts for implementing its tools
2424
in your workflows.
2525

2626

@@ -30,7 +30,7 @@ Ansys Common Tools provides a collection of tools for the PyAnsys ecosystem.
3030
:link-type: doc
3131

3232
Understand how to use Python to interact programmatically with
33-
its set of tools.
33+
its tools.
3434

3535
.. grid-item-card:: Contribute :material-regular:`group`
3636
:padding: 2 2 2 2

doc/source/user_guide/ansys_downloader.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Ansys example downloader
44
========================
55

6-
Use the Ansys example downloader to download examples from a PyAnsys library. After you import this tool, specify the filename, directory, and local path for the file to download:
6+
Use the Ansys example downloader to download an example from a PyAnsys library. Import this tool and then specify the filename, directory, and local path for the file to download:
77

88
.. code:: pycon
99

doc/source/user_guide/ansys_exceptions.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
Ansys exceptions
44
================
55

6-
Use the Ansys exceptions tool to gracefully catch and handle exceptions that might occur when using Ansys tools, thereby providing a better user experience.
6+
Ansys exceptions are a set of predefined error-handling classes designed to help developers identify, catch, and handle errors that might occur when using Ansys tools. These exceptions provide a structured way to manage errors, ensuring that your programs can gracefully recover from unexpected issues and provide meaningful feedback to users.
77

8-
After importing this tool, use the base :class:`AnsysError <ansys.tools.common.exceptions.AnsysError>` class to catch and handle exceptions related to Ansys tools, extending with your exceptions or using them directly in your programs:
8+
By using Ansys exceptions, you can improve the robustness and maintainability of your code. They allow you to differentiate between various types of errors, such as invalid input types or logical inconsistencies, and handle them appropriately.
9+
10+
You can import exception classes and use the predefined exceptions directly in your programs:
911

1012
.. code:: pycon
1113
@@ -18,3 +20,15 @@ After importing this tool, use the base :class:`AnsysError <ansys.tools.common.e
1820
AnsysTypeError: An invalid type was provided.
1921
>>> raise AnsysLogicError("A logic error occurred in Ansys tools.")
2022
AnsysLogicError: A logic error occurred in Ansys tools.
23+
24+
You can also extend the base exception class to define your own custom exceptions. This allows you to create error types specific to your needs:
25+
26+
```python
27+
class CustomError(AnsysError):
28+
"""A custom exception for specific error handling."""
29+
30+
pass
31+
32+
33+
raise CustomError("This is a custom error message.")
34+
```

doc/source/user_guide/ansys_tools_path.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Ansys path tool
44
===============
55

6-
Use the Ansys path tool to find the path of the latest local Ansys installation. After importing this tool, call the :func:`find_ansys <ansys.tools.common.path.find_ansys>` function to return the installation path:
6+
Use the Ansys path tool to find the path of the latest local Ansys installation. Importing this tool and then call the :func:`find_ansys <ansys.tools.common.path.find_ansys>` function to return the installation path:
77

88
.. code:: pycon
99

doc/source/user_guide/index.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
User guide
55
==========
66

7-
This section explains key concepts for implementing its set of tools in your
8-
PyAnsys workflows. You can use these tools in your examples as well as integrate Ansys Common Tools into your own code.
7+
This section explains key concepts for implementing the tools in Ansys Common Tools in your PyAnsys workflows. You can use these tools in your examples as well as integrate them into your own code.
98

109
.. important::
11-
This library only supports the last two major versions of Python. Usage with older
12-
versions might or might not work.
10+
Ansys Common Tools only supports the last two major versions of Python. Usage with older versions might not work.
1311

1412

1513

@@ -20,14 +18,14 @@ PyAnsys workflows. You can use these tools in your examples as well as integrate
2018
:link: ansys_tools_path
2119
:link-type: doc
2220

23-
Learn how to use Ansys path tool.
21+
Learn how to use the Ansys path tool.
2422

2523
.. grid-item-card:: Ansys example downloader
2624
:padding: 2 2 2 2
2725
:link: ansys_downloader
2826
:link-type: doc
2927

30-
Learn how to use the example downloader tool.
28+
Learn how to use the example downloader.
3129

3230
.. grid-item-card:: Ansys exceptions
3331
:padding: 2 2 2 2

doc/source/user_guide/launcher/cli.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
Command-line interface
44
======================
55

6-
You use the ``ansys-launcher`` command-line interface to edit the default
7-
launch configuration.
6+
Use the ``ansys-launcher`` command-line interface to edit default
7+
launch configurations.
88

9-
Configuration options for products are defined by each product plugin.
9+
Each product plugin defines configuration options for its products.
1010

1111
.. click:: ansys.tools.common.launcher._cli:cli
1212
:prog: ansys-launcher

doc/source/user_guide/launcher/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Local product launcher
22
----------------------
33

4-
Use the local product launcher rather than launch functions implemented by various PyAnsys libraries. These pages provide an overview and describes how to use it.
4+
Use the local product launcher rather than the launch functions implemented by various PyAnsys libraries. These pages provide an overview and describe how to use the local product launcher:
55

66
- :ref:`rationale`: Provides a high-level overview of the problem that the
77
local product launcher solves.

doc/source/user_guide/launcher/plugin_creation.rst

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
Launcher plugin creation
44
------------------------
55

6-
This page explains how to create a plugin for the Local Product Launcher. The plugin
7-
in the example launches Ansys Composite PrepPost (ACP) as a subprocess.
6+
This page explains how to create a plugin for the local product launcher. The plugin in the example launches Ansys Composite PrepPost (ACP) as a subprocess.
87

9-
The Local Product Launcher defines the interface that a plugin must satisfy in the :mod:`.interface` module.
8+
The local product launcher defines the interface that a plugin must satisfy in the :mod:`.interface` module.
109

1110
.. note::
1211

@@ -88,14 +87,13 @@ there's quite a lot going on in this code, descriptions of each part are provide
8887
return {"main": self._url}
8988
9089
91-
The launcher class inherits from ``LauncherProtocol[LauncherConfig]``. This isn't a requirement, but it means a type checker like `mypy <https://mypy.readthedocs.io>`_ can verify that the :class:`.LauncherProtocol` interface is fulfilled.
90+
The launcher class inherits from ``LauncherProtocol[LauncherConfig]``. This isn't a requirement, but it means a type checker like `Mypy <https://mypy.readthedocs.io>`_ can verify that the :class:`.LauncherProtocol` interface is fulfilled.
9291

9392
Next, setting ``CONFIG_MODEL = DirectLauncherConfig`` connects the launcher to the configuration class.
9493

9594
The subsequent line, ``SERVER_SPEC = {"main": ServerType.GRPC}``, defines which kind of servers the
96-
product starts. Here, there's only a single server, which is accessible via gRPC. The keys in this
97-
dictionary can be chosen arbitrarily, but they should be consistent across the launcher implementation.
98-
Ideally, you use the key to convey some meaning. For example, ``"main"`` could refer to the main interface
95+
product starts. Here, there's only a single server, which is accessible via gRPC. The keys in this dictionary can be chosen arbitrarily, but they should be consistent across the launcher implementation.
96+
Ideally, use the key to convey some meaning. For example, ``"main"`` could refer to the main interface
9997
to your product and ``file_transfer`` could refer to an additional service for file upload and download.
10098

10199
The ``__init__`` method must accept exactly one keyword-only argument, ``config``, which contains the
@@ -109,7 +107,7 @@ For the ``_url`` and ``_process`` attributes, only the type is declared for the
109107
self._url: str
110108
self._process: subprocess.Popen[str]
111109
112-
The core of the launcher implementation is in the ``start()`` and ``stop()`` methods:
110+
The core of the launcher implementation is in the ``start`` and ``stop`` methods:
113111

114112
.. code:: python
115113
@@ -126,11 +124,11 @@ The core of the launcher implementation is in the ``start()`` and ``stop()`` met
126124
text=True,
127125
)
128126
129-
This :meth:`start()<.LauncherProtocol.start>` method selects an available port using the
130-
:func:`.find_free_ports` function. It then starts the server as a subprocess. Note that here, the server output is simply discarded. In a real launcher, the option to redirect it (for example to a file) should be added.
127+
The :meth:`start<.LauncherProtocol.start>` method selects an available port using the
128+
:func:`.find_free_ports` function. It then starts the server as a subprocess. Note that here, the server output is simply discarded. In a real launcher, you should add the option to redirect it (for example to a file).
131129
The ``_url`` attribute keeps track of the URL and port that the server should be accessible on.
132130

133-
The :meth:`start()<.LauncherProtocol.stop>` method terminates the subprocess:
131+
The :meth:`start<.LauncherProtocol.stop>` method terminates the subprocess:
134132

135133
.. code:: python
136134
@@ -143,12 +141,12 @@ The :meth:`start()<.LauncherProtocol.stop>` method terminates the subprocess:
143141
self._process.wait()
144142
145143
If your product is prone to ignoring ``SIGTERM``, you might want to add a timeout to the
146-
:py:meth:`.wait() <subprocess.Popen.wait>` method and retry with the
147-
:py:meth:`.kill() <subprocess.Popen.kill>` method instead of the
148-
:py:meth:`.terminate() <subprocess.Popen.terminate>` method.
144+
:py:meth:`.wait <subprocess.Popen.wait>` method and retry with the
145+
:py:meth:`.kill <subprocess.Popen.kill>` method instead of the
146+
:py:meth:`.terminate <subprocess.Popen.terminate>` method.
149147

150148
Next, you must provide a way to verify that the product has successfully launched. This is implemented
151-
in the :meth:`check <.LauncherProtocol.check>`. Because the server implements gRPC health checking, the
149+
in the :meth:`check <.LauncherProtocol.check>` method. Because the server implements gRPC health checking, the
152150
:func:`.check_grpc_health` helper can be used for this purpose:
153151

154152
.. code:: python
@@ -158,7 +156,7 @@ in the :meth:`check <.LauncherProtocol.check>`. Because the server implements gR
158156
return check_grpc_health(channel=channel, timeout=timeout)
159157
160158
161-
Finally, the ``_url`` attribute stored in the :meth:`start() <.LauncherProtocol.start>` method must
159+
Finally, the ``_url`` attribute stored in the :meth:`start <.LauncherProtocol.start>` method must
162160
be made available in the :attr:`urls <.LauncherProtocol.urls>` property:
163161

164162
.. code:: python
@@ -174,19 +172,17 @@ Note that the return value for the ``urls`` property should adhere to the schema
174172
Register entrypoint
175173
'''''''''''''''''''
176174

177-
Having defined all the necessary components for a Local Product Launcher plugin, you can now register the
178-
plugin, which makes it available. You do this through the Python `entrypoints <https://packaging.python.org/specifications/entry-points/>`_
179-
mechanism.
175+
Having defined all the necessary components for a local product launcher plugin, you can now register the
176+
plugin, which makes it available. You do this through the Python `entrypoints mechanism <https://packaging.python.org/specifications/entry-points/>`_.
180177

181-
You define the entrypoint in your package's build configuration. The exact syntax depends on which
182-
packaging tool you use:
178+
You define the entrypoint in your package's build configuration. The exact syntax depends on which packaging tool you use:
183179

184180
.. .. grid:: 1
185181
.. :gutter: 3
186182
187183
.. tab-set::
188184

189-
.. tab-item:: setuptools
185+
.. tab-item:: Setuptools
190186

191187
Setuptools can accept its configuration in one of three ways. Choose the one that applies to your project:
192188

@@ -221,9 +217,9 @@ packaging tool you use:
221217
)
222218
223219
224-
For more information, see the `setuptools documentation <https://setuptools.pypa.io/en/latest/userguide/entry_point.html#entry-points-for-plugins>`_.
220+
For more information, see the `Entry Points for Plugins <https://setuptools.pypa.io/en/latest/userguide/entry_point.html#entry-points-for-plugins>`_ in the Setuptools documentation.
225221

226-
.. tab-item:: flit
222+
.. tab-item:: Flit
227223

228224
In a ``pyproject.toml`` file:
229225

@@ -232,9 +228,9 @@ packaging tool you use:
232228
[project.entry-points."ansys.tools.local_product_launcher.launcher"]
233229
"ACP.direct" = "<your.module.name>:DirectLauncher"
234230
235-
For more information, see the `flit documentation <https://flit.pypa.io/en/stable/pyproject_toml.html#pyproject-project-entrypoints>`_.
231+
For more information, see the `Entry points sections <https://flit.pypa.io/en/stable/pyproject_toml.html#pyproject-project-entrypoints>`_ in the Flit documentation.
236232

237-
.. tab-item:: poetry
233+
.. tab-item:: Poetry
238234

239235
In a ``pyproject.toml`` file:
240236

@@ -243,39 +239,35 @@ packaging tool you use:
243239
[tool.poetry.plugins."ansys.tools.local_product_launcher.launcher"]
244240
"ACP.direct" = "<your.module.name>:DirectLauncher"
245241
246-
For more information, see the `poetry documentation <https://python-poetry.org/docs/pyproject#plugins>`_.
242+
For more information, see the `plugins <https://python-poetry.org/docs/pyproject#plugins>`_ in the Poetry documentation.
247243

248-
In all cases, ``ansys.tools.local_product_launcher.launcher`` is an identifier specifying that the entrypoint defines a Local Product Launcher plugin. It must be kept the same.
244+
In all cases, ``ansys.tools.local_product_launcher.launcher`` is an identifier specifying that the entrypoint defines a local product launcher plugin. It must be kept the same.
249245

250246
The entrypoint itself has two parts:
251247

252-
- The entrypoint name ``ACP.direct`` consists of two parts: ``ACP`` is the product name, and
253-
``direct`` is the launch mode identifier. The name must be of this format and contain exactly
254-
one dot ``.`` separating the two parts.
255-
- The entrypoint value ``<your.module.name>:DirectLauncher`` defines where the launcher
256-
implementation is located. In other words, it must load the launcher class:
248+
- The entrypoint name ``ACP.direct`` consists of two parts: ``ACP`` is the product name, and ``direct`` is the launch mode identifier. The name must be of this format and contain exactly one dot ``.`` separating the two parts.
249+
- The entrypoint value ``<your.module.name>:DirectLauncher`` defines where the launcher implementation is located. In other words, it must load the launcher class:
257250

258251
.. code::
259252
260253
from <your.module.name> import DirectLauncher
261254
262255
263-
For the entrypoints to update, you must re-install your package (even if it was installed with ``pip install -e``).
256+
For the entrypoints to update, you must re-install your package (even if it was installed with the ``pip install -e`` command).
264257

265258
Add command-line default and description
266259
''''''''''''''''''''''''''''''''''''''''
267260

268-
With the three preceding parts, you've successfully created a Local Product Launcher plugin. :octicon:`rocket`
261+
With the three preceding parts, you've successfully created a local product launcher plugin. :octicon:`rocket`
269262

270-
You can now improve the usability of the command line by adding a default and description to the configuration class.
263+
You can now improve the usability of the command line by adding a default and a description to the configuration class.
271264

272265
To do so, edit the ``DirectLaunchConfig`` class, using the :py:func:`dataclasses.field` function to enrich
273266
the ``binary_path``:
274267

275268
* The default value is specified as the ``default`` argument.
276269
* The description is given in the ``metadata`` dictionary, using the special key :py:obj:`METADATA_KEY_DOC <.interface.METADATA_KEY_DOC>`.
277270

278-
279271
.. code:: python
280272
281273
import os
@@ -309,23 +301,18 @@ the ``binary_path``:
309301
For the default value, use the :py:func:`get_available_ansys_installations <path.get_available_ansys_installations>`
310302
helper to find the Ansys installation directory.
311303

312-
Now, when running ``ansys-launcher configure ACP direct``, users can see and accept the default
313-
value if they want.
304+
Now, when running ``ansys-launcher configure ACP direct``, users can see and accept the default value if they want.
314305

315306
.. note::
316307

317-
If the default value is ``None``, it is converted to the string ``default`` for the
318-
command-line interface. This allows implementing more complicated default behaviors
319-
that may not be expressible when the command-line interface is run.
308+
If the default value is ``None``, it is converted to the string ``default`` for command-line interface. This allows implementing more complicated default behaviors that may not be expressible when the command-line interface is run.
320309

321310
Add a fallback launch mode
322311
''''''''''''''''''''''''''
323312

324-
If you want to provide a fallback launch mode that can be used without any configuration, you can add
325-
an entrypoint with the special name ``<product>.__fallback__``.
313+
If you want to provide a fallback launch mode that can be used without any configuration, you can add an entrypoint with the special name ``<product>.__fallback__``.
326314

327-
For example, if you wanted the ``DirectLauncher`` to be the fallback for ACP, you could add this
328-
entrypoint:
315+
For example, to make ``DirectLauncher`` the fallback for ACP, add this entry point:
329316

330317
.. code:: toml
331318

0 commit comments

Comments
 (0)