Closed KarinaKarina6 closed 6 months ago
Let me think.... I'm used to doing this in PyCharm; let me think of how to do it in VsCode...
Hmm... I can't see the whole file. Do you have something like this in your file?
import jpype.imports
try: jpype.startJVM(classpath=[f"resources/tetrad-current.jar"]) except OSError: print("JVM already started")
(Well, I mean, with the correct indentation...)
Sorry, maybe I'm doing something wrong.
I opened the run_continuous.py
file and ran the code step by step. This line works without errors:
import jpype.imports
After this the code is executed:
jpype.startJVM(classpath=[f"resources/tetrad-current.jar"])
Next is done:
import pandas as pd
But when I get to the line:
import tools.translate as tr
The error that I sent you in the screenshot appears.
As far as I understand, there is translate.py
code in file:
try:
jpype.startJVM(classpath=[f"resources/tetrad-current.jar"])
except OSError:
pass
except OSError
occurs
OK, tomorrow sometime, I'll pull up VSCode and give it a shot. Are you on Mac? Windows? I have both... I don't have Linux...
I'm on Windows. Thank you!
Also, let me open up my Windows laptop and see if I can get it work in VSCode... wish me luck--I don't usually use Windows...
I understand, I wish you good luck! I hope it won't be a big problem
Sorry for the delay; I got caught up in some other projects. Later today and tomorrow I'm going to spend some time on my Windows laptop (which I don't do much) so I'll have a look at this again.
I've been wrestling with the same issue in VSCode, specifically regarding imports from the .edu.cmu namespace. Running in a Linux VM container with Python 3.9 and JPype1==1.3.0. So it's not an OS specific issue.
An interesting observation is that importing TetradSearch.py works seamlessly using the syntax import tools.TetradSearch as ts. So far, I've managed to complete most tasks by utilizing pandas for data preprocessing, initializing a search object, and invoking functions through the search object.
The challenge arises when attempting to directly access any of the .edu.cmu codebase. Notably, when inspecting files within the tools directory, such as TetradSearch.py, VSCode indicates a lack of access to those imports. Interestingly, this restriction seems to vanish when importing that specific file into another script, where it appears to function correctly— throwing no input errors and is able to output plausible graphs.
My investigation into this issue has been limited thus far, but it seems that jpype, the module facilitating Java integration, might be encountering difficulties in passing back classes from the Java Virtual Machine (JVM). I haven't found a solution other than only working with the imported python objects and not trying to call any of the java codebase directly.
Huh, maybe that's the issue I'm having with it. I'll try it again this weekend and see if that's what's holding it up for me. Thanks.
Yeah, I'm not entirely sure what's going on. It's somewhat comforting to know that someone else is facing a similar issue because I've been in full-on PhD imposter mode, thinking I must be making some glaring mistake. Well, I haven't ruled out the possibility of me doing something wrong, but...
For what it's worth, I did confirm that my container is running a 64-bit version of Python and OpenJDK. If I manage to figure out what's going on in my container with the .edu imports I'll update with more info.
Thanks!
On Fri, Jan 26, 2024 at 10:27 PM Andrew Colt Deckert < @.***> wrote:
Yeah, I'm not entirely sure what's going on. It's somewhat comforting to know that someone else is facing a similar issue because I've been in full-on PhD imposter mode, thinking I must be making some glaring mistake. Well, I haven't ruled out the possibility of me doing something wrong, but...
For what it's worth, I did confirm that my container is running a 64-bit version of Python and OpenJDK. If I manage to figure out what's going on in my container with the .edu imports I'll update with more info.
— Reply to this email directly, view it on GitHub https://github.com/cmu-phil/py-tetrad/issues/16#issuecomment-1912944977, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLFSR5UEVGWJSQJNQYMLKDYQRX2ZAVCNFSM6AAAAABAZLDGBWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJSHE2DIOJXG4 . You are receiving this because you commented.Message ID: @.***>
I have mine running. It appears to be an issue with using relative paths (vscode specific?) as changing to use direct paths seems to fix the problem. Here's my working version of continuous.py. Maybe that will help Karina as well to switch to using direct paths
import jpype.imports
import sys
BASE_DIR = "/workspace/notebooks/Causal/py-tetrad/pytetrad/" #this is specific to my file directory
sys.path.append(BASE_DIR)
try:
jpype.startJVM(classpath=[f"{BASE_DIR}/resources/tetrad-current.jar"]) #alternatively works with just the full direct path called here
except OSError:
print("JVM already started")
import pandas as pd
import tools.translate as tr
import tools.TetradSearch as ts
data = pd.read_csv(f"{BASE_DIR}/resources/airfoil-self-noise.continuous.txt", sep="\t")
data = data.astype({col: "float64" for col in data.columns})
The rest is unchanged
Thanks so much! I'll try this.
By the way, in case Karina hasn't seen this, I'll tag har: @KarinaKarina6
@cdecker8 thanks a lot! I'll try this soon. I hope that everything will work out, because I really want to work with this package.
I think this is done. If not, reopen it.
Hello! I would like to know about ways to run codes. From the README I understood that files can be launched through the terminal, and this method works for me. But I would like to work with files through Visual Studio Code to be able to debug the code. Is it possible to do this? I tried to run file
run_continuous.py
through Visual Studio Code, but I encountered the following error, although everything works fine when launched from the terminal.