From 696b5bd51d8e240f023c5930a9103d7e5ae9c8e1 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:46:38 +0200 Subject: [PATCH] feat: allow for platform input when using Ansys Lab (#1416) 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> --- doc/changelog.d/1416.added.md | 1 + .../geometry/core/connection/launcher.py | 30 +++++++++++++++++++ tests/integration/test_launcher_remote.py | 4 ++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 doc/changelog.d/1416.added.md diff --git a/doc/changelog.d/1416.added.md b/doc/changelog.d/1416.added.md new file mode 100644 index 0000000000..ceb3be6c8e --- /dev/null +++ b/doc/changelog.d/1416.added.md @@ -0,0 +1 @@ +allow for platform input when using Ansys Lab \ No newline at end of file diff --git a/src/ansys/geometry/core/connection/launcher.py b/src/ansys/geometry/core/connection/launcher.py index 2f4128e221..499bfe0637 100644 --- a/src/ansys/geometry/core/connection/launcher.py +++ b/src/ansys/geometry/core/connection/launcher.py @@ -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, @@ -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 @@ -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, @@ -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, @@ -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 @@ -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 diff --git a/tests/integration/test_launcher_remote.py b/tests/integration/test_launcher_remote.py index 7614700e8c..658f511a71 100644 --- a/tests/integration/test_launcher_remote.py +++ b/tests/integration/test_launcher_remote.py @@ -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=[