Suppose I have a Jep instance running in my Java main method.I'd like to pass an object (not a class) from the JVM side to the Python side, so in Python I can call the methods of this object dynamically. Is this possible?
--
You received this message because you are subscribed to the Google Groups "Jep Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-project+unsubscribe@googlegroups.com.
To post to this group, send email to jep-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jep-project/28a72662-5f7f-4bac-af8f-a3478d10bd9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Yes, Jep lets you use java objects easily from python, here is a simple example:
try (Jep jep = new Jep()){
Object javaObject = new Object();
jep.set("javaObject", javaObject);
jep.eval("print(javaObject.toString())");
}
On Wed, Mar 15, 2017 at 12:53 AM, Tongfei Chen <cton...@gmail.com> wrote:
Suppose I have a Jep instance running in my Java main method.I'd like to pass an object (not a class) from the JVM side to the Python side, so in Python I can call the methods of this object dynamically. Is this possible?
--
You received this message because you are subscribed to the Google Groups "Jep Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-project...@googlegroups.com.
As per https://groups.google.com/d/msg/jep-project/uuMVFAKhIY0/vih6VDceCQAJ I implemented `ClassEnquirer````val ci = ClassList.getInstance()new JepConfig().../*** A way to be able to execute Python code embedded in the Knowscieng code base (se python folders)* #resource*/.addIncludePaths(PythonPaths.includePaths: _*).setClassEnquirer(new ClassEnquirer {override def isJavaPackage(name: String): Boolean = {if (ci.isJavaPackage(name)) {logger.info(s"isJavaPackage($name) = true")true}else if (name.startsWith("java.") || name.startsWith("io.knowscieng.")) {logger.info(s"isJavaPackage($name) = true")true}else {logger.info(s"isJavaPackage($name) = false")false}}```Now I am getting```18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(y_module.data_layer) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(y_module.data_layer.module) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(signal) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(_signal) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(enum) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(logging) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(time) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(traceback) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(linecache) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(tokenize) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(re) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(sre_compile) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(_sre) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(sre_parse) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(sre_constants) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(copyreg) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(token) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(warnings) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(string) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(_string) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(threading) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(atexit) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(pandas) = false18/05/18 03:26:13 [jep-single-thread-19] INFO orchestration: isJavaPackage(pyspark) = false18/05/18 03:26:13 [jep-single-thread-19] ERROR data_layer: Error initModule(data_layer) <class 'ModuleNotFoundError'>: No module named 'io.knowscieng'; 'io' is not a package In = 303102866, using List(/projects/knowscieng.io/.../src/main/python)```The import from the python code is for classes from "io.knowscieng".But the inquirer is not even asked.So seems to be confused by the includePaths?ThanksNick
On Friday, May 18, 2018 at 6:09:41 AM UTC-4, SemanticBeeng wrote:Hi Ben,Another question in this context, please.Have a Scala program calling a python script it works fine.Now need to pass more custom Scala objects to the script running embedded .Passing a java map works.But trying to "import java.util.ArrayList" in Python gives " <class 'ModuleNotFoundError'>: No module named 'java.util.ArrayList' "Have examples where starting a python script (not embeeded in Je) can import and call java objects.But how to do same from Python running embeddedWhat I really want is to pass custom Scala objects to embedded Python but also import same classes from Python.But seeing that passing java maps works without imports I am wondering what is the role of the import.Is the solution around setting class loaders in JepConfig?Many thanks in advance,Nick
On Thursday, March 16, 2017 at 3:25:59 PM UTC-4, Ben Steffensmeier wrote:
Yes, Jep lets you use java objects easily from python, here is a simple example:
try (Jep jep = new Jep()){
Object javaObject = new Object();
jep.set("javaObject", javaObject);
jep.eval("print(javaObject.toString())");
}
On Wed, Mar 15, 2017 at 12:53 AM, Tongfei Chen <cton...@gmail.com> wrote:
Suppose I have a Jep instance running in my Java main method.I'd like to pass an object (not a class) from the JVM side to the Python side, so in Python I can call the methods of this object dynamically. Is this possible?
--
You received this message because you are subscribed to the Google Groups "Jep Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-project...@googlegroups.com.
To post to this group, send email to jep-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jep-project/28a72662-5f7f-4bac-af8f-a3478d10bd9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Jep Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-project+unsubscribe@googlegroups.com.
To post to this group, send email to jep-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jep-project/260d091d-6420-45e0-9062-60be23f82bd8%40googlegroups.com.