Skip to content

Commit ff75309

Browse files
feat: allow version input to automatically consider the nuances for the Ansys Student version (#1548)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent e04d8f9 commit ff75309

File tree

7 files changed

+49
-36
lines changed

7 files changed

+49
-36
lines changed

doc/changelog.d/1548.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
allow version input to automatically consider the nuances for the Ansys Student version

doc/source/getting_started/local/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Launch a local session
44
======================
55

6-
If Ansys 2023 R2 or later and PyAnsys Geometry are installed, you can create a local backend session using
6+
If Ansys 2024 R1 or later and PyAnsys Geometry are installed, you can create a local backend session using
77
Discovery, SpaceClaim, or the Geometry service. Once the backend is running, PyAnsys Geometry can manage the connection.
88

99
To launch and establish a connection to the service, open Python and use the following commands for

doc/source/getting_started/remote/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Launch a remote session
44
=======================
55

6-
If a remote server is running Ansys 2023 R2 or later and is also running PIM (Product
6+
If a remote server is running Ansys 2024 R1 or later and is also running PIM (Product
77
Instance Manager), you can use PIM to start a Discovery or SpaceClaim session
88
that PyAnsys Geometry can connect to.
99

docker/build_docker_windows.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
for env_key, env_val in os.environ.items():
3434
if env_key.startswith("AWP_ROOT"):
3535
# There is an Ansys installation... Check that the version is at
36-
# least 2023R2. Environment variables are in the form
37-
# AWP_ROOT232=/path/to/2023R2
36+
# least 2024R1. Environment variables are in the form
37+
# AWP_ROOT241=/path/to/2024R1
3838
#
3939
# Get the version number
4040
version = env_key.split("AWP_ROOT")[1]
41-
if version < "232":
41+
if version < "241":
4242
# This version is too old, so we will ignore it
4343
continue
4444
else:
@@ -48,7 +48,7 @@
4848
if len(awp_root) == 0:
4949
# There are no Ansys installations
5050
print("XXXXXXX No Ansys compatible installations found.. exiting process. XXXXXXX")
51-
print("XXXXXXX Please install Ansys 2023R2 or newer. XXXXXXX")
51+
print("XXXXXXX Please install Ansys 2024R1 or newer. XXXXXXX")
5252
exit(0)
5353

5454
# Request the user to select the version of Ansys to use

src/ansys/geometry/core/connection/launcher.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def launch_remote_modeler(
248248
249249
version : str, default: None
250250
Version of the Geometry service to run in the three-digit format.
251-
For example, "232". If you do not specify the version, the server
251+
For example, "241". If you do not specify the version, the server
252252
chooses the version.
253253
client_log_level : int, default: logging.INFO
254254
Log level for the client. The default is ``logging.INFO``.
@@ -367,7 +367,7 @@ def launch_modeler_with_discovery_and_pimlight(
367367
----------
368368
version : str, default: None
369369
Version of Discovery to run in the three-digit format.
370-
For example, "232". If you do not specify the version, the server
370+
For example, "241". If you do not specify the version, the server
371371
chooses the version.
372372
client_log_level : int, default: logging.INFO
373373
Log level for the client. The default is ``logging.INFO``.
@@ -410,7 +410,7 @@ def launch_modeler_with_geometry_service_and_pimlight(
410410
----------
411411
version : str, default: None
412412
Version of the Geometry service to run in the three-digit format.
413-
For example, "232". If you do not specify the version, the server
413+
For example, "241". If you do not specify the version, the server
414414
chooses the version.
415415
client_log_level : int, default: logging.INFO
416416
Log level for the client. The default is ``logging.INFO``.
@@ -453,7 +453,7 @@ def launch_modeler_with_spaceclaim_and_pimlight(
453453
----------
454454
version : str, default: None
455455
Version of SpaceClaim to run in the three-digit format.
456-
For example, "232". If you do not specify the version, the server
456+
For example, "241". If you do not specify the version, the server
457457
chooses the version.
458458
client_log_level : int, default: logging.INFO
459459
Log level for the client. The default is ``logging.INFO``.
@@ -505,14 +505,15 @@ def launch_modeler_with_geometry_service(
505505
Parameters
506506
----------
507507
product_version: int, optional
508-
The product version to be started. Goes from v23.2.1 to
508+
The product version to be started. Goes from v24.1 to
509509
the latest. Default is ``None``.
510510
If a specific product version is requested but not installed locally,
511511
a SystemError will be raised.
512512
513513
**Ansys products versions and their corresponding int values:**
514514
515515
* ``241`` : Ansys 24R1
516+
* ``242`` : Ansys 24R2
516517
host: str, optional
517518
IP address at which the Geometry service will be deployed. By default,
518519
its value will be ``localhost``.
@@ -555,7 +556,7 @@ def launch_modeler_with_geometry_service(
555556
If the specified endpoint is already in use, a connection
556557
error will be raised.
557558
SystemError
558-
If there is not an Ansys product 23.2 version or later installed
559+
If there is not an Ansys product 24.1 version or later installed
559560
a SystemError will be raised.
560561
561562
Returns
@@ -629,10 +630,6 @@ def launch_modeler_with_discovery(
629630
):
630631
"""Start Ansys Discovery locally using the ``ProductInstance`` class.
631632
632-
.. note::
633-
634-
Support for Ansys Discovery is restricted to Ansys 24.1 onward.
635-
636633
When calling this method, a standalone Discovery session is started.
637634
By default, if an endpoint is specified (by defining `host` and `port` parameters)
638635
but the endpoint is not available, the startup will fail. Otherwise, it will try to
@@ -641,14 +638,15 @@ def launch_modeler_with_discovery(
641638
Parameters
642639
----------
643640
product_version: int, optional
644-
The product version to be started. Goes from v23.2.1 to
641+
The product version to be started. Goes from v24.1 to
645642
the latest. Default is ``None``.
646643
If a specific product version is requested but not installed locally,
647644
a SystemError will be raised.
648645
649646
**Ansys products versions and their corresponding int values:**
650647
651648
* ``241`` : Ansys 24R1
649+
* ``242`` : Ansys 24R2
652650
host: str, optional
653651
IP address at which the Discovery session will be deployed. By default,
654652
its value will be ``localhost``.
@@ -690,7 +688,7 @@ def launch_modeler_with_discovery(
690688
ConnectionError
691689
If the specified endpoint is already in use, a connection error will be raised.
692690
SystemError:
693-
If there is not an Ansys product 23.2 version or later installed
691+
If there is not an Ansys product 24.1 version or later installed
694692
or if a specific product's version is requested but not installed locally then
695693
a SystemError will be raised.
696694
@@ -707,11 +705,11 @@ def launch_modeler_with_discovery(
707705
>>> from ansys.geometry.core import launch_modeler_with_discovery
708706
>>> modeler = launch_modeler_with_discovery()
709707
710-
Starting an Ansys Discovery V 23.2 session, on address ``10.171.22.44``, port ``5001``,
708+
Starting an Ansys Discovery V 24.1 session, on address ``10.171.22.44``, port ``5001``,
711709
with chatty logs, using API v231 and a ``300`` seconds timeout:
712710
713711
>>> from ansys.geometry.core import launch_modeler_with_discovery
714-
>>> modeler = launch_modeler_with_discovery(product_version = 232,
712+
>>> modeler = launch_modeler_with_discovery(product_version = 241,
715713
host="10.171.22.44",
716714
port=5001,
717715
api_version= 231,
@@ -767,15 +765,15 @@ def launch_modeler_with_spaceclaim(
767765
Parameters
768766
----------
769767
product_version: int, optional
770-
The product version to be started. Goes from v23.2.1 to
768+
The product version to be started. Goes from v24.1 to
771769
the latest. Default is ``None``.
772770
If a specific product version is requested but not installed locally,
773771
a SystemError will be raised.
774772
775773
**Ansys products versions and their corresponding int values:**
776774
777-
* ``232`` : Ansys 23R2 SP1
778775
* ``241`` : Ansys 24R1
776+
* ``242`` : Ansys 24R2
779777
host: str, optional
780778
IP address at which the SpaceClaim session will be deployed. By default,
781779
its value will be ``localhost``.
@@ -817,7 +815,7 @@ def launch_modeler_with_spaceclaim(
817815
ConnectionError
818816
If the specified endpoint is already in use, a connection error will be raised.
819817
SystemError
820-
If there is not an Ansys product 23.2 version or later installed
818+
If there is not an Ansys product 24.1 version or later installed
821819
or if a specific product's version is requested but not installed locally then
822820
a SystemError will be raised.
823821
@@ -834,11 +832,11 @@ def launch_modeler_with_spaceclaim(
834832
>>> from ansys.geometry.core import launch_modeler_with_spaceclaim
835833
>>> modeler = launch_modeler_with_spaceclaim()
836834
837-
Starting an Ansys SpaceClaim V 23.2 session, on address ``10.171.22.44``, port ``5001``,
835+
Starting an Ansys SpaceClaim V 24.1 session, on address ``10.171.22.44``, port ``5001``,
838836
with chatty logs, using API v231 and a ``300`` seconds timeout:
839837
840838
>>> from ansys.geometry.core import launch_modeler_with_spaceclaim
841-
>>> modeler = launch_modeler_with_spaceclaim(product_version = 232,
839+
>>> modeler = launch_modeler_with_spaceclaim(product_version = 241,
842840
host="10.171.22.44",
843841
port=5001,
844842
api_version= 231,

src/ansys/geometry/core/connection/product_instance.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def prepare_and_start_backend(
192192
Parameters
193193
----------
194194
product_version: ``int``, optional
195-
The product version to be started. Goes from v23.2.1 to
195+
The product version to be started. Goes from v24.1 to
196196
the latest. Default is ``None``.
197197
If a specific product version is requested but not installed locally,
198198
a SystemError will be raised.
@@ -242,7 +242,7 @@ def prepare_and_start_backend(
242242
ConnectionError
243243
If the specified endpoint is already in use, a connection error will be raised.
244244
SystemError
245-
If there is not an Ansys product 23.2 version or later installed
245+
If there is not an Ansys product 24.1 version or later installed
246246
or if a specific product's version is requested but not installed locally then
247247
a SystemError will be raised.
248248
@@ -268,10 +268,24 @@ def prepare_and_start_backend(
268268
port = _check_port_or_get_one(port)
269269
installations = get_available_ansys_installations()
270270
if product_version is not None:
271-
_check_version_is_available(product_version, installations)
271+
try:
272+
_check_version_is_available(product_version, installations)
273+
except SystemError as serr:
274+
# The user requested a version as a Student version...
275+
# Let's negate it and try again... if this works, we override the
276+
# product_version variable.
277+
try:
278+
_check_version_is_available(-product_version, installations)
279+
except SystemError:
280+
# The student version is not installed either... raise the original error.
281+
raise serr
282+
283+
product_version = -product_version
272284
else:
273285
product_version = get_latest_ansys_installation()[0]
274-
_check_minimal_versions(product_version)
286+
287+
# Verify that the minimum version is installed.
288+
_check_minimal_versions(product_version)
275289

276290
if server_logs_folder is not None:
277291
# Verify that the user has write permissions to the folder and that it exists.
@@ -480,12 +494,12 @@ def __start_program(args: list[str], local_env: dict[str, str]) -> subprocess.Po
480494
def _check_minimal_versions(latest_installed_version: int) -> None:
481495
"""Check client is compatible with Ansys Products.
482496
483-
Check that at least V232 is installed.
497+
Check that at least V241 is installed.
484498
"""
485-
if abs(latest_installed_version) < 232:
499+
if abs(latest_installed_version) < 241:
486500
msg = (
487-
"PyAnsys Geometry is compatible with Ansys Products from version 23.2.1. "
488-
+ "Please install Ansys products 23.2.1 or later."
501+
"PyAnsys Geometry is compatible with Ansys Products from version 24.1.0. "
502+
+ "Please install Ansys products 24.1.0 or later."
489503
)
490504
raise SystemError(msg)
491505

src/ansys/geometry/core/modeler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def run_discovery_script_file(
400400
bodies in the design.
401401
402402
The implied API version of the script should match the API version of the running
403-
Geometry Service. DMS API versions 23.2.1 and later are supported. DMS is a
403+
Geometry Service. DMS API versions 24.1 and later are supported. DMS is a
404404
Windows-based modeling service that has been containerized to ease distribution,
405405
execution, and remotability operations.
406406
@@ -417,8 +417,8 @@ def run_discovery_script_file(
417417
script modifies the current design, the design may be out-of-sync. By default,
418418
``False``.
419419
api_version : int | str | ApiVersions, optional
420-
The scripting API version to use. For example, version 23.2 can be passed as
421-
an integer 232, a string "232" or using the
420+
The scripting API version to use. For example, version 24.1 can be passed as
421+
an integer 241, a string "241" or using the
422422
``ansys.geometry.core.connection.backend.ApiVersions`` enum class.
423423
By default, ``None``. When specified, the service will attempt to run the script with
424424
the specified API version. If the API version is not supported, the service will raise

0 commit comments

Comments
 (0)