The launcher.py module#

Summary#

launch_modeler

Start the Modeler interface for PyAnsys Geometry.

launch_remote_modeler

Start the Geometry service remotely using the PIM API.

launch_docker_modeler

Start the Geometry service locally using Docker.

launch_modeler_with_discovery_and_pimlight

Start Ansys Discovery remotely using the PIM API.

launch_modeler_with_geometry_service_and_pimlight

Start the Geometry service remotely using the PIM API.

launch_modeler_with_spaceclaim_and_pimlight

Start Ansys SpaceClaim remotely using the PIM API.

launch_modeler_with_geometry_service

Start the Geometry service locally using the ProductInstance class.

launch_modeler_with_discovery

Start Ansys Discovery locally using the ProductInstance class.

launch_modeler_with_spaceclaim

Start Ansys SpaceClaim locally using the ProductInstance class.

Description#

Module for connecting to instances of the Geometry service.

Module detail#

launcher.launch_modeler(mode: str = None, **kwargs: dict | None) ansys.geometry.core.modeler.Modeler#

Start the Modeler interface for PyAnsys Geometry.

Parameters:
modestr, default: None

Mode in which to launch the Modeler service. The default is None, in which case the method tries to determine the mode automatically. The possible values are:

  • "pypim": Launches the Modeler service remotely using the PIM API.

  • "docker": Launches the Modeler service locally using Docker.

  • "geometry_service": Launches the Modeler service locally using the Ansys Geometry Service.

  • "spaceclaim": Launches the Modeler service locally using Ansys SpaceClaim.

  • "discovery": Launches the Modeler service locally using Ansys Discovery.

**kwargsdict, default: None

Keyword arguments for the launching methods. For allowable keyword arguments, see the corresponding methods for each mode:

Returns:
ansys.geometry.core.modeler.Modeler

Pythonic interface for geometry modeling.

Examples

Launch the Geometry service.

>>> from ansys.geometry.core import launch_modeler
>>> modeler = launch_modeler()
launcher.launch_remote_modeler(platform: str = 'windows', version: str | None = None, client_log_level: int = logging.INFO, client_log_file: str | None = None, **kwargs: dict | None) ansys.geometry.core.modeler.Modeler#

Start the Geometry service remotely using the PIM API.

When calling this method, you must ensure that you are in an environment where PyPIM is configured. You can use the pypim.is_configured method to check if it is configured.

Parameters:
platformstr, 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.

versionstr, 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 chooses the version.

client_log_levelint, default: logging.INFO

Log level for the client. The default is logging.INFO.

client_log_filestr, default: None

Path to the log file for the client. The default is None, in which case the client logs to the console.

**kwargsdict, default: None

Placeholder to prevent errors when passing additional arguments that are not compatible with this method.

Returns:
ansys.geometry.core.modeler.Modeler

Instance of the Geometry service.

launcher.launch_docker_modeler(port: int = DEFAULT_PORT, connect_to_existing_service: bool = True, restart_if_existing_service: bool = False, name: str | None = None, image: ansys.geometry.core.connection.docker_instance.GeometryContainers | None = None, client_log_level: int = logging.INFO, client_log_file: str | None = None, **kwargs: dict | None) ansys.geometry.core.modeler.Modeler#

Start the Geometry service locally using Docker.

When calling this method, a Geometry service (as a local Docker container) is started. By default, if a container with the Geometry service already exists at the given port, it connects to it. Otherwise, it tries to launch its own service.

Parameters:
portint, optional

Localhost port to deploy the Geometry service on or the the Modeler interface to connect to (if it is already deployed). By default, the value is the one for the DEFAULT_PORT connection parameter.

connect_to_existing_servicebool, default: True

Whether the Modeler interface should connect to a Geometry service already deployed at the specified port.

restart_if_existing_servicebool, default: False

Whether the Geometry service (which is already running) should be restarted when attempting connection.

namestr, default: None

Name of the Docker container to deploy. The default is None, in which case Docker assigns it a random name.

imageGeometryContainers, default: None

