Skip to content

Commit

Permalink
More....
Browse files Browse the repository at this point in the history
  • Loading branch information
prmukherj committed Apr 4, 2024
1 parent d174d1e commit 323920f
Showing 1 changed file with 17 additions and 46 deletions.
63 changes: 17 additions & 46 deletions src/ansys/fluent/core/fluent_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,7 @@ def fluent_build_info(self) -> str:
branch = self.scheme_eval.scheme_eval("(inquire-src-vcs-branch)")
return f"Build Time: {build_time} Build Id: {build_id} Revision: {rev} Branch: {branch}"

def get_cortex_connection_properties(
self,
ip: str,
port: int,
password: Optional[str] = None,
inside_container: Optional[bool] = None,
):
def get_cortex_connection_properties(self):
"""Get connection properties of Fluent."""
from grpc._channel import _InactiveRpcError

Expand All @@ -266,16 +260,18 @@ def get_cortex_connection_properties(
cortex_pid = None
cortex_pwd = None

return cortex_host, FluentConnectionProperties(
ip,
port,
password,
cortex_pwd,
cortex_pid,
cortex_host,
fluent_host_pid,
inside_container,
)
return fluent_host_pid, cortex_host, cortex_pid, cortex_pwd
#
# return cortex_host, FluentConnectionProperties(
# ip,
# port,
# password,
# cortex_pwd,
# cortex_pid,
# cortex_host,
# fluent_host_pid,
# inside_container,
# )


class FluentConnection:
Expand Down Expand Up @@ -381,27 +377,11 @@ def __init__(
self.scheme_eval = service_creator("scheme_eval").create(
self._scheme_eval_service
)

con_props = _ConnectionProperties(self.scheme_eval)
fluent_host_pid, cortex_host, cortex_pid, cortex_pwd = (
con_props.get_cortex_connection_properties()
)
self._cleanup_on_exit = cleanup_on_exit
from grpc._channel import _InactiveRpcError

try:
logger.info(self.fluent_build_info)
logger.debug("Obtaining Cortex connection properties...")
fluent_host_pid = self.scheme_eval.scheme_eval("(cx-client-id)")
cortex_host = self.scheme_eval.scheme_eval("(cx-cortex-host)")
cortex_pid = self.scheme_eval.scheme_eval("(cx-cortex-id)")
cortex_pwd = self.scheme_eval.scheme_eval("(cortex-pwd)")
logger.debug("Cortex connection properties successfully obtained.")
except _InactiveRpcError:
logger.warning(
"Fluent Cortex properties unobtainable, force exit and other"
"methods are not going to work properly, proceeding..."
)
cortex_host = None
cortex_pid = None
cortex_pwd = None
fluent_host_pid = None

if (
(inside_container is None or inside_container is True)
Expand Down Expand Up @@ -455,15 +435,6 @@ def __init__(
)
FluentConnection._monitor_thread.cbs.append(self._finalizer)

@property
def fluent_build_info(self) -> str:
"""Get Fluent build info."""
build_time = self.scheme_eval.scheme_eval("(inquire-build-time)")
build_id = self.scheme_eval.scheme_eval("(inquire-build-id)")
rev = self.scheme_eval.scheme_eval("(inquire-src-vcs-id)")
branch = self.scheme_eval.scheme_eval("(inquire-src-vcs-branch)")
return f"Build Time: {build_time} Build Id: {build_id} Revision: {rev} Branch: {branch}"

def _close_slurm(self):
subprocess.run(["scancel", f"{self._slurm_job_id}"])

Expand Down

0 comments on commit 323920f

Please sign in to comment.