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': '<image registry>: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:
Raised when Fluent image name or image tag is not specified. |
|
Raised when license server is not specified. |
|
Raised when server info file is not given properly. |
Functions:
|
Parses the parameters listed below, and sets up the container configuration file. |
|
Converts the dict to string while hiding the 'environment' argument from the dictionary, if the environment variable 'PYFLUENT_HIDE_LOG_SECRETS' is '1'. |
|
Start a Fluent container. |
- exception ansys.fluent.core.launcher.fluent_container.FluentImageNameTagNotSpecified#
Bases:
ValueErrorRaised when Fluent image name or image tag is not specified.
Methods:
__init__()Initializes FluentImageNameTagNotSpecified.
- __init__()#
Initializes FluentImageNameTagNotSpecified.
- exception ansys.fluent.core.launcher.fluent_container.LicenseServerNotSpecified#
Bases:
KeyErrorRaised when license server is not specified.
Methods:
__init__()Initializes LicenseServerNotSpecified.
- __init__()#
Initializes LicenseServerNotSpecified.
- exception ansys.fluent.core.launcher.fluent_container.ServerInfoFileError#
Bases:
ValueErrorRaised when server info file is not given properly.
Methods:
__init__()Initializes ServerInfoFileError.
- __init__()#
Initializes ServerInfoFileError.
- ansys.fluent.core.launcher.fluent_container.configure_container_dict(args, mount_source=None, mount_target=None, timeout=None, 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, compose_config=None, **container_dict)#
Parses the parameters listed below, and sets up the container configuration file.
- Parameters:
- args
List[str] List of Fluent launch arguments.
- mount_source
str|Path,optional Path on the host system to mount into the container. This directory will serve as the working directory for the Fluent process inside the container. If not specified, PyFluent’s current working directory will be used.
- mount_target
str|Path,optional Path inside the container where
mount_sourcewill be mounted. This will be the working directory path visible to the Fluent process running inside the container.- timeout
int,optional Time limit for the Fluent container to start, in seconds.
- port
int,optional Port for Fluent container to use.
- license_server
str,optional License server for Ansys Fluent to use.
- container_server_info_file
str|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_image
str,optional Specifies full image name for Docker container run, with the format
"image_name:image_tag".image_tagandimage_nameare ignored iffluent_imagehas been specified.- image_name
str,optional Ignored if
fluent_imagehas been specified.- image_tag
str,optional Ignored if
fluent_imagehas been specified.- file_transfer_service
optional Supports file upload and download.
- compose_config
ComposeConfig,optional Configuration for Docker Compose, if using Docker Compose to launch the container.
- **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.
- args
- Returns:
- Raises:
LicenseServerNotSpecifiedIf license server is not specified through an environment variable or in
container_dict.ServerInfoFileErrorIf server info file is specified through both a command-line argument inside
container_dictand thecontainer_server_info_fileparameter.FluentImageNameTagNotSpecifiedIf
fluent_imageorimage_tagandimage_nameare 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().Deprecated since version v0.23.dev1: ‘container_mount_path’ and ‘host_mount_path’ are deprecated. Use ‘mount_target’ and ‘mount_source’ instead.
- ansys.fluent.core.launcher.fluent_container.dict_to_str(dict)#
Converts the dict to string while hiding the ‘environment’ argument from the dictionary, if the environment variable ‘PYFLUENT_HIDE_LOG_SECRETS’ is ‘1’. This is useful for logging purposes, to avoid printing sensitive information such as license server details.
- ansys.fluent.core.launcher.fluent_container.start_fluent_container(args, container_dict=None, start_timeout=60, compose_config=None)#
Start a Fluent container.
- Parameters:
- args
List[str] List of Fluent launch arguments.
- container_dict
dict,optional Dictionary with Docker container configuration.
- start_timeout
int,optional Timeout in seconds for the container to start. If not specified, it defaults to 60 seconds.
- compose_config
ComposeConfig,optional Configuration for Docker Compose, if using Docker Compose to launch the container.
- args
- Returns:
- Raises:
TimeoutErrorIf Fluent container launch reaches timeout.
Notes
Uses
configure_container_dict()to parse the optionalcontainer_dictconfiguration.This function should usually not be called directly, it is automatically used by
launch_fluent().