Skip to content

Commit c807809

Browse files
feat: allow for product_version on geometry service launcher function (#1182)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 594b916 commit c807809

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

doc/changelog.d/1182.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: allow for ``product_version`` on geometry service launcher function

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

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ def launch_modeler(mode: str = None, **kwargs: Optional[Dict]) -> "Modeler":
6868
6969
**kwargs : dict, default: None
7070
Keyword arguments for the launching methods. For allowable keyword arguments, see the
71-
:func:`launch_remote_modeler` and :func:`launch_docker_modeler` methods. Some of these
72-
keywords might be unused.
71+
corresponding methods for each mode:
72+
73+
* For ``"pypim"`` mode, see the :func:`launch_remote_modeler` method.
74+
* For ``"docker"`` mode, see the :func:`launch_docker_modeler` method.
75+
* For ``"geometry_service"`` mode, see the
76+
:func:`launch_modeler_with_geometry_service` method.
77+
* For ``"spaceclaim"`` mode, see the :func:`launch_modeler_with_spaceclaim` method.
78+
* For ``"discovery"`` mode, see the :func:`launch_modeler_with_discovery` method.
7379
7480
Returns
7581
-------
@@ -232,9 +238,8 @@ def launch_remote_modeler(version: Optional[str] = None, **kwargs: Optional[Dict
232238
For example, "232". If you do not specify the version, the server
233239
chooses the version.
234240
**kwargs : dict, default: None
235-
Keyword arguments for the launching methods. For allowable keyword arguments, see the
236-
:func:`launch_remote_modeler` and :func:`launch_docker_modeler` methods. Some of these
237-
keywords might be unused.
241+
Placeholder to prevent errors when passing additional arguments that
242+
are not compatible with this method.
238243
239244
Returns
240245
-------
@@ -286,9 +291,8 @@ def launch_docker_modeler(
286291
Docker engine and deploys the latest version of the Geometry service for
287292
that OS.
288293
**kwargs : dict, default: None
289-
Keyword arguments for the launching methods. For allowable keyword arguments, see the
290-
:func:`launch_remote_modeler` and :func:`launch_docker_modeler` methods. Some of these
291-
keywords might be unused.
294+
Placeholder to prevent errors when passing additional arguments that
295+
are not compatible with this method.
292296
293297
Returns
294298
-------
@@ -313,7 +317,9 @@ def launch_docker_modeler(
313317
return Modeler(host="localhost", port=port, docker_instance=docker_instance)
314318

315319

316-
def launch_modeler_with_discovery_and_pimlight(version: Optional[str] = None) -> "Modeler":
320+
def launch_modeler_with_discovery_and_pimlight(
321+
version: Optional[str] = None, **kwargs: Optional[Dict]
322+
) -> "Modeler":
317323
"""
318324
Start Ansys Discovery remotely using the PIM API.
319325
@@ -328,6 +334,9 @@ def launch_modeler_with_discovery_and_pimlight(version: Optional[str] = None) ->
328334
Version of Discovery to run in the three-digit format.
329335
For example, "232". If you do not specify the version, the server
330336
chooses the version.
337+
**kwargs : dict, default: None
338+
Placeholder to prevent errors when passing additional arguments that
339+
are not compatible with this method.
331340
332341
Returns
333342
-------
@@ -342,7 +351,9 @@ def launch_modeler_with_discovery_and_pimlight(version: Optional[str] = None) ->
342351
)
343352

344353

345-
def launch_modeler_with_geometry_service_and_pimlight(version: Optional[str] = None) -> "Modeler":
354+
def launch_modeler_with_geometry_service_and_pimlight(
355+
version: Optional[str] = None, **kwargs: Optional[Dict]
356+
) -> "Modeler":
346357
"""
347358
Start the Geometry service remotely using the PIM API.
348359
@@ -357,6 +368,9 @@ def launch_modeler_with_geometry_service_and_pimlight(version: Optional[str] = N
357368
Version of the Geometry service to run in the three-digit format.
358369
For example, "232". If you do not specify the version, the server
359370
chooses the version.
371+
**kwargs : dict, default: None
372+
Placeholder to prevent errors when passing additional arguments that
373+
are not compatible with this method.
360374
361375
Returns
362376
-------
@@ -401,12 +415,14 @@ def launch_modeler_with_spaceclaim_and_pimlight(version: Optional[str] = None) -
401415

402416

403417
def launch_modeler_with_geometry_service(
418+
product_version: int = None,
404419
host: str = "localhost",
405420
port: int = None,
406421
enable_trace: bool = False,
407422
log_level: int = 2,
408423
timeout: int = 60,
409424
logs_folder: str = None,
425+
**kwargs: Optional[Dict],
410426
) -> "Modeler":
411427
"""
412428
Start the Geometry service locally using the ``ProductInstance`` class.
@@ -418,6 +434,15 @@ def launch_modeler_with_geometry_service(
418434
419435
Parameters
420436
----------
437+
product_version: int, optional
438+
The product version to be started. Goes from v23.2.1 to
439+
the latest. Default is ``None``.
440+
If a specific product version is requested but not installed locally,
441+
a SystemError will be raised.
442+
443+
**Ansys products versions and their corresponding int values:**
444+
445+
* ``241`` : Ansys 24R1
421446
host: str, optional
422447
IP address at which the Geometry service will be deployed. By default,
423448
its value will be ``localhost``.
@@ -440,6 +465,9 @@ def launch_modeler_with_geometry_service(
440465
Timeout for starting the backend startup process. The default is 60.
441466
logs_folder : sets the backend's logs folder path. If nothing is defined,
442467
the backend will use its default path.
468+
**kwargs : dict, default: None
469+
Placeholder to prevent errors when passing additional arguments that
470+
are not compatible with this method.
443471
444472
Raises
445473
------
@@ -473,8 +501,16 @@ def launch_modeler_with_geometry_service(
473501
enable_trace= True,
474502
timeout=300)
475503
"""
504+
# if api_version is passed, throw a warning saying that it is not used
505+
if "api_version" in kwargs:
506+
logger.warning(
507+
"The 'api_version' parameter is not used in 'launch_modeler_with_geometry_service'. "
508+
"Please remove it from the arguments."
509+
)
510+
476511
return prepare_and_start_backend(
477512
BackendType.WINDOWS_SERVICE,
513+
product_version=product_version,
478514
host=host,
479515
port=port,
480516
enable_trace=enable_trace,
@@ -495,6 +531,7 @@ def launch_modeler_with_discovery(
495531
manifest_path: str = None,
496532
logs_folder: str = None,
497533
hidden: bool = False,
534+
**kwargs: Optional[Dict],
498535
):
499536
"""
500537
Start Ansys Discovery locally using the ``ProductInstance`` class.
@@ -546,6 +583,9 @@ def launch_modeler_with_discovery(
546583
logs_folder : sets the backend's logs folder path. If nothing is defined,
547584
the backend will use its default path.
548585
hidden : starts the product hiding its UI. Default is ``False``.
586+
**kwargs : dict, default: None
587+
Placeholder to prevent errors when passing additional arguments that
588+
are not compatible with this method.
549589
550590
Raises
551591
------
@@ -605,6 +645,7 @@ def launch_modeler_with_spaceclaim(
605645
manifest_path: str = None,
606646
logs_folder: str = None,
607647
hidden: bool = False,
648+
**kwargs: Optional[Dict],
608649
):
609650
"""
610651
Start Ansys SpaceClaim locally using the ``ProductInstance`` class.
@@ -653,6 +694,9 @@ def launch_modeler_with_spaceclaim(
653694
logs_folder : sets the backend's logs folder path. If nothing is defined,
654695
the backend will use its default path.
655696
hidden : starts the product hiding its UI. Default is ``False``.
697+
**kwargs : dict, default: None
698+
Placeholder to prevent errors when passing additional arguments that
699+
are not compatible with this method.
656700
657701
Raises
658702
------

0 commit comments

Comments
 (0)