diff --git a/doc/changelog.d/5172.added.md b/doc/changelog.d/5172.added.md new file mode 100644 index 00000000000..39b599bf14c --- /dev/null +++ b/doc/changelog.d/5172.added.md @@ -0,0 +1 @@ +Include UDS path in connection properties. diff --git a/src/ansys/fluent/core/fluent_connection.py b/src/ansys/fluent/core/fluent_connection.py index d8cadae8a61..f7370bdddd8 100644 --- a/src/ansys/fluent/core/fluent_connection.py +++ b/src/ansys/fluent/core/fluent_connection.py @@ -247,12 +247,35 @@ def clear(self): self._details = "" -@dataclass(frozen=True) +@dataclass(frozen=True, kw_only=True) class FluentConnectionProperties: - """Stores Fluent connection properties, including connection IP, port and password; + """Stores Fluent connection properties, including connection IP/port or UDS path and password; Fluent Cortex working directory, process ID and hostname; and whether Fluent was launched in a docker container. + Attributes + ---------- + ip : str | None + IP address used to connect to Fluent. + port : int | None + Port used to connect to Fluent. + uds_fullpath : str | Path | None + Full path to the Unix Domain Socket used for local connections on Linux. + password : str | None + Password used for authentication when calling Fluent services. + cortex_pwd : str | None + Fluent Cortex working directory. + cortex_pid : int | None + Process ID of the Cortex process. + cortex_host : str | None + Hostname of the Cortex process. + fluent_host_pid : int | None + Process ID of the Fluent solver host process. + inside_container : bool | ContainerT | None + Container context for Fluent. + Returns ``False`` when not running in a container, + and the container instance when running in one. + Examples -------- These properties are also available through the session object and can be accessed as: @@ -267,6 +290,7 @@ class FluentConnectionProperties: ip: str | None = None port: int | None = None + uds_fullpath: str | Path | None = None password: str | None = None cortex_pwd: str | None = None cortex_pid: int | None = None @@ -583,14 +607,14 @@ def __init__( self._channel_str = None self._slurm_job_id = None self.finalizer_cbs = [] + self._uds_fullpath = None if channel is not None: self._channel = channel else: - uds_fullpath = None if address is not None: self._channel_str = address - uds_fullpath = get_uds_path(address) - if uds_fullpath is None: + self._uds_fullpath = get_uds_path(address) + if self._uds_fullpath is None: ip, port = address.rsplit(":", 1) port = int(port) else: @@ -599,7 +623,7 @@ def __init__( self._channel = _get_channel( ip=ip, port=port, - uds_fullpath=uds_fullpath, + uds_fullpath=self._uds_fullpath, allow_remote_host=allow_remote_host, certificates_folder=certificates_folder, insecure_mode=insecure_mode, @@ -664,14 +688,15 @@ def __init__( ) self.connection_properties = FluentConnectionProperties( - ip, - port, - password, - cortex_pwd, - cortex_pid, - cortex_host, - fluent_host_pid, - inside_container, + ip=ip, + port=port, + uds_fullpath=self._uds_fullpath, + password=password, + cortex_pwd=cortex_pwd, + cortex_pid=cortex_pid, + cortex_host=cortex_host, + fluent_host_pid=fluent_host_pid, + inside_container=inside_container, ) self._remote_instance = remote_instance