Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove settings API hash comparison and runtime generation of settings API classes #3399

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2207,42 +2207,34 @@ def get_root(
"""
from ansys.fluent.core import CODEGEN_OUTDIR, CODEGEN_ZIP_SETTINGS, utils

obj_info = flproxy.get_static_info()
mkundu1 marked this conversation as resolved.
Show resolved Hide resolved
try:
if os.getenv("PYFLUENT_USE_OLD_SETTINGSGEN") != "1":
if os.getenv("PYFLUENT_USE_OLD_SETTINGSGEN") != "1":
try:
settings = utils.load_module(
f"settings_{version}",
CODEGEN_OUTDIR / "solver" / f"settings_{version}.py",
)
root_cls = settings.root
except FileNotFoundError:
obj_info = flproxy.get_static_info()
root_cls, _ = get_cls("", obj_info, version=version)
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_cls = settings.root
root = 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

Expand Down
3 changes: 2 additions & 1 deletion tests/test_flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ def test_command():


def test_attrs():
r = flobject.get_root(Proxy(), version="251")
r = flobject.get_root(Proxy())
r._setattr("version", "251")
assert r.g_1.s_4.get_attr("active?")
assert r.g_1.s_4.get_attr("allowed-values") == ["foo", "bar"]
r.g_1.b_3 = True
Expand Down