Fix classpathresource for python script
parent
b2187a4c36
commit
7c7f9db097
|
@ -50,6 +50,11 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.nd4j</groupId>
|
||||||
|
<artifactId>nd4j-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.bytedeco.cpython.global.python;
|
import org.bytedeco.cpython.global.python;
|
||||||
|
import org.nd4j.common.io.ClassPathResource;
|
||||||
|
|
||||||
import static org.bytedeco.cpython.global.python.*;
|
import static org.bytedeco.cpython.global.python.*;
|
||||||
import static org.bytedeco.cpython.helper.python.Py_SetPath;
|
import static org.bytedeco.cpython.helper.python.Py_SetPath;
|
||||||
|
@ -182,9 +183,8 @@ public class PythonExecutioner {
|
||||||
|
|
||||||
|
|
||||||
private static String getWrappedCode(String code) {
|
private static String getWrappedCode(String code) {
|
||||||
|
ClassPathResource resource = new ClassPathResource("org/nd4j/python4j/pythonexec/pythonexec.py");
|
||||||
try (InputStream is = PythonExecutioner.class
|
try (InputStream is = resource.getInputStream()) {
|
||||||
.getResourceAsStream("org/nd4j/python4j/pythonexec/pythonexec.py")) {
|
|
||||||
String base = IOUtils.toString(is, StandardCharsets.UTF_8);
|
String base = IOUtils.toString(is, StandardCharsets.UTF_8);
|
||||||
String indentedCode = " " + code.replace("\n", "\n ");
|
String indentedCode = " " + code.replace("\n", "\n ");
|
||||||
String out = base.replace(" pass", indentedCode);
|
String out = base.replace(" pass", indentedCode);
|
||||||
|
|
Loading…
Reference in New Issue