Yelp / MOE

A global, black box optimization engine for real world metric optimization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Debugging moe in pycharm

KukumavMozolo opened this issue · comments

Hi there,

i am trying to run a unit test that i wrote to test a certain functionality.
It works fine if let it execute through "sudo docker build -t moe_container ."

However i would like to be able to use the debugger in pycharm and i am running in the following import error:

==================================== ERRORS ====================================
ERROR collecting tests/optimal_learning/python/python_version/integrate/integrat_t_ei_2_test.py
/usr/local/lib/python2.7/dist-packages/py/_path/local.py:641: in pyimport
import(modname)
init.py:7: in
from moe.resources import Root
E ImportError: No module named resources
=========================== 1 error in 0.19 seconds ============================

Adding the ressource root to the PYTHONPATH did not fix it.
Does anybody know how to fix it?

Sorry I've been gone for so long! See: #448 for details.

Can you run the command outside of pycharm and outside of docker? Can you run pycharm inside of docker (like in interactive mode)? Is your src dir clean? Are you in a virtualenv?

I'm guessing that since it's a python import error and it happens intermittently, something weird is happening to your path locally. I would add
print sys.path
before import in the failing file, and see if that shows what you would expect.

I've also seen this error arise b/c __init__.py is missing or messed up, but I doubt that's the case here.

Actually i found that my virtualenv was not setup correctly and i can run unit test now. But is there a way to launch the moe app within pycharm and use the debugger??

Cool, glad you got that resolved.

I've never used pycharm, so I'm honestly not sure. If you want to launch the whole web server from within pycharm, I'd start with figuring out how to run pyramid in pycharm.

If you just want to investigate a relatively small component of MOE, I would make a little test script that does the appropriate setup and calls your function/class/etc. That should just work from within pycharm, I would think.

Lastly, maybe I'm behind the times, but I've always debugged with print statements and by adding:

... working code ...
import pdb
pdb.set_trace()
... code that you want to investigate ...

and running starting moe, running my script, or whatever from the terminal. It starts an interactive python session at the set_trace() location so you can view local variables, run commands, step through code, etc.