The Geometry service Docker image to deploy. The default is None, in which case the LocalDockerInstance class identifies the OS of your Docker engine and deploys the latest version of the Geometry service for that OS.

client_log_levelint, default: logging.INFO

Log level for the client. The default is logging.INFO.

client_log_filestr, default: None

Path to the log file for the client. The default is None, in which case the client logs to the console.

**kwargsdict, default: None

Placeholder to prevent errors when passing additional arguments that are not compatible with this method.

Returns:
Modeler

Instance of the Geometry service.

launcher.launch_modeler_with_discovery_and_pimlight(version: str | None = None, client_log_level: int = logging.INFO, client_log_file: str | None = None, **kwargs: dict | None) ansys.geometry.core.modeler.Modeler#

Start Ansys Discovery remotely using the PIM API.

When calling this method, you must ensure that you are in an environment where PyPIM is configured. You can use the pypim.is_configured method to check if it is configured.

Parameters:
versionstr, default: None

Version of Discovery to run in the three-digit format. For example, “232”. If you do not specify the version, the server chooses the version.

client_log_levelint, default: logging.INFO

Log level for the client. The default is logging.INFO.

client_log_filestr, default: None

Path to the log file for the client. The default is None, in which case the client logs to the console.

**kwargsdict, default: None

Placeholder to prevent errors when passing additional arguments that are not compatible with this method.

Returns:
ansys.geometry.core.modeler.Modeler

Instance of Modeler.

launcher.launch_modeler_with_geometry_service_and_pimlight(version: str | None = None, client_log_level: int = logging.INFO, client_log_file: str | None = None, **kwargs: dict | None) ansys.geometry.core.modeler.Modeler#

Start the Geometry service remotely using the PIM API.

When calling this method, you must ensure that you are in an environment where PyPIM is configured. You can use the pypim.is_configured method to check if it is configured.

Parameters:
versionstr, 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 chooses the version.

client_log_levelint, default: logging.INFO

Log level for the client. The default is logging.INFO.

client_log_filestr, default: None

Path to the log file for the client. The default is None, in which case the client logs to the console.

**kwargsdict, default: None

Placeholder to prevent errors when passing additional arguments that are not compatible with this method.

Returns:
ansys.geometry.core.modeler.Modeler

Instance of Modeler.

launcher.launch_modeler_with_spaceclaim_and_pimlight(version: str | None = None, client_log_level: int = logging.INFO, client_log_file: str | None = None, **kwargs: dict | None) ansys.geometry.core.modeler.Modeler#

Start Ansys SpaceClaim remotely using the PIM API.

When calling this method, you must ensure that you are in an environment where PyPIM is configured. You can use the pypim.is_configured method to check if it is configured.

Parameters:
versionstr, default: None

Version of SpaceClaim to run in the three-digit format. For example, “232”. If you do not specify the version, the server chooses the version.

client_log_levelint, default: logging.INFO

Log level for the client. The default is logging.INFO.

client_log_filestr, default: None

Path to the log file for the client. The default is None, in which case the client logs to the console.

**kwargsdict, default: None

Placeholder to prevent errors when passing additional arguments that are not compatible with this method.

Returns:
ansys.geometry.core.modeler.Modeler

Instance of Modeler.

launcher.launch_modeler_with_geometry_service(product_version: int = None, host: str = 'localhost', port: int = None, enable_trace: bool = False, timeout: int = 60, server_log_level: int = 2, client_log_level: int = logging.INFO, server_logs_folder: str = None, client_log_file: str = None, log_level: int = None, logs_folder: str = None, **kwargs: dict | None) ansys.geometry.core.modeler.Modeler#

Start the Geometry service locally using the ProductInstance class.

When calling this method, a standalone Geometry service is started. By default, if an endpoint is specified (by defining host and port parameters) but the endpoint is not available, the startup will fail. Otherwise, it will try to launch its own service.

Parameters:
product_version: int, optional

The product version to be started. Goes from v23.2.1 to the latest. Default is None. If a specific product version is requested but not installed locally, a SystemError will be raised.

Ansys products versions and their corresponding int values:

  • 241 : Ansys 24R1

host: str, optional

