launcher#
Provides a module for launching CFX.
This module supports both starting CFX locally and connecting to a remote instance with gRPC.
Functions:
|
Connect to an existing CFX server instance. |
|
Use a factory function to create a launcher for supported launch modes. |
|
Launch CFX locally in server mode or connect to a running CFX server instance. |
- ansys.cfx.core.launcher.launcher.connect_to_cfx(ip: str | None = None, port: int | None = None, address: str | None = None, cleanup_on_exit: bool = False, start_transcript: bool = False, server_info_file_name: str | None = None, password: str | None = None, allow_remote_host: bool = False, certificates_folder: str | None = None, insecure_mode: bool = False, start_watchdog: bool | None = None) PreProcessing | Solver | PostProcessing#
Connect to an existing CFX server instance.
- Parameters:
- ip
str, default:None IP address for connecting to an existing CFX instance. When
None, the IP address defaults to"127.0.0.1". You can also use thePYCFX_CFX_IP=<ip>environment variable to set this parameter. The explicit value of theipparameter takes precedence over thePYCFX_CFX_IP=<ip>environment variable.- port
int, default:None Port to listen on for an existing CFX instance. You can also use the
PYCFX_CFX_PORT=<port>environment variable to set a default value. The explicit value of theportparameter takes precedence over thePYCFX_CFX_PORT=<port>environment variable.- address
str, default:None Address to connect to an existing CFX instance.
- cleanup_on_exitbool, default:
False Whether to shut down the connected CFX session when PyCFX is exited, or if the
exit()method is called on the session instance, or if the session instance becomes unreferenced.- start_transcriptbool, default:
False Whether to start streaming the CFX transcript in the client. You can stop and start the streaming of the CFX transcript subsequently using the
transcript.start()andtranscript.stop()methods on the session object.- server_info_file_name: str, default: None
Path to the server information file written out by CFX server. PyCFX uses the connection information in the file to connect to a running CFX session.
- password
str, default:None Password to connect to an existing CFX instance.
- allow_remote_hostbool, default:
False Whether to allow connecting to a remote CFX instance.
- certificates_folder
str, default:None Path to the folder containing TLS certificates for CFX’s gRPC server.
- insecure_modebool, default:
False Whether to connect CFX’s gRPC server in insecure mode without TLS. This mode is not recommended. For more information on the implications and usage of insecure mode, see the CFX documentation.
- start_watchdog: bool, default: None
When
cleanup_on_exitisTrue,start_watchdogdefaults toTrue, which means an independent watchdog process is run to ensure that any local CFX connections are properly closed (or terminated if frozen) when the Python process ends.
- ip
- Returns:
Union[PreProcessing,Solver,PostProcessing]Session object.
- Raises:
ValueErrorRaised when neither
certificates_foldernorinsecure_modeare set whileallow_remote_hostisTrue. Raised when bothcertificates_folderandinsecure_modeare set simultaneously. Raised whencertificates_folderis set butallow_remote_hostisFalse. Raised wheninsecure_modeis set butallow_remote_hostisFalse.
- ansys.cfx.core.launcher.launcher.create_launcher(cfx_launch_mode: LaunchMode = None, **kwargs)#
Use a factory function to create a launcher for supported launch modes.
- Parameters:
- cfx_launch_mode: LaunchMode
Supported CFX launch modes. Options are
"LaunchMode.CONTAINER"and"LaunchMode.STANDALONE".- kwargs
Any Keyword arguments.
- Returns:
- launcher:
Union[DockerLauncher,StandaloneLauncher] Session launcher.
- launcher:
- Raises:
DisallowedValuesErrorIf an unknown CFX launch mode is passed.
NotImplementedErrorIf an unimplemented CFX launch mode is passed.
- ansys.cfx.core.launcher.launcher.launch_cfx(product_version: str | None = None, journal_file_names: None | str | list[str] = None, start_timeout: int | None = None, additional_arguments: str | None = '', env: Dict[str, Any] | None = None, start_container: bool | None = None, container_dict: dict | None = None, dry_run: bool = False, cleanup_on_exit: bool = True, start_transcript: bool = False, ui_mode: UIMode | str | None = None, case_file_name: str | None = None, run_directory: str | None = None, results_file_name: str | None = None, solver_input_file_name: str | None = None, mode: CFXMode | str | None = None, cwd: str | None = None, topy: str | list | None = None, start_watchdog: bool | None = None, scheduler_options: dict | None = None, file_transfer_service: Any | None = None, **kwargs) PreProcessing | Solver | PostProcessing | dict#
Launch CFX locally in server mode or connect to a running CFX server instance.
- Parameters:
- product_version
str, default:None Version of Ansys CFX to launch. The string must be in a format like
"25.2.0"(for 2025 R2), matching the documented version format in the CFXVersion class. The default isNone, in which case the newest installed version is used.- journal_file_names
str|list[str], default:None String path to a CFX journal file or a list of such paths. CFX executes the journals.
- start_timeout
int, default:None Maximum allowable time in seconds for connecting to the CFX server. The default is
None, in which case 60 seconds is used if CFX is launched outside a Slurm environment. No timeout occurs if CFX is launched within a Slurm environment.- additional_arguments
str, default: “” Additional arguments to send to CFX as a string in the same format they are normally passed to CFX on the command line.
- env
dict, default:None Mapping to modify environment variables in CFX.
- start_containerbool, default:
None Whether to launch a CFX Docker container image. For more information about containers, see
cfx_container.- container_dict
dict, default:None Dictionary for CFX Docker container configuration. If specified, setting
start_container = Trueis redundant. CFX launches inside a Docker container using the configuration changes specified. See alsocfx_container.- dry_runbool, default:
False Whether to dry run a container start. If
True, CFX is not launched but the configuration information that would be used is printed as if CFX is being launched. If dry running a container start, thelaunch_cfx()method returns the configuredcontainer_dict.- cleanup_on_exitbool, default:
True Whether to shut down the connected CFX session when PyCFX is exited, or the
exit()method is called on the session instance, or if the session instance becomes unreferenced.- start_transcriptbool, default:
False Whether to start streaming the CFX transcript in the client. You can stop and start the streaming of the CFX transcript subsequently using the
transcript.start()andtranscript.stop()methods on the session object.- ui_mode
UIModeorstr, default:None CFX user interface mode. Options are either the values of the
UIModeenum or any of"no_gui","hidden_gui", or"gui". WhenNone,UIMode.HIDDEN_GUIis used.- case_file_name
str, default:None Name of the case file to read into a CFX-Pre session.
- run_directory
str, default:None Name of the run directory to monitor with a CFX-Solver or CFD-Post session.
- results_file_name
str, default:None Name of the results file to read into a CFD-Post session or start a CFX-Solver session.
- solver_input_file_name
str, default:None Name of the solver input file to start a CFX-Solver session.
- mode
str, default:None Launch mode of CFX to point to a specific session type. Options are
"pre-processing","solver", and"post-processing".- cwd
str, default:None Working directory for the CFX client.
- topybool or
str, default:None Boolean flag to write the equivalent Python journals from the journals passed. This parameter can optionally take the file name of a new Python journal file.
- start_watchdogbool, default:
None When
cleanup_on_exitisTrue,start_watchdogdefaults toTrue, which means an independent watchdog process is run to ensure that any local GUI-less CFX sessions started by PyCFX are properly closed (or killed if frozen) when the current Python process ends.- scheduler_options
dict, default:None Dictionary containing scheduler (such as Slurm scheduler) options.
- file_transfer_servicedefault:
None File transfer service. Uploads or downloads files to or from the server.
- kwargs
Any Keyword arguments.
- product_version
- Returns:
Union[PreProcessing,Solver,PostProcessing,dict]Session object or configuration dictionary if
dry_run = True.
- Raises:
UnexpectedKeywordArgumentIf an unexpected keyword argument is provided.
DockerContainerLaunchNotSupportedIf a CFX Docker container launch is not supported.
Notes
Job scheduler environments such as SLURM, LSF, and PBS allocate resources and compute nodes. The allocated machines and core counts are queried from the scheduler environment and passed to CFX.