Skip to content

Commit

Permalink
Feat/launcher hidden mode (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-matteo authored Nov 28, 2023
1 parent 6a5dfc7 commit 0fdbf7c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ansys/geometry/core/connection/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def launch_modeler_with_discovery(
timeout: int = 150,
manifest_path: str = None,
logs_folder: str = None,
hidden: bool = False,
):
"""
Start Ansys Discovery locally using the ``ProductInstance`` class.
Expand Down Expand Up @@ -420,6 +421,7 @@ def launch_modeler_with_discovery(
version.
logs_folder : sets the backend's logs folder path. If nothing is defined,
the backend will use its default path.
hidden : starts the product hiding its UI. Default is ``False``.
Raises
------
Expand Down Expand Up @@ -465,6 +467,7 @@ def launch_modeler_with_discovery(
timeout=timeout,
manifest_path=manifest_path,
logs_folder=logs_folder,
hidden=hidden,
)


Expand All @@ -477,6 +480,7 @@ def launch_modeler_with_spaceclaim(
timeout: int = 150,
manifest_path: str = None,
logs_folder: str = None,
hidden: bool = False,
):
"""
Start Ansys SpaceClaim locally using the ``ProductInstance`` class.
Expand Down Expand Up @@ -524,6 +528,7 @@ def launch_modeler_with_spaceclaim(
version.
logs_folder : sets the backend's logs folder path. If nothing is defined,
the backend will use its default path.
hidden : starts the product hiding its UI. Default is ``False``.
Raises
------
Expand Down Expand Up @@ -569,6 +574,7 @@ def launch_modeler_with_spaceclaim(
timeout=timeout,
manifest_path=manifest_path,
logs_folder=logs_folder,
hidden=hidden,
)


Expand Down
30 changes: 30 additions & 0 deletions src/ansys/geometry/core/connection/product_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@
To be used only with Ansys Discovery and Ansys SpaceClaim.
"""

BACKEND_SPACECLAIM_HIDDEN = "/Headless=True"
"""
The argument to hide SpaceClaim's UI on the backend.
To be used only with Ansys SpaceClaim.
"""

BACKEND_DISCOVERY_HIDDEN = "--hidden"
"""
The argument to hide Discovery's UI on the backend.
To be used only with Ansys Discovery.
"""

BACKEND_SPLASH_OFF = "/Splash=False"
"""
The argument to specify the backend's addin manifest file's path.
To be used only with Ansys Discovery and Ansys SpaceClaim.
"""


class ProductInstance:
"""
Expand Down Expand Up @@ -143,6 +164,7 @@ def prepare_and_start_backend(
timeout: int = 150,
manifest_path: str = None,
logs_folder: str = None,
hidden: bool = False,
) -> "Modeler":
"""
Start the requested service locally using the ``ProductInstance`` class.
Expand Down Expand Up @@ -187,6 +209,7 @@ def prepare_and_start_backend(
version. Only applicable for Ansys Discovery and Ansys SpaceClaim.
logs_folder : sets the backend's logs folder path. If nothing is defined,
the backend will use its default path.
hidden : starts the product hiding its UI. Default is ``False``.
Raises
------
Expand Down Expand Up @@ -223,6 +246,10 @@ def prepare_and_start_backend(

if backend_type == BackendType.DISCOVERY:
args.append(os.path.join(installations[product_version], DISCOVERY_FOLDER, DISCOVERY_EXE))
if hidden is True:
args.append(BACKEND_DISCOVERY_HIDDEN)

# Here begins the spaceclaim arguments.
args.append(BACKEND_SPACECLAIM_OPTIONS)
args.append(
BACKEND_ADDIN_MANIFEST_ARGUMENT
Expand All @@ -231,6 +258,9 @@ def prepare_and_start_backend(
env_copy[BACKEND_API_VERSION_VARIABLE] = str(api_version)
elif backend_type == BackendType.SPACECLAIM:
args.append(os.path.join(installations[product_version], SPACECLAIM_FOLDER, SPACECLAIM_EXE))
if hidden is True:
args.append(BACKEND_SPACECLAIM_HIDDEN)
args.append(BACKEND_SPLASH_OFF)
args.append(
BACKEND_ADDIN_MANIFEST_ARGUMENT
+ _manifest_path_provider(product_version, installations, manifest_path)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_launcher_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_product_launch_with_parameters():
log_level=random.randint(0, 3),
api_version=apiVersions[random.randint(0, len(apiVersions) - 1)].value,
timeout=180,
hidden=True,
)

modeler_spaceclaim = launch_modeler_with_spaceclaim(
Expand All @@ -99,6 +100,7 @@ def test_product_launch_with_parameters():
log_level=random.randint(0, 3),
api_version=apiVersions[random.randint(0, len(apiVersions) - 1)].value,
timeout=180,
hidden=True,
)

assert modeler_geo_service != None
Expand Down

0 comments on commit 0fdbf7c

Please sign in to comment.