Skip to content

refactor: Make inactive object access less strict. - #5690

Open
prmukherj wants to merge 5 commits into
mainfrom
refactor/inactive_object_access
Open

prmukherj wants to merge 5 commits into
mainfrom
refactor/inactive_object_access

Conversation

@prmukherj

@prmukherj prmukherj commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Context

Children of inactive objects in the API hierarchy could not be aliased without triggering an InactiveObjectError.

>>> viscous = solver.settings.setup.models.viscous
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\spearson\AppData\Local\Temp\tmphjkcu785\ansys\fluent\core\solver\flobject.py", line 1047, in __getattribute__
    raise InactiveObjectError(self.python_path)
ansys.fluent.core.solver.flobject.InactiveObjectError: '<session>.setup.models' is currently inactive.

Change Summary

If there are no named objects in the path then we allow to traverse based on path, ie. via static info

>>> viscous = solver.settings.setup.models.viscous

>>> solver.settings.setup.models.turbulence.laminar
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\PyFluent_Dev\pyfluent\src\ansys\fluent\core\solver\flobject.py", line 1816, in __getattribute__
    return super().__getattribute__(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'turbulence' object has no attribute 'laminar'.
The most similar names are: spalart_allmaras
>>> solver.settings.setup.models.turbulence.get_state()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\PyFluent_Dev\pyfluent\src\ansys\fluent\core\solver\flobject.py", line 1467, in get_state
    self._check_active()
  File "D:\PyFluent_Dev\pyfluent\src\ansys\fluent\core\solver\flobject.py", line 999, in _check_active
    raise InactiveObjectError(obj.python_path)
ansys.fluent.core.solver.flobject.InactiveObjectError: '<session>.settings.setup.models' is currently inactive.

>>> solver.settings.setup.models.turbulence.model.allowed_values()
D:\PyFluent_Dev\pyfluent\src\ansys\fluent\core\solver\flobject.py:953: PyFluentUserWarning: '<session>.settings.setup.models' is currently inactive. Returning static allowed values for '<session>.settings.setup.models.turbulence.model' for reference only; they may not be valid in the current Fluent state.
  attrs = self.get_attrs([attr])
['laminar', 'mixing-length', 'ke1e', 'inviscid', 'spalart-allmaras', 'reynolds-stress', 'transition-sst', 'scale-adaptive-simulation', 'detached-eddy-simulation', 'large-eddy-simulation', 'k-kl-w', 'k-epsilon', 'v2f', 'zero-equation-hvac', 'k-omega']

>>> solver.settings.setup.models.turbulence.model.is_active()   
False

>>> graphics = solver.settings.results.graphics
>>> graphics.mesh["mesh-1"] = {"surfaces_list": "*"}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\PyFluent_Dev\pyfluent\src\ansys\fluent\core\solver\flobject.py", line 2945, in __setitem__
    self._check_active(for_mutation=True)
  File "D:\PyFluent_Dev\pyfluent\src\ansys\fluent\core\solver\flobject.py", line 999, in _check_active
    raise InactiveObjectError(obj.python_path)
ansys.fluent.core.solver.flobject.InactiveObjectError: '<session>.settings.results.graphics.mesh' is currently inactive.

>>> graphics.mesh.is_active()     
False
  1. get or set state raises still
  2. Attribute access are allowed via warnings

Rationale

To make the aliasing possible without raising error.

Impact

Users to get error only when they execute and not while aliasing, which makes scripting experience better.

NOTE:

In future we must reduce the contracts from client and allow all apis to be available in the client without any extra checks and must allow the server to handle these. Need to discuss on this point.

@github-actions github-actions Bot added documentation Documentation related (improving, adding, etc) enhancement Improve any current implemented feature labels Nov 30, 2026
@prmukherj prmukherj linked an issue Nov 30, 2026 that may be closed by this pull request
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Other metadata queries, or allowed-values queries without static data, raise
``InactiveObjectError``. The ``is_active()`` method reports the object's own
activity, which can differ from its ancestors' activity. Named objects must
still exist when they are accessed by name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seanpearsonuk, want your suggestion to make the last sentence sound better and read accurately, like the named object should actually exist in server to access them and statically getting them is not possible is what I mean. Could you please help in rephrasing this so as to make it sound correct?

@prmukherj
prmukherj marked this pull request as ready for review December 1, 2026 04:03

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation related (improving, adding, etc) enhancement Improve any current implemented feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Access to inactive objects

2 participants