Skip to content

__class__ attribute lookup failure on Solver object #4794

@iboyd-ansys

Description

@iboyd-ansys

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

PySystemCoupling depends on pyfluent for some of its Sphinx Gallery examples. I am trying to update our ansys-fluent-core dependency from 0.35.0 to 0.37.1 as suggested by a dependabot PR.

The doc build is failing at a late stage of running an example. The example run itself completes successfully, but the Sphinx Gallery code examines various objects in order to generate "back references" for certain objects. This relies on being able to access the __class__ attribute of the objects. This is not accessible on the pyfluent Solver as the attempted access results in an AttributeError being raised. See stack trace below.

This behaviour seems to be a result of changes made in PR #4572 in session_solver.py (there are similar changes in session_meshing.py). From discussion with @seanpearsonuk, I understand that this could have a wider impact than the effect on our doc builds.

Traceback (most recent call last):
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/sphinx/events.py", line 404, in emit
        results.append(listener.handler(self.app, *args))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/sphinx_gallery/gen_gallery.py", line 814, in generate_gallery_rst
        ) = generate_dir_rst(src_dir, target_dir, gallery_conf, seen_backrefs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/sphinx_gallery/gen_rst.py", line 613, in generate_dir_rst
        results = parallel(
                  ^^^^^^^^^
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/sphinx_gallery/gen_rst.py", line 614, in <genexpr>
        p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/sphinx_gallery/gen_rst.py", line 1434, in generate_file_rst
        out_vars["backrefs"] = _get_backreferences(
                               ^^^^^^^^^^^^^^^^^^^^
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/sphinx_gallery/gen_rst.py", line 1275, in _get_backreferences
        example_code_obj = identify_names(script_blocks, ref_regex, global_variables, node)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/sphinx_gallery/backreferences.py", line 257, in identify_names
        names = list(finder.get_mapping())
                     ^^^^^^^^^^^^^^^^^^^^
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/sphinx_gallery/backreferences.py", line 112, in get_mapping
        prop = getattr(last_obj.__class__, level, None)
                       ^^^^^^^^^^^^^^^^^^
      File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/ansys/fluent/core/session_solver.py", line 361, in __getattribute__
        raise AttributeError(
    AttributeError: 'Solver' object has no attribute '__class__'

📝 Steps to reproduce

The issue can be seen in the builds for PR ansys/pysystem-coupling#576.

I cannot give anything more precise than that. Presumably the issue is not seen in pyfluent Sphinx Gallery builds so I do not know specifically what triggers it for us.

💻 Which operating system are you using?

Linux

📀 Which ANSYS version are you using?

Using Fluent 25.2.3 container

🐍 Which Python version are you using?

3.12

📦 Installed packages

ansys-fluent-core==0.37.1 is the relevant package here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue, problem or error in PyFluent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions