container_launcher#
Provides a module for launching CFX in container mode.
Examples#
>>> from ansys.cfx.core.launcher.launcher import create_launcher
>>> from ansys.cfx.core.launcher.pycfx_enums import LaunchMode
>>> container_pre_launcher = create_launcher(LaunchMode.CONTAINER,
... ui_mode=UIMode.HIDDEN_GUI,
... mode=CFXMode.PRE_PROCESSING,
... container_dict={...} )
>>> container_pre_session = container_pre_launcher()
>>> container_solver_launcher = create_launcher(LaunchMode.CONTAINER,
... ui_mode=UIMode.HIDDEN_GUI,
... mode=CFXMode.SOLVER,
... container_dict={...})
>>> container_solver_session = container_solver_launcher()
Classes:
|
Instantiates a CFX session in container mode. |
- class ansys.cfx.core.launcher.container_launcher.DockerLauncher(mode: CFXMode, ui_mode: UIMode, product_version: str | None = None, journal_file_names: None | str | list[str] = None, start_timeout: int = 60, 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, case_file_name: str | None = None, run_directory: str | None = None, results_file_name: str | None = None, solver_input_file_name: 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)#
Bases:
objectInstantiates a CFX session in container mode.
Methods:
__init__(mode, ui_mode[, product_version, ...])Launch a CFX session in container mode.
- __init__(mode: CFXMode, ui_mode: UIMode, product_version: str | None = None, journal_file_names: None | str | list[str] = None, start_timeout: int = 60, 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, case_file_name: str | None = None, run_directory: str | None = None, results_file_name: str | None = None, solver_input_file_name: 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)#
Launch a CFX session in container mode.
- Parameters:
- mode
CFXMode Launch mode of CFX to point to a specific session type.
- ui_mode
UIMode CFX user interface mode. Options are the values of the
UIModeenum.- 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 theCFXVersionclass. The default isNone, in which case the newest installed version is used.- journal_file_names
str|list[str] |None, Default:None String path to a CFX journal file or a list of such paths. CFX executes the one or more journals.
- start_timeout
int, default: 60 Maximum allowable time in seconds for connecting to the CFX server.
- 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 the
cfx_containermodule.- 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 also thecfx_containermodule.- 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.- 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.
- cwd
str, default:None Working directory for the CFX client.
- topybool or
str, default:None A Boolean flag to write the equivalent Python journals from the journals that are 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.- file_transfer_servicedefault:
None File transfer service. Uploads or downloads files to or from the server.
- mode
- 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.