fluent_container#

Provides a module for launching and configuring local Fluent Docker container runs.

Notes#

For configuration details, see configure_container_dict(), and for a list of additional Docker container run configuration options that can also be specified through the container_dict argument for launch_fluent(), see documentation for Docker run.

For the Fluent Docker container to be able to find license information, the license file or server needs to be specified through the ANSYSLMD_LICENSE_FILE environment variable, or the license_server argument for the container_dict (see configure_container_dict()).

Examples#

Launching a Fluent Docker container with system default configuration:

>>> import ansys.fluent.core as pyfluent
>>> session = pyfluent.launch_fluent(start_container=True)

Launching with custom configuration, using mount_source and fluent_image which are arguments for configure_container_dict(), and auto_remove which is an argument for Docker run:

>>> import ansys.fluent.core as pyfluent
>>> custom_config = {}
>>> custom_config.update(fluent_image='custom_fluent:v23.1.0', mount_source='/testing', auto_remove=False)
>>> session = pyfluent.launch_fluent(container_dict=custom_config)

Getting default Fluent Docker container configuration, then launching with customized configuration:

>>> import ansys.fluent.core as pyfluent
>>> config_dict = pyfluent.launch_fluent(start_container=True, dry_run=True)
Docker container run configuration information:
config_dict =
{'auto_remove': True,
 'command': ['-gu', '-sifile=/mnt/pyfluent/serverinfo-lpqsdldw.txt', '3ddp'],
 'detach': True,
 'environment': {'ANSYSLMD_LICENSE_FILE': '2048@licenseserver.com',
                 'REMOTING_PORTS': '54000/portspan=2'},
 'fluent_image': 'ghcr.io/ansys/pyfluent:v23.2.0',
 'labels': {'test_name': 'none'},
 'ports': {'54000': 54000},
 'volumes': ['/home/user/.local/share/ansys_fluent_core/examples:/mnt/pyfluent'],
 'working_dir': '/mnt/pyfluent'}
>>> config_dict.update(image_name='custom_fluent', image_tag='v23.1.0', mem_limit='1g')
>>> session = pyfluent.launch_fluent(container_dict=config_dict)

Exceptions:

FluentImageNameTagNotSpecified()

Raised when Fluent image name or image tag is not specified.

LicenseServerNotSpecified()

Raised when license server is not specified.

ServerInfoFileError()

Raised when server info file is not given properly.

Functions:

configure_container_dict(args[, ...])

Parses the parameters listed below, and sets up the container configuration file.

start_fluent_container(args[, container_dict])

Start a Fluent container.

exception ansys.fluent.core.launcher.fluent_container.FluentImageNameTagNotSpecified#

Bases: ValueError

Raised when Fluent image name or image tag is not specified.

__init__()#

Initializes FluentImageNameTagNotSpecified.

exception ansys.fluent.core.launcher.fluent_container.LicenseServerNotSpecified#

Bases: KeyError

Raised when license server is not specified.

__init__()#

Initializes LicenseServerNotSpecified.

exception ansys.fluent.core.launcher.fluent_container.ServerInfoFileError#

Bases: ValueError

Raised when server info file is not given properly.

__init__()#

Initializes ServerInfoFileError.

ansys.fluent.core.launcher.fluent_container.configure_container_dict(args, mount_source=None, mount_target=None, timeout=60, port=None, license_server=None, container_server_info_file=None, remove_server_info_file=True, fluent_image=None, image_name=None, image_tag=None, file_transfer_service=None, **container_dict)#

Parses the parameters listed below, and sets up the container configuration file.

Parameters:
argsList[str]

List of Fluent launch arguments.

mount_sourcestr | Path, optional

Existing path in the host operating system that will be mounted to mount_target.

mount_targetstr | Path, optional

Path inside the container where mount_source will be mounted to.

timeoutint, optional

Time limit for the Fluent container to start, in seconds. By default, 30 seconds.

portint, optional

Port for Fluent container to use.

license_serverstr, optional

License server for Ansys Fluent to use.

container_server_info_filestr | Path, optional

Name of the server information file for Fluent to write on the mount_source.

remove_server_info_filebool, optional

Defaults to True, and automatically deletes the server information file after PyFluent has finished using it.

fluent_imagestr, optional

Specifies full image name for Docker container run, with the format "image_name:image_tag". image_tag and image_name are ignored if fluent_image has been specified.

image_namestr, optional

Ignored if fluent_image has been specified.

image_tagstr, optional

Ignored if fluent_image has been specified.

file_transfer_serviceoptional

Supports file upload and download.

**container_dict

Additional keyword arguments can be specified, they will be treated as Docker container run options to be passed directly to the Docker run execution. See examples below and Docker run documentation.

Returns:
fluent_imagestr
container_dictdict
timeoutint
portint
host_server_info_filePath
remove_server_info_file: bool
Raises:
LicenseServerNotSpecified

If license server is not specified through an environment variable or in container_dict.

ServerInfoFileError

If server info file is specified through both a command-line argument inside container_dict and the container_server_info_file parameter.

FluentImageNameTagNotSpecified

If fluent_image or image_tag and image_name are not specified.

Notes

This function should usually not be called directly, it is automatically used by launch_fluent().

For a list of additional Docker container run configuration options that can also be specified using container_dict, see Docker run documentation.

See also start_fluent_container().

ansys.fluent.core.launcher.fluent_container.start_fluent_container(args, container_dict=None)#

Start a Fluent container.

Parameters:
argsList[str]

List of Fluent launch arguments.

container_dictdict, optional

Dictionary with Docker container configuration.

Returns:
int

Fluent gPRC server port exposed from the container.

str

Fluent gPRC server password exposed from the container.

Raises:
TimeoutError

If Fluent container launch reaches timeout.

Notes

Uses configure_container_dict() to parse the optional container_dict configuration.

This function should usually not be called directly, it is automatically used by launch_fluent().