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:
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. |
|
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:
- args
List
[str
] List of Fluent launch arguments.
- mount_source
str
|Path
,optional
Existing path in the host operating system that will be mounted to
mount_target
.- mount_target
str
|Path
,optional
Path inside the container where
mount_source
will be mounted to.- timeout
int
,optional
Time limit for the Fluent container to start, in seconds. By default, 30 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_tag
andimage_name
are ignored iffluent_image
has been specified.- image_name
str
,optional
Ignored if
fluent_image
has been specified.- image_tag
str
,optional
Ignored if
fluent_image
has been specified.- file_transfer_service
optional
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.
- args
- Returns:
- 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 thecontainer_server_info_file
parameter.FluentImageNameTagNotSpecified
If
fluent_image
orimage_tag
andimage_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:
- Returns:
- Raises:
TimeoutError
If Fluent container launch reaches timeout.
Notes
Uses
configure_container_dict()
to parse the optionalcontainer_dict
configuration.This function should usually not be called directly, it is automatically used by
launch_fluent()
.