Skip to content

fix: Remove a runtime attribute query for argument-aliases #4241

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

Merged
merged 4 commits into from
Jul 8, 2025
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
1 change: 1 addition & 0 deletions doc/changelog.d/4241.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove a runtime attribute query for argument-aliases
34 changes: 19 additions & 15 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,11 +1650,16 @@ def _get_new_keywords(obj, *args, **kwds):
newkwds[argName] = arg
if kwds:
# Convert deprecated keywords through aliases
# We don't get arguments-aliases from static-info yet.
argument_aliases_scm = obj.get_attr("arguments-aliases") or {}
argument_aliases = {}
for k, v in argument_aliases_scm.items():
argument_aliases[to_python_name(k)] = to_python_name(v.removeprefix("'"))
if FluentVersion(obj._version) >= FluentVersion.v252:
argument_aliases = {k: v[0] for k, v in obj._child_aliases.items()}
else:
# Arguments-aliases was not statically available before v252.
argument_aliases_scm = obj.get_attr("arguments-aliases") or {}
argument_aliases = {}
for k, v in argument_aliases_scm.items():
argument_aliases[to_python_name(k)] = to_python_name(
v.removeprefix("'")
)
for k, v in kwds.items():
alias = argument_aliases.get(k)
if alias:
Expand Down Expand Up @@ -1781,13 +1786,6 @@ def execute_command(self, *args, **kwds):
assert_type(ret, base_t._state_type)
return ret

def __call__(self, *args, **kwds):
try:
return self.execute_command(*args, **kwds)
except KeyboardInterrupt:
self._root._on_interrupt(self)
raise KeyboardInterrupt


# TODO: Remove this after parameter list() method is fixed from Fluent side
def _fix_parameter_list_return(val):
Expand Down Expand Up @@ -1824,6 +1822,8 @@ class Command(BaseCommand):

def __call__(self, **kwds):
"""Call a command with the specified keyword arguments."""
if not self.is_active():
raise InactiveObjectError(self.python_path)
try:
return self.execute_command(**kwds)
except KeyboardInterrupt:
Expand All @@ -1836,6 +1836,8 @@ class CommandWithPositionalArgs(BaseCommand):

def __call__(self, *args, **kwds):
"""Call a command with the specified positional and keyword arguments."""
if not self.is_active():
raise InactiveObjectError(self.python_path)
try:
return self.execute_command(*args, **kwds)
except KeyboardInterrupt:
Expand All @@ -1848,6 +1850,8 @@ class Query(Action):

def __call__(self, **kwds):
"""Call a query with the specified keyword arguments."""
if not self.is_active():
raise InactiveObjectError(self.python_path)
kwds = _get_new_keywords(self, **kwds)
scmKwds = {}
for arg, value in kwds.items():
Expand Down Expand Up @@ -2241,14 +2245,14 @@ def _process_cls_names(info_dict, names, write_doc=False):
child_aliases = info.get("child-aliases") or info.get("child_aliases", {})
command_aliases = info.get("command-aliases") or info.get("command_aliases", {})
query_aliases = info.get("query-aliases") or info.get("query_aliases", {})
argument_aliases = info.get("arguments-aliases") or info.get(
arguments_aliases = info.get("arguments-aliases") or info.get(
"arguments_aliases", {}
)
if child_aliases or command_aliases or query_aliases or argument_aliases:
if child_aliases or command_aliases or query_aliases or arguments_aliases:
cls._child_aliases = {}
# No need to differentiate in the Python implementation
for k, v in (
child_aliases | command_aliases | query_aliases | argument_aliases
child_aliases | command_aliases | query_aliases | arguments_aliases
).items():
# Storing the original name as we don't have any other way
# to recover it at runtime.
Expand Down