bd2kccd / py-causal

Other
204 stars 50 forks source link

Building from source: "Could not initialize class edu.cmu.tetrad.util.TetradLogger" #28

Closed chiroptical closed 7 years ago

chiroptical commented 7 years ago
from pycausal import pycausal as pc
from pycausal import search as s
import pandas as pd
import pydot
df = pd.read_table("data/audiology.txt", sep="\t")
pc.start_vm(java_max_heap_size='100M')
fges = s.fgesDiscrete(df, structurePrior=1.0, samplePrior=1.0, maxDegree=3, faithfulnessAssumed=True, verbose=True, numofthreads=2)

yields:

JavaException: Could not initialize class edu.cmu.tetrad.util.TetradLogger

Any thoughts? I should mention that I am running this within a Singularity container on Arch Linux with:

pacman -S --noconfirm jdk8-openjdk
conda install -y pandas numpy pydot graphviz nomkl javabridge ipykernel
chirayukong commented 7 years ago

I've seen this on Ubuntu with r-causal before. But to be honest, I have no clue. I'm asking Duc Do, who had this problem before, on how he solved it. I'll come back to this asap.

chiroptical commented 7 years ago

@chirayukong Any ideas on this?

jdramsey commented 7 years ago

I'm clueless too, but mainly because all it says is there's an exception without printing out the exception, so it's like debugging from first principles. Is there any way you can get it to print out the exception?

Joe

On Thu, Jun 29, 2017 at 12:21 PM, Barry Moore notifications@github.com wrote:

@chirayukong https://github.com/chirayukong Any ideas on this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bd2kccd/py-causal/issues/28#issuecomment-312018498, or mute the thread https://github.com/notifications/unsubscribe-auth/AJZZR3WECStsmGHrpJkj4YzLI1x9nivBks5sI88GgaJpZM4N828n .

-- Joseph D. Ramsey Special Faculty and Director of Research Computing Department of Philosophy 135 Baker Hall Carnegie Mellon University Pittsburgh, PA 15213

jsph.ramsey@gmail.com Office: (412) 268-8063 http://www.andrew.cmu.edu/user/jdramsey

chirayukong commented 7 years ago

One way to debug is to manually call Tetrad-lib jar file like this example: https://github.com/bd2kccd/py-causal/blob/development/example/javabridge/Python-Javabridge%20calling%20directly%20Py-Causal%20FGES%20Discrete%20Example.ipynb

chiroptical commented 7 years ago

Okay, I misunderstood the installation instructions. I added the Tetrad jar file (https://cloud.ccd.pitt.edu/nexus/content/repositories/releases/edu/cmu/tetrad-gui/6.2.0/tetrad-gui-6.2.0-launch.jar ) and added the location to my CLASSPATH, but now I get (with trace):

JavaError                                 Traceback (most recent call last)
<ipython-input-6-a9cb7d410de4> in <module>()
----> 1 fges = s.fgesDiscrete(df, structurePrior=1.0, samplePrior=1.0, maxDegree=3, faithfulnessAssumed=True, verbose=True, numofthreads=2)

/usr/local/miniconda/lib/python2.7/site-packages/pycausal/search.pyc in __init__(self, df, structurePrior, samplePrior, maxDegree, faithfulnessAssumed, numofthreads, verbose, priorKnowledge)
    354     def __init__(self, df, structurePrior = 1.0, samplePrior = 1.0, maxDegree = 3, faithfulnessAssumed = True, numofthreads = 2, verbose = False, priorKnowledge = None):
    355 
--> 356         tetradData = pycausal.loadDiscreteData(df)
    357 
    358         score = javabridge.JClassWrapper('edu.cmu.tetrad.search.BDeuScore')(tetradData)

/usr/local/miniconda/lib/python2.7/site-packages/pycausal/pycausal.pyc in loadDiscreteData(df)
    205         dataReader = javabridge.JClassWrapper('edu.pitt.dbmi.data.reader.tabular.VerticalDiscreteTabularDataReader')(f,delimiter)
    206         tetradData = dataReader.readInData()
--> 207         tetradData = javabridge.static_call('edu/pitt/dbmi/causal/cmd/util/TetradDataUtils','toVerticalDiscreteDataModel','(Ledu/pitt/dbmi/data/BoxDataSet;)Ledu/cmu/tetrad/data/DataModel;', tetradData)
    208 
    209         os.remove(temp_data_path)

/usr/local/miniconda/lib/python2.7/site-packages/javabridge/jutil.pyc in static_call(class_name, method_name, sig, *args)
    930     '''
    931     env = get_env()
--> 932     fn = make_static_call(class_name, method_name, sig)
    933     args_sig = split_sig(sig[1:sig.find(')')])
    934     ret_sig = sig[sig.find(')')+1:]

/usr/local/miniconda/lib/python2.7/site-packages/javabridge/jutil.pyc in make_static_call(class_name, method_name, sig)
    909     if method_id is None:
    910         raise JavaError('Could not find method name = %s '
--> 911                         'with signature = %s' %(method_name, sig))
    912     def fn(*args):
    913         result = env.call_static_method(klass, method_id, *args)

JavaError: Could not find method name = toVerticalDiscreteDataModel with signature = (Ledu/pitt/dbmi/data/BoxDataSet;)Ledu/cmu/tetrad/data/DataModel;

Is there a specific version I should use?

chirayukong commented 7 years ago

Oh, there are actually three jar files: https://github.com/bd2kccd/py-causal/tree/development/src/pycausal/lib. The Tetrad-gui should do the work with the causal-cmd-0.2.0-SNAPSHOT.jar. However, I would suggest to use:

P.S. I need to update those javabridge examples. Some of them are not up-to-date.

chiroptical commented 7 years ago

I will work on this now.