Beam_bathe example - plot_data error (Stopping the server proxy - Message: Fault)

Hello,

I just completed the installation of compas and compas_fea, and I am going through the first example file, beam_bathe. Overall, it seems to work well, as the .inp file is written and the analysis successfully executed. Unfortunately, the last line of code, which is meant to plot the data in the Rhino viewport, throws an error.
The error message:

Message: Fault

Traceback:
  line 800, in close, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1493, in parse_response, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1316, in single_request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1283, in request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1598, in _ServerProxy__request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1243, in __call__, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 334, in proxy, "C:\Users\renau\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\compas\rpc\proxy.py"
  line 959, in plot_data, "C:\Users\renau\Dropbox (MIT)\1_PhD\Code\Tools\compas\compas_fea\src\compas_fea\cad\rhino.py"
  line 73, in <module>, "C:\Users\renau\AppData\Roaming\McNeel\Rhinoceros\6.0\scripts\beam_bathe.py"

And the last lines printed in the Rhino command line:

***** Data extracted from Abaqus .odb file : 3.732 s *****

***** Saving data to structure.results successful : 0.016 s *****

Stopping the server proxy.

Note that I have the src folder of compas and compas_fea referenced in my environment variables, as recommended here.

Has anybody encountered this issue before? Any suggestions on how to solve it?

Thanks,

Renaud

Hi Renaud,

Looks like the analysis part is fine, I just checked the current beam_bathe example on my system and it is fine (double check you have pulled the latest version of compas_fea), so it must be the communication between Rhino and your system’s CPython via the rpc server in the plot_data() function.

Can you first confirm on your system (not in Rhino) that you can import compas and compas_fea, by opening a command prompt and importing both, as in the screenshot. If all is okay then no error messages will appear. If this is okay (which it most likely is as you have probably done the src folder environment variables correct, as per the link you gave), we can try to debug further.

Hi Andrew,

Thanks for the quick response. Yes, I can import both compas and compas_fea without any apparent problem (see below).


As for the version of compas_fea, I pulled from your master branch today.

Note that, for a reason unbeknownst to me, the error message fluctuates between what I’ve posted above and the following:

Message: error

Traceback:
  line 820, in connect, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\httplib.py"
  line 844, in send, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\httplib.py"
  line 882, in _send_output, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\httplib.py"
  line 1038, in endheaders, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\httplib.py"
  line 1459, in send_content, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1283, in request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1598, in _ServerProxy__request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1243, in __call__, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 334, in proxy, "C:\Users\renau\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\compas\rpc\proxy.py"
  line 959, in plot_data, "C:\Users\renau\Dropbox (MIT)\1_PhD\Code\Tools\compas\compas_fea\src\compas_fea\cad\rhino.py"
  line 575, in create_connection, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\socket.py"
  line 1311, in single_request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 73, in <module>, "C:\Users\renau\AppData\Roaming\McNeel\Rhinoceros\6.0\scripts\beam_bathe.py"

Either way, it does look related to the rpc server. I’m going to try and dig deeper into the issue.

Thanks again!

Renaud

FWIW, this is what i think is going on…

judging from both of your prompt messages there seems to be an important difference between your setups that explains the problem.

andrew has a non-Anaconda install, and renaud has an Anaconda install.

for andrew setting the environment variables will work, but for renaud the environment variables will not have an effect when using the RPC server.

RPC will check which environment to activate or use the default environment in no other is available. the activated environment, by design, will use its own set of environment variables and is thus completely unaware of compas_fea since it was never “installed” in any environment. it was just added to your system-wide PYTHONPATH and to the Modules Search Paths in Rhino.

using old-school packages (which are “installed” by adding them to PYTHONPATH) in combination with an installed version of COMPAS is currently simply not possible…

@gonzalocasas what do you think?

This explanation makes sense to me, theoretically, but the rpc server seems to be using the Python interpreter associated with my anaconda environment where compas is installed:

In the anaconda prompt, with the compas environment activated, importing compas_fea using its Python interpreter does not throw any errors:

That suggests to me that the environment activated by rpc (compas_env) has access to that module. Is this correct, or am I missing something?

the first image if from the RhinoScriptEditor in Debug mode?

Yes, it is.

it might be the problem is related to your other post. perhaps because you have a non-standard install location for Anaconda (which in previous instances was always related to not having admin rights on your computer) you are not allowed to make the required tmp folders used by RPC inthe background.

can you try running the following from Rhino

import compas
import sys

from compas.datastructures import Mesh
from compas.rpc import Proxy

from compas_rhino.artists import MeshArtist

numerical = Proxy('compas.numerical')

mesh = Mesh.from_obj(compas.get('faces.obj'))

mesh.update_default_vertex_attributes({'px': 0.0, 'py': 0.0, 'pz': 0.0})
mesh.update_default_edge_attributes({'q': 1.0})

key_index = mesh.key_index()

xyz   = mesh.get_vertices_attributes('xyz')
edges = [(key_index[u], key_index[v]) for u, v in mesh.edges()]
fixed = [key_index[key] for key in mesh.vertices_where({'vertex_degree': 2})]
q     = mesh.get_edges_attribute('q', 1.0)
loads = mesh.get_vertices_attributes(('px', 'py', 'pz'), (0.0, 0.0, 0.0))

xyz, q, f, l, r = numerical.fd_numpy(xyz, edges, fixed, q, loads)

for key, attr in mesh.vertices(True):
    index = key
    attr['x'] = xyz[index][0]
    attr['y'] = xyz[index][1]
    attr['z'] = xyz[index][2]
    attr['rx'] = r[index][0]
    attr['ry'] = r[index][1]
    attr['rz'] = r[index][2]

for index, (u, v, attr) in enumerate(mesh.edges(True)):
    attr['f'] = f[index][0]
    attr['l'] = l[index][0]

artist = MeshArtist(mesh)
artist.draw_vertices()
artist.draw_edges()
artist.draw_faces()
artist.redraw()

also, which version of COMPAS do you have?

Yes, that might be it. I have run other compas examples successfully on my laptop but never using the Proxy function and rpc server.
Running your script from Rhino yields the following error stack:

Message: Fault

Traceback:
  line 800, in close, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1493, in parse_response, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1316, in single_request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1283, in request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1598, in _ServerProxy__request, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 1243, in __call__, "C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\xmlrpclib.py"
  line 334, in proxy, "C:\Users\renau\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\compas\rpc\proxy.py"
  line 24, in <module>, "C:\Users\renau\AppData\Local\Temp\TempScript.py"

I am using the version 0.6.2.

unfortunately the only way to check is to uninstall Anaconda and make sure to reinstall it in the standard location (C:\Users\renau\Anaconda3) if your computer allows this…

but let me quickly discuss this tomorrow with a few people first. i don’t want to make you go through all of that if the problem might be related to something else…

Ok, that sounds good.
Worst case, I’ll save my environments configs and try that. It wouldn’t be the end of the world.

Thanks for the help!

Interesting but weird development. It turns out that, if I start the proxy server from outside Rhino (using the Anaconda prompt; see below), it is reused when the script is subsequently run from Rhino, and it works:
Starting the proxy server from anaconda prompt:

Result from the test script with proxy externally started:

I guess that’s a good enough short-term solution, but I’m surprised by this behavior.

okay we are getting close :slight_smile:
can you try the following and report back?

in Anaconda Prompt

conda info --envs

in Rhino

import compas_bootstrapper
from compas_bootstrapper import ENVIRONMENT_NAME
from compas_bootstrapper import PYTHON_DIRECTORY
print ENVIRONMENT_NAME
print PYTHON_DIRECTORY

and then finally, do you have COMPAS listed in the Module Search Paths in Rhino? (you shouldn’t…)

Yes :slight_smile:

conda info --envs

returns:

base                  *  C:\Program Files\Anaconda3
compas_env               C:\Users\renau\AppData\Local\conda\conda\envs\compas_env
ds3.1                    C:\Users\renau\AppData\Local\conda\conda\envs\ds3.1
mfpredict                C:\Users\renau\AppData\Local\conda\conda\envs\mfpredict
py27                     C:\Users\renau\AppData\Local\conda\conda\envs\py27
tensorflow               C:\Users\renau\AppData\Local\conda\conda\envs\tensorflow

Running the script in Rhino returns:

compas_env
C:\Users\renau\AppData\Local\conda\conda\envs\compas_env

And I do not have COMPAS in the module search paths, although I do have COMPAS_FEA referenced there.

hmm that is not what i was expecting…

@andrewliew which version of COMPAS do you have? can you confirm that compas_fea works with COMPAS 0.6.2 ?

Sorry, arrived a bit late to the party, thanks both for investigating further.

@danhaive Does your trick to run the proxy server outside of Rhino then work with plot_data() back in Rhino afterwards?

@tomvanmele I can indeed confirm the compas_fea example works with compas 0.6.2 (on my system at least). Might a compas_fea Anaconda install-able be a possible near-term solution?

@andrewliew yes, that works with plot_data() as well.

i have the feeling that PYTHONPATH is added to the active environment when Python is launched from Anaconda Prompt (because Anaconda Prompt takes care of that) but not when Python is launched in a different way; for example through a subprocess from Rhino.

that would explain why all Rhino settings seem to in order and everything works when the Proxy Server is launched from the Anaconda Prompt first, but not when it is launched from Rhino.

perhaps we should add an optional PYTHONPATH parameter to RPC that allows for adding search paths on the fly…

i will release a patch to test this.

That makes sense to me. Let me know when/if the patch is released, and I can try it out. In the meantime, I’ll start the server externally first