ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
433 stars 121 forks source link

Strange console output when opening MapdlGrpc in debugger #965

Closed da1910 closed 2 years ago

da1910 commented 2 years ago

Describe the bug Expanding a MapdlGrpc object in the pycharm debugger outputs text to the console.

To Reproduce Steps to reproduce the behavior:

  1. Run MAPDL docker container as per instructions
  2. Connect a new pyMapdl session using mapdl = Mapdl(ip="127.0.0.1", port=50052)
  3. (Possibly need to call mapdl.prep7)
  4. Open the mapdl object in the debugger in pychark

Expected behavior The object properties appear, with no output to the console

Screenshots image

System Information:

Run a PyMAPDL report

Please run the following code wherever you are experiencing the bug and paste the output below. This report helps us track down bugs and it is critical to addressing your bug:

from ansys.mapdl import core as pymapdl
print(pymapdl.Report())

-------------------------------------------------------------------------------
PyMAPDL Software and Environment Report
-------------------------------------------------------------------------------
  Date: Mon Mar 14 11:11:32 2022 GMT Standard Time
                OS : Windows
            CPU(s) : 6
           Machine : AMD64
      Architecture : 64bit
       Environment : Python
             Intel : GPU Vendor
Intel(R) UHD Graphics 630 : GPU Renderer
4.5.0 - Build 27.20.100.9664 : GPU Version
  Python 3.8.12 (heads/master:bd5e0bb, Aug 31 2021, 10:21:45) [MSC v.1929 64
  bit (AMD64)]
        matplotlib : 3.5.1
             numpy : 1.22.3
           pyvista : 0.33.3
           appdirs : 1.4.4
              tqdm : 4.63.0
            pyiges : 0.2.1
             scipy : 1.8.0
              grpc : 1.44.0
ansys.api.mapdl.v0 : 0.4.1
ansys.mapdl.reader : 0.51.10
   google.protobuf : 3.19.4
       ansys_corba : Version unknown
-------------------------------------------------------------------------------
Ansys Installation
******************
Unable to locate any Ansys installations
Ansys Environment Variables
***************************
None```
germa89 commented 2 years ago

Hi @da1910

I haven't been able to reproduce this.

Could you clarify a bit more what do you mean with:

Open the mapdl object in the debugger in pycharm

?

Do you mean print the object? In VSCode I don't see anything like:

a
b
c
da1910 commented 2 years ago

Inspecting the object in the debugger, I believe it will be evaluating each of the object's public properties. I'm well used to individual properties throwing errors when you do this, and that's fine, but the side-effect was puzzling.

I was also able to get it to crash a couple of times by doing this, I will try and work out how to reproduce that.

PyMapdlAbc

germa89 commented 2 years ago

My observations:

Recommendations

We could probably go over this and try to really understand what PyCharm is doing when "inspecting" the mapdl object. I believe it calls dir().

However, it will take quite a lot of time, so my recommendation is to avoid this problem altogether by adding a special method __dir__() to the MapdlCore class, so we can avoid PyCharm specific code.

germa89 commented 2 years ago

I realised VSCode also hangs when in debugger I inspect Mapdl.mesh.

I believe it is the same reason as the above comment.

Still nothing regarding the a b c message.

da1910 commented 2 years ago

I'll check the PR branch for #972 out this afternoon and let you know if it fixes my abc issue

germa89 commented 2 years ago

@da1910 did it fix it??