Skip to content

Commit

Permalink
feat: allow for platform input when using Ansys Lab (#1416)
Browse files Browse the repository at this point in the history
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 9, 2024
1 parent bd57e6f commit 696b5bd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/changelog.d/1416.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allow for platform input when using Ansys Lab
30 changes: 30 additions & 0 deletions src/ansys/geometry/core/connection/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def _launch_with_automatic_detection(**kwargs: dict | None) -> "Modeler":


def launch_remote_modeler(
platform: str = "windows",
version: str | None = None,
client_log_level: int = logging.INFO,
client_log_file: str | None = None,
Expand All @@ -236,6 +237,15 @@ def launch_remote_modeler(
Parameters
----------
platform : str, default: None
**Specific for Ansys Lab**. The platform option for the Geometry service.
The default is ``"windows"``.
This parameter is used to specify the operating system on which the
Geometry service will run. The possible values are:
* ``"windows"``: The Geometry service runs on a Windows machine.
* ``"linux"``: The Geometry service runs on a Linux machine.
version : str, default: None
Version of the Geometry service to run in the three-digit format.
For example, "232". If you do not specify the version, the server
Expand All @@ -257,6 +267,7 @@ def launch_remote_modeler(
return _launch_pim_instance(
is_pim_light=False,
product_name="geometry",
product_platform=platform,
product_version=version,
backend_type=None,
client_log_level=client_log_level,
Expand Down Expand Up @@ -861,6 +872,7 @@ def launch_modeler_with_spaceclaim(
def _launch_pim_instance(
is_pim_light: bool,
product_name: str,
product_platform: str | None = None,
product_version: str | None = None,
backend_type: BackendType | None = None,
client_log_level: int = logging.INFO,
Expand All @@ -881,6 +893,14 @@ def _launch_pim_instance(
running on a local machine.
product_name : str
Name of the service to run.
product_platform : str, default: None
Platform on which the service will run. **Specific for Ansys Lab**.
This parameter is used to specify the operating system on which the
Geometry service will run. The possible values are:
* ``"windows"``: The Geometry service runs on a Windows machine.
* ``"linux"``: The Geometry service runs on a Linux machine.
product_version : str, default: None
Version of the service to run.
backend_type : BackendType, default: None
Expand All @@ -906,6 +926,16 @@ def _launch_pim_instance(
"The package 'ansys-platform-instancemanagement' is required to use this function."
)

# Platform is used mostly for Ansys Lab purposes. If product_version is defined, use it.
# Higher priority is given to product_version.
if product_platform: # pragma: no cover
if product_version:
LOG.warning(
"The 'product_platform' parameter is not used when 'product_version' is defined."
)
else:
product_version = product_platform

# If PIM Light is being used and PyPIM configuration is not defined... use defaults.
if is_pim_light and not os.environ.get("ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG", None):
os.environ["ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG"] = DEFAULT_PIM_CONFIG
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/test_launcher_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def test_launch_remote_instance(monkeypatch, modeler: Modeler):
# Assert: PyAnsys Geometry went through the PyPIM workflow
assert mock_is_configured.called
assert mock_connect.called
mock_client.create_instance.assert_called_with(product_name="geometry", product_version=None)
mock_client.create_instance.assert_called_with(
product_name="geometry", product_version="windows"
)
assert mock_instance.wait_for_ready.called
mock_instance.build_grpc_channel.assert_called_with(
options=[
Expand Down

0 comments on commit 696b5bd

Please sign in to comment.