IP address at which the Geometry service will be deployed. By default, its value will be localhost.

portint, optional

Port at which the Geometry service will be deployed. By default, its value will be None.

enable_tracebool, optional

Boolean enabling the logs trace on the Geometry service console window. By default its value is False.

timeoutint, optional

Timeout for starting the backend startup process. The default is 60.

server_log_levelint, optional
Backend’s log level from 0 to 3:

0: Chatterbox 1: Debug 2: Warning 3: Error

The default is 2 (Warning).

client_log_levelint, optional

Logging level to apply to the client. By default, INFO level is used. Use the logging module’s levels: DEBUG, INFO, WARNING, ERROR, CRITICAL.

server_logs_folderstr, optional

Sets the backend’s logs folder path. If nothing is defined, the backend will use its default path.

client_log_filestr, optional

Sets the client’s log file path. If nothing is defined, the client will log to the console.

log_levelint, optional

DEPRECATED. Use server_log_level instead.

logs_folderstr, optional

DEPRECATED. Use server_logs_folder instead.

**kwargsdict, default: None

Placeholder to prevent errors when passing additional arguments that are not compatible with this method.

Returns:
Modeler

Instance of the Geometry service.

Raises:
ConnectionError

If the specified endpoint is already in use, a connection error will be raised.

SystemError

If there is not an Ansys product 23.2 version or later installed a SystemError will be raised.

Examples

Starting a geometry service with the default parameters and getting back a Modeler object:

>>> from ansys.geometry.core import launch_modeler_with_geometry_service
>>> modeler = launch_modeler_with_geometry_service()

Starting a geometry service, on address 10.171.22.44, port 5001, with chatty logs, traces enabled and a 300 seconds timeout:

>>> from ansys.geometry.core import launch_modeler_with_geometry_service
>>> modeler = launch_modeler_with_geometry_service(host="10.171.22.44",
    port=5001,
    enable_trace= True,
    timeout=300,
    server_log_level=0)
launcher.launch_modeler_with_discovery(product_version: int = None, host: str = 'localhost', port: int = None, api_version: ansys.geometry.core.connection.backend.ApiVersions = ApiVersions.LATEST, timeout: int = 150, manifest_path: str = None, hidden: bool = False, server_log_level: int = 2, client_log_level: int = logging.INFO, client_log_file: str = None, log_level: int = None, **kwargs: dict | None)#

Start Ansys Discovery locally using the ProductInstance class.

Note

Support for Ansys Discovery is restricted to Ansys 24.1 onward.

When calling this method, a standalone Discovery session is started. By default, if an endpoint is specified (by defining host and port parameters) but the endpoint is not available, the startup will fail. Otherwise, it will try to launch its own service.

Parameters:
product_version: int, optional

The product version to be started. Goes from v23.2.1 to the latest. Default is None. If a specific product version is requested but not installed locally, a SystemError will be raised.

Ansys products versions and their corresponding int values:

  • 241 : Ansys 24R1

host: str, optional

IP address at which the Discovery session will be deployed. By default, its value will be localhost.

portint, optional

Port at which the Geometry service will be deployed. By default, its value will be None.

api_version: ApiVersions, optional

The backend’s API version to be used at runtime. Goes from API v21 to the latest. Default is ApiVersions.LATEST.

timeoutint, optional

Timeout for starting the backend startup process. The default is 150.

manifest_pathstr, optional

Used to specify a manifest file path for the ApiServerAddin. This way, it is possible to run an ApiServerAddin from a version an older product version.

hiddenstarts the product hiding its UI. Default is False.
server_log_levelint, optional
Backend’s log level from 0 to 3:

0: Chatterbox 1: Debug 2: Warning 3: Error

The default is 2 (Warning).

client_log_levelint, optional

Logging level to apply to the client. By default, INFO level is used. Use the logging module’s levels: DEBUG, INFO, WARNING, ERROR, CRITICAL.

client_log_filestr, optional

Sets the client’s log file path. If nothing is defined, the client will log to the console.

log_levelint, optional

DEPRECATED. Use server_log_level instead.

**kwargsdict, default: None

Placeholder to prevent errors when passing additional arguments that are not compatible with this method.

Returns:
Modeler

Instance of the Geometry service.

Raises:
ConnectionError

If the specified endpoint is already in use, a connection error will be raised.

SystemError:

If there is not an Ansys product 23.2 version or later installed or if a specific product’s version is requested but not installed locally then a SystemError will be raised.

Examples

Starting an Ansys Discovery session with the default parameters and getting back a Modeler object:

>>> from ansys.geometry.core import launch_modeler_with_discovery
>>> modeler = launch_modeler_with_discovery()

Starting an Ansys Discovery V 23.2 session, on address 10.171.22.44, port 5001, with chatty logs, using API v231 and a 300 seconds timeout:

>>> from ansys.geometry.core import launch_modeler_with_discovery
>>> modeler = launch_modeler_with_discovery(product_version = 232,
    host="10.171.22.44",
    port=5001,
    api_version= 231,
    timeout=300,
    server_log_level=0)
launcher.launch_modeler_with_spaceclaim(product_version: int = None, host: str = 'localhost', port: int = None, api_version: ansys.geometry.core.connection.backend.ApiVersions = ApiVersions.LATEST, timeout: int = 150, manifest_path: str = None, hidden: bool = False, server_log_level: int = 2, client_log_level: int = logging.INFO, client_log_file: str = None, log_level: int = None, **kwargs: dict | None)#

Start Ansys SpaceClaim locally using the ProductInstance class.

When calling this method, a standalone SpaceClaim session is started. By default, if an endpoint is specified (by defining host and port parameters) but the endpoint is not available, the startup will fail. Otherwise, it will try to launch its own service.

Parameters:
product_version: int, optional

The product version to be started. Goes from v23.2.1 to the latest. Default is None. If a specific product version is requested but not installed locally, a SystemError will be raised.

Ansys products versions and their corresponding int values:

  • 232 : Ansys 23R2 SP1

  • 241 : Ansys 24R1

host: str, optional

IP address at which the SpaceClaim session will be deployed. By default, its value will be localhost.

portint, optional

Port at which the Geometry service will be deployed. By default, its value will be None.

api_version: ApiVersions, optional

The backend’s API version to be used at runtime. Goes from API v21 to the latest. Default is ApiVersions.LATEST.

timeoutint, optional

Timeout for starting the backend startup process. The default is 150.

manifest_pathstr, optional

Used to specify a manifest file path for the ApiServerAddin. This way, it is possible to run an ApiServerAddin from a version an older product version.

hiddenstarts the product hiding its UI. Default is False.
server_log_levelint, optional
Backend’s log level from 0 to 3:

0: Chatterbox 1: Debug 2: Warning 3: Error

The default is 2 (Warning).

client_log_levelint, optional

Logging level to apply to the client. By default, INFO level is used. Use the logging module’s levels: DEBUG, INFO, WARNING, ERROR, CRITICAL.

client_log_filestr, optional

Sets the client’s log file path. If nothing is defined, the client will log to the console.

log_levelint, optional

DEPRECATED. Use server_log_level instead.

**kwargsdict, default: None

Placeholder to prevent errors when passing additional arguments that are not compatible with this method.

Returns:
Modeler

Instance of the Geometry service.

Raises:
ConnectionError

If the specified endpoint is already in use, a connection error will be raised.

SystemError

If there is not an Ansys product 23.2 version or later installed or if a specific product’s version is requested but not installed locally then a SystemError will be raised.

Examples

Starting an Ansys SpaceClaim session with the default parameters and get back a Modeler object:

>>> from ansys.geometry.core import launch_modeler_with_spaceclaim
>>> modeler = launch_modeler_with_spaceclaim()

Starting an Ansys SpaceClaim V 23.2 session, on address 10.171.22.44, port 5001, with chatty logs, using API v231 and a 300 seconds timeout:

>>> from ansys.geometry.core import launch_modeler_with_spaceclaim
>>> modeler = launch_modeler_with_spaceclaim(product_version = 232,
    host="10.171.22.44",
    port=5001,
    api_version= 231,
    timeout=300,
    server_log_level=0)