From e6f770c650313684b68ed8f8025438f57c97272b Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Thu, 24 Oct 2024 20:43:06 -0400 Subject: [PATCH 1/3] fix: Handle unitless parameters --- src/ansys/fluent/core/solver/flobject.py | 42 ++++++++---------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/src/ansys/fluent/core/solver/flobject.py b/src/ansys/fluent/core/solver/flobject.py index 674339f3251..aaf918a6e57 100644 --- a/src/ansys/fluent/core/solver/flobject.py +++ b/src/ansys/fluent/core/solver/flobject.py @@ -2204,42 +2204,28 @@ def get_root( """ from ansys.fluent.core import CODEGEN_OUTDIR, CODEGEN_ZIP_SETTINGS, utils - obj_info = flproxy.get_static_info() - try: - if os.getenv("PYFLUENT_USE_OLD_SETTINGSGEN") != "1": - settings = utils.load_module( - f"settings_{version}", - CODEGEN_OUTDIR / "solver" / f"settings_{version}.py", + if os.getenv("PYFLUENT_USE_OLD_SETTINGSGEN") != "1": + settings = utils.load_module( + f"settings_{version}", + CODEGEN_OUTDIR / "solver" / f"settings_{version}.py", + ) + else: + if CODEGEN_ZIP_SETTINGS: + importer = zipimporter( + str(CODEGEN_OUTDIR / "solver" / f"settings_{version}.zip") ) + settings = importer.load_module("settings") else: - if CODEGEN_ZIP_SETTINGS: - importer = zipimporter( - str(CODEGEN_OUTDIR / "solver" / f"settings_{version}.zip") - ) - settings = importer.load_module("settings") - else: - settings = utils.load_module( - f"settings_{version}", - CODEGEN_OUTDIR / "solver" / f"settings_{version}" / "__init__.py", - ) - - if settings.SHASH != _gethash(obj_info): - settings_logger.warning( - "Mismatch between generated file and server object " - "info. Dynamically created settings classes will " - "be used." + settings = utils.load_module( + f"settings_{version}", + CODEGEN_OUTDIR / "solver" / f"settings_{version}" / "__init__.py", ) - raise RuntimeError("Mismatch in hash values") - cls = settings.root - except Exception: - cls, _ = get_cls("", obj_info, version=version) - root = cls() + root = settings.root() root.set_flproxy(flproxy) root._set_on_interrupt(interrupt) root._set_file_transfer_service(file_transfer_service) _Alias.scheme_eval = scheme_eval _fix_parameter_list_return.scheme_eval = scheme_eval - root._setattr("_static_info", obj_info) root._setattr("_file_transfer_service", file_transfer_service) return root From ee56536c1fec7286325c6e4b0561f7d951779686 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Thu, 24 Oct 2024 20:45:51 -0400 Subject: [PATCH 2/3] fix: Handle unitless parameters --- src/ansys/fluent/core/solver/flobject.py | 42 ++++++++++++++++-------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/ansys/fluent/core/solver/flobject.py b/src/ansys/fluent/core/solver/flobject.py index aaf918a6e57..674339f3251 100644 --- a/src/ansys/fluent/core/solver/flobject.py +++ b/src/ansys/fluent/core/solver/flobject.py @@ -2204,28 +2204,42 @@ def get_root( """ from ansys.fluent.core import CODEGEN_OUTDIR, CODEGEN_ZIP_SETTINGS, utils - if os.getenv("PYFLUENT_USE_OLD_SETTINGSGEN") != "1": - settings = utils.load_module( - f"settings_{version}", - CODEGEN_OUTDIR / "solver" / f"settings_{version}.py", - ) - else: - if CODEGEN_ZIP_SETTINGS: - importer = zipimporter( - str(CODEGEN_OUTDIR / "solver" / f"settings_{version}.zip") - ) - settings = importer.load_module("settings") - else: + obj_info = flproxy.get_static_info() + try: + if os.getenv("PYFLUENT_USE_OLD_SETTINGSGEN") != "1": settings = utils.load_module( f"settings_{version}", - CODEGEN_OUTDIR / "solver" / f"settings_{version}" / "__init__.py", + CODEGEN_OUTDIR / "solver" / f"settings_{version}.py", ) - root = settings.root() + else: + if CODEGEN_ZIP_SETTINGS: + importer = zipimporter( + str(CODEGEN_OUTDIR / "solver" / f"settings_{version}.zip") + ) + settings = importer.load_module("settings") + else: + settings = utils.load_module( + f"settings_{version}", + CODEGEN_OUTDIR / "solver" / f"settings_{version}" / "__init__.py", + ) + + if settings.SHASH != _gethash(obj_info): + settings_logger.warning( + "Mismatch between generated file and server object " + "info. Dynamically created settings classes will " + "be used." + ) + raise RuntimeError("Mismatch in hash values") + cls = settings.root + except Exception: + cls, _ = get_cls("", obj_info, version=version) + root = cls() root.set_flproxy(flproxy) root._set_on_interrupt(interrupt) root._set_file_transfer_service(file_transfer_service) _Alias.scheme_eval = scheme_eval _fix_parameter_list_return.scheme_eval = scheme_eval + root._setattr("_static_info", obj_info) root._setattr("_file_transfer_service", file_transfer_service) return root From 372025a3cce1e62fb423646125554b6443cd8f23 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Fri, 25 Oct 2024 09:09:51 -0400 Subject: [PATCH 3/3] fix: pyconsole --- src/ansys/fluent/core/solver/flobject.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ansys/fluent/core/solver/flobject.py b/src/ansys/fluent/core/solver/flobject.py index 674339f3251..8f3f89accfb 100644 --- a/src/ansys/fluent/core/solver/flobject.py +++ b/src/ansys/fluent/core/solver/flobject.py @@ -1757,8 +1757,11 @@ def _fix_parameter_list_return(val): for name, v in val.items(): value, units = v if len(units) > 0 and isinstance(units[0], str): + # Symbols are not stripped in the command return in PyConsole. + # Following code will work in both PyConsole and PyFluent. + unit = units[0].lstrip("'") unit_labels = _fix_parameter_list_return.scheme_eval( - f"(units/inquire-available-label-strings-for-quantity '{units[0]})" + f"(units/inquire-available-label-strings-for-quantity '{unit})" ) unit_label = unit_labels[0] if len(unit_labels) > 0 else "" else: