Skip to content

Commit b5d8238

Browse files
authored
Merge branch 'main' into pre-commit-ci-update-config
2 parents a24b62a + 904f6c4 commit b5d8238

File tree

18 files changed

+542
-138
lines changed

18 files changed

+542
-138
lines changed

doc/changelog.d/454.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Feat/add local launcher

doc/changelog.d/553.documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
remote instance

doc/changelog.d/555.dependencies.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bump psutil from 6.1.1 to 7.0.0

doc/source/cheat_sheet/cheat_sheet_script.qmd

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,23 @@ jupyter:
3535

3636
# Connect to Speos Service
3737

38-
Connect to an instance locally:
38+
Start instance locally:
3939

4040
```{python}
4141
#| eval: false
42-
from ansys.speos.core import Speos
42+
from ansys.speos.core.launcher import launch_local_speos_rpc_server
43+
44+
speos_server = launch_local_speos_rpc_server()
45+
# returns a connected speos instance
46+
```
47+
48+
Connect to an existing instance:
4349

44-
speos_server = Speos(host='127.0.0.1', port=50098)
50+
```{python}
51+
#| eval: false
52+
from ansys.speos.core import Speos
53+
host_ip = '127.0.0.1' # localhost here
54+
speos_server = Speos(host=host_ip, port=50098)
4555
```
4656

4757
# Speos Solver files

doc/source/getting_started/index.rst

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,14 @@ containers. Select the option that best suits your needs.
3131
Launch the Speos service as a Docker container
3232
and connect to it from PySpeos.
3333

34-
.. grid-item-card:: Local service
35-
:link: local/index
34+
.. grid-item-card:: Launch a service
35+
:link: launcher/index
3636
:link-type: doc
3737

38-
Launch the Speos service locally on your machine
38+
Launch the Speos service locally or remotely on a Computer
3939
and connect to it from PySpeos.
4040

41-
.. grid-item-card:: Remote service
42-
:link: remote/index
43-
:link-type: doc
44-
45-
Launch the Speos service on a remote machine and
46-
connect to it using PIM (Product Instance Manager).
47-
48-
.. grid-item-card:: Connect to an existing service
41+
.. grid-item-card:: Use an existing service
4942
:link: existing/index
5043
:link-type: doc
5144

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
.. _ref_creating_local_service:
2+
3+
Launch a service
4+
================
5+
6+
To launch a Speos service you have several options:
7+
8+
* Use python launch method to start it locally
9+
* Use Bash to start it yourself
10+
* Rely on Ansys PIM to start a service
11+
12+
Python launcher
13+
---------------
14+
15+
To launch a local Speos RPC server instance use:
16+
17+
.. code:: python
18+
19+
from ansys.speos.core.launcher import launch_local_speos_rpc_server
20+
21+
speos = launch_local_speos_rpc_server(version='251')
22+
23+
You receive a ``Speos`` object in return that you then use as a Speos session.
24+
For more information you can look at the API Reference.
25+
26+
.. button-ref:: ../../api/ansys/speos/core/launcher/index
27+
:ref-type: doc
28+
:color: primary
29+
:shadow:
30+
31+
32+
The session can be ended via the object ``Speos`` like this:
33+
34+
.. code:: python
35+
36+
speos.close()
37+
38+
Launch a local service from the command line
39+
--------------------------------------------
40+
41+
To launch the service, you need to use the following commands:
42+
43+
.. tab-set::
44+
45+
.. tab-item:: Windows CMD
46+
47+
.. code-block:: bash
48+
49+
"%AWP_ROOT251%\Optical Products\SPEOS_RPC\SpeosRPC_Server.exe"
50+
51+
.. tab-item:: Windows Powershell
52+
53+
.. code-block:: bash
54+
55+
& "$env:AWP_ROOT251\Optical Products\SPEOS_RPC\SpeosRPC_Server.exe"
56+
57+
.. tab-item:: Linux
58+
59+
.. code-block:: bash
60+
61+
$AWP_ROOT251/OpticalProducts/SPEOS_RPC/SpeosRPC_Server.x
62+
63+
64+
To stop the server you can use the following command line:
65+
66+
.. tab-set::
67+
68+
.. tab-item:: Windows CMD
69+
70+
.. code-block:: bash
71+
72+
"%AWP_ROOT251%\Optical Products\SPEOS_RPC\SpeosRPC_Server.exe --stop portNumber"
73+
74+
.. tab-item:: Windows Powershell
75+
76+
.. code-block:: bash
77+
78+
& "$env:AWP_ROOT251\Optical Products\SPEOS_RPC\SpeosRPC_Server.exe --stop portNumber"
79+
80+
.. tab-item:: Linux
81+
82+
.. code-block:: bash
83+
84+
$AWP_ROOT251/OpticalProducts/SPEOS_RPC/SpeosRPC_Server.x --stop portNumber
85+
86+
To see all the command line parameters you can use the help flag:
87+
88+
.. tab-set::
89+
90+
.. tab-item:: Windows CMD
91+
92+
.. code-block:: bash
93+
94+
"%AWP_ROOT251%\Optical Products\SPEOS_RPC\SpeosRPC_Server.exe --help"
95+
96+
.. tab-item:: Windows Powershell
97+
98+
.. code-block:: bash
99+
100+
& "$env:AWP_ROOT251\Optical Products\SPEOS_RPC\SpeosRPC_Server.exe --help"
101+
102+
.. tab-item:: Linux
103+
104+
.. code-block:: bash
105+
106+
$AWP_ROOT251/OpticalProducts/SPEOS_RPC/SpeosRPC_Server.x --help
107+
108+
Use PySpeos launcher with PIM
109+
-----------------------------
110+
111+
If a remote server is running Ansys Release 2025 R1 or later and is also running PIM (Product
112+
Instance Manager), you can use PIM to start a SpeosRPC server Session that PySpeos
113+
can connect to.
114+
115+
A usage example of the remote service can be accessed via AnsysLAB.
116+
117+
.. warning::
118+
119+
**This option is only available for Ansys employees.**
120+
121+
Only Ansys employees with credentials to the Artifact Repository Browser
122+
can download ZIP files for PIM.
123+
124+
To launch a remote Speos service:
125+
126+
.. code:: python
127+
128+
from ansys.speos.core import launcher
129+
130+
speos = launcher.launch_speos("251")
131+
132+
The preceding commands launch a remote Speos service (version 2025 R1).
133+
You receive a ``Speos`` object in return that you then use as a Speos session.
134+
135+
The session can be ended via the object ``Speos`` like this:
136+
137+
.. code:: python
138+
139+
speos.close()
140+
141+
.. button-ref:: ../index
142+
:ref-type: doc
143+
:color: primary
144+
:shadow:
145+
:expand:
146+
147+
Go to Getting started

doc/source/getting_started/local/index.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

doc/source/getting_started/remote/index.rst

Lines changed: 0 additions & 52 deletions
This file was deleted.

doc/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ PySpeos documentation |version|
3838
Learn how to use PySpeos with examples that demonstrate its capabilities.
3939

4040
.. grid-item-card:: Contribute :fa:`people-group`
41+
:padding: 2 2 2 2
4142
:link: contributing
4243
:link-type: doc
4344

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies=[
3131
"grpcio>=1.50.0,<1.71",
3232
"grpcio-health-checking>=1.45.0,<1.68",
3333
"ansys-api-speos==0.14.2",
34+
"ansys-tools-path>=0.3.1",
3435
"numpy>=1.20.3,<3",
3536
"comtypes>=1.4,<1.5",
3637
]
@@ -41,6 +42,7 @@ graphics = [
4142
"ansys-tools-visualization-interface>=0.8.3",
4243
]
4344
tests = [
45+
"psutil==7.0.0",
4446
"pytest==8.3.5",
4547
"pyvista>=0.40.0,<0.45",
4648
"ansys-tools-visualization-interface>=0.8.3",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
"""Collection of all constants used in pySpeos."""
24+
25+
import os
26+
27+
DEFAULT_HOST = "localhost"
28+
"""Default host used by Speos RPC server and client """
29+
DEFAULT_PORT = "50098"
30+
"""Default port used by Speos RPC server and client """
31+
DEFAULT_VERSION = "251"
32+
"""Latest supported Speos version of the current PySpeos Package"""
33+
MAX_MESSAGE_LENGTH = int(os.environ.get("SPEOS_MAX_MESSAGE_LENGTH", 256 * 1024**2))
34+
"""Maximum message length value accepted by the Speos RPC server,
35+
By default, value stored in environment variable SPEOS_MAX_MESSAGE_LENGTH or 268 435 456.
36+
"""

0 commit comments

Comments
 (0)