Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for jpy integration junit tests #632

Merged
merged 3 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions py/jpy-integration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
}

evaluationDependsOn ':deephaven-jpy'
evaluationDependsOn ':Integrations'

sourceSets {
// All sourcesets here are used for testing; we'll inform the idea{} plugin, below
Expand Down Expand Up @@ -110,6 +111,51 @@ Task pythonToJava = tasks.create 'unittestPythonToJava', {
}

if (!PyEnv.pythonEnabled(project)) {
Closure<TaskProvider<Task>> gradleTestInDocker = { String taskName, SourceSet sourceSet ->

def gradleWrapper = tasks.register("${taskName}GradleInit", Wrapper.class) { wrapper ->
wrapper.scriptFile "${buildDir}/template-project/gradlew"
wrapper.jarFile "${buildDir}/template-project/gradle/wrapper/gradle-wrapper.jar"
}
return Docker.registerDockerTask(project, taskName) {
copyIn {
dependsOn gradleWrapper
from ("${buildDir}/template-project") {
into 'project'
}
from(project.file('src/javaToPython/build.gradle.template')) {
into 'project'
rename { file -> 'build.gradle' }
}
from (sourceSet.runtimeClasspath) {
into 'classpath'
}
from (sourceSet.output.getClassesDirs()) {
into 'classes'
}
}
parentContainers = [project(':Integrations').tasks.findByName('buildDeephavenPython')] // deephaven/runtime-base
dockerfile {
// base image with default java, python, wheels
from 'deephaven/runtime-base'

// set up the project
copyFile 'project', '/project'
workingDir '/project'
// run once with no actual classes, so that gradle is preinstalled and cached
runCommand '/project/gradlew'
copyFile 'classpath', '/classpath'
copyFile 'classes', '/classes'
}
entrypoint = ['/project/gradlew', 'test', '--info']
containerOutPath = '/project/build/test-results/test/'
copyOut {
into "${buildDir}/test-results/${taskName}"
}
}
}
testJavaToPython.dependsOn gradleTestInDocker('java-to-python-test', sourceSets.javaToPython)

// Task testTask = venvTest.javaTest(project, "java-to-python-test-${pv.name}", installWheels, sourceSets.javaToPython)
// testJavaToPython.dependsOn testTask

Expand Down
19 changes: 19 additions & 0 deletions py/jpy-integration/src/javaToPython/build.gradle.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java-library'
}

// Classpath is already built, just need to pass to the test task
test.classpath = fileTree('/classpath/').plus(files('/classpath'))
test.testClassesDirs = files('/classes')

test.systemProperties([
'jpy.jpyLib':'/usr/local/lib/python3.7/dist-packages/jpy.cpython-37m-x86_64-linux-gnu.so',
'jpy.jdlLib':'/usr/local/lib/python3.7/dist-packages/jdl.cpython-37m-x86_64-linux-gnu.so',
'jpy.pythonLib':'/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0',
// Cleaning up on a dedicated thread has some issues when there is frequent starting
// and stopping of the python virtual environment. We'll rely on cleaning up inline
// when necessary.
// TODO issue #651 to see if we can remove this
'PyObject.cleanup_on_thread':'false',
// 'jpy.debug':'true'
])
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ java_home = '${javaHome}'
jvm_dll = None
jvm_maxmem = '${jvmMaxMem}'
jvm_classpath = ['${jvmClasspath}']
jvm_properties = {'PyObject.cleanup_on_thread': 'false'}
jvm_properties = {'PyObject.cleanup_on_thread': 'false'} # TODO issue #651 to see if we can remove this
#jvm_options = ['-Djpy.debug=true']
jvm_options = []