Skip to content

Commit d4fc542

Browse files
committed
[ci] Switch gradle build script from groovy to kotlin
1 parent 1956694 commit d4fc542

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1291
-1130
lines changed

awscurl/build.gradle

Lines changed: 0 additions & 44 deletions
This file was deleted.

awscurl/build.gradle.kts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
plugins {
2+
ai.djl.javaProject
3+
}
4+
5+
dependencies {
6+
implementation(platform("ai.djl:bom:${version}"))
7+
implementation(libs.huggingface.tokenizers) {
8+
exclude(group = "org.apache.commons", module = "commons-compress")
9+
}
10+
implementation(libs.slf4j.simple)
11+
implementation(libs.commons.cli)
12+
implementation(libs.commons.codec)
13+
implementation(libs.apache.httpclient)
14+
implementation(libs.apache.httpmime)
15+
16+
testImplementation(libs.netty.http)
17+
testImplementation(libs.testng) {
18+
exclude(group = "junit", module = "junit")
19+
}
20+
21+
tasks {
22+
jar {
23+
manifest {
24+
attributes["Main-Class"] = "ai.djl.awscurl.AwsCurl"
25+
}
26+
includeEmptyDirs = false
27+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
28+
from(configurations.runtimeClasspath.get().map {
29+
if (it.isDirectory()) it else zipTree(it).matching {
30+
exclude("**/*.so")
31+
exclude("**/*.dylib")
32+
exclude("**/*.dll")
33+
}
34+
})
35+
36+
doLast {
37+
exec {
38+
workingDir(".")
39+
executable("sh")
40+
args(
41+
"-c",
42+
"cat src/main/scripts/stub.sh build/libs/awscurl*.jar > build/awscurl && chmod +x build/awscurl"
43+
)
44+
}
45+
}
46+
}
47+
}
48+
}

benchmark/build.gradle

Lines changed: 0 additions & 148 deletions
This file was deleted.

benchmark/build.gradle.kts

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
@file:Suppress("UNCHECKED_CAST")
2+
3+
import com.netflix.gradle.plugins.deb.Deb
4+
5+
plugins {
6+
ai.djl.javaProject
7+
application
8+
id("com.netflix.nebula.ospackage") version "11.4.0"
9+
}
10+
11+
dependencies {
12+
implementation(platform("ai.djl:bom:${version}"))
13+
implementation(project(":wlm"))
14+
15+
implementation(libs.commons.cli)
16+
implementation(libs.apache.log4j.slf4j)
17+
implementation("ai.djl:model-zoo")
18+
19+
runtimeOnly("ai.djl.pytorch:pytorch-model-zoo")
20+
runtimeOnly("ai.djl.tensorflow:tensorflow-model-zoo")
21+
runtimeOnly("ai.djl.mxnet:mxnet-model-zoo")
22+
runtimeOnly("ai.djl.ml.xgboost:xgboost")
23+
runtimeOnly("ai.djl.tensorrt:tensorrt")
24+
runtimeOnly("ai.djl.huggingface:tokenizers")
25+
runtimeOnly(project(":engines:python"))
26+
27+
testImplementation(libs.testng) {
28+
exclude(group = "junit", module = "junit")
29+
}
30+
31+
if (hasGpu) {
32+
runtimeOnly("ai.djl.onnxruntime:onnxruntime-engine") {
33+
exclude(group = "com.microsoft.onnxruntime", module = "onnxruntime")
34+
}
35+
runtimeOnly(libs.onnxruntime.gpu)
36+
} else {
37+
runtimeOnly("ai.djl.onnxruntime:onnxruntime-engine")
38+
}
39+
}
40+
41+
tasks {
42+
application {
43+
mainClass = System.getProperty("main", "ai.djl.benchmark.Benchmark")
44+
}
45+
46+
run.configure {
47+
environment("TF_CPP_MIN_LOG_LEVEL", "1") // turn off TensorFlow print out
48+
systemProperties = System.getProperties().toMap() as Map<String, Any>
49+
systemProperties.remove("user.dir")
50+
}
51+
52+
register<JavaExec>("benchmark") {
53+
environment("TF_CPP_MIN_LOG_LEVEL", "1") // turn off TensorFlow print out
54+
val arguments = gradle.startParameter.taskRequests[0].args
55+
for (argument in arguments) {
56+
if (argument.trim().startsWith("--args")) {
57+
var line = argument.split("=", limit = 2)
58+
if (line.size == 2) {
59+
line = line[1].split(" ")
60+
if (line.contains("-t")) {
61+
if (System.getProperty("ai.djl.default_engine") == "TensorFlow") {
62+
environment("OMP_NUM_THREADS", "1")
63+
environment("TF_NUM_INTRAOP_THREADS", "1")
64+
} else {
65+
environment("MXNET_ENGINE_TYPE", "NaiveEngine")
66+
environment("OMP_NUM_THREADS", "1")
67+
}
68+
}
69+
break
70+
}
71+
}
72+
}
73+
74+
systemProperties = System.getProperties().toMap() as Map<String, Any>
75+
systemProperties.remove("user.dir")
76+
classpath = sourceSets.main.get().runtimeClasspath
77+
// restrict the jvm heap size for better monitoring benchmark
78+
if (project.hasProperty("loggc")) {
79+
jvmArgs("-Xmx2g", "-Xlog:gc*=debug:file=build/gc.log")
80+
} else {
81+
jvmArgs("-Xmx2g")
82+
}
83+
mainClass = "ai.djl.benchmark.Benchmark"
84+
}
85+
86+
register("prepareDeb") {
87+
dependsOn(distTar)
88+
doFirst {
89+
exec {
90+
commandLine(
91+
"tar",
92+
"xvf",
93+
"${buildDirectory}/distributions/benchmark-${version}.tar",
94+
"-C",
95+
"$buildDirectory"
96+
)
97+
}
98+
}
99+
}
100+
101+
register<Deb>("createDeb") {
102+
dependsOn("prepareDeb")
103+
104+
packageName = "djl-bench"
105+
archiveVersion = version
106+
release = "1"
107+
maintainer = "Deep Java Library <[email protected]>"
108+
summary = "djl-bench is a command line tool that allows you to benchmark the\n" +
109+
" model on all different platforms for single-thread/multi-thread\n" +
110+
" inference performance."
111+
112+
from(buildDirectory / "benchmark-${version}") {
113+
into("/usr/local/djl-bench-${version}")
114+
}
115+
link("/usr/bin/djl-bench", "/usr/local/djl-bench-${version}/bin/benchmark")
116+
}
117+
118+
register<Exec>("installOnLinux") {
119+
dependsOn("createDeb")
120+
doFirst {
121+
if ("linux" in os) {
122+
val ver = version.toString().replace("-", "~")
123+
commandLine("sudo", "dpkg", "-i", "${buildDirectory}/distributions/djl-bench_${ver}-1_all.deb")
124+
} else {
125+
throw GradleException("task installOnLinux Only supported on Linux.")
126+
}
127+
}
128+
}
129+
130+
startScripts {
131+
doLast {
132+
val replacement = "CLASSPATH=\\\$APP_HOME/lib/*\n\n" +
133+
"if [[ \"\\\$*\" == *-t* || \"\\\$*\" == *--threads* ]]\n" +
134+
"then\n" +
135+
" export TF_CPP_MIN_LOG_LEVEL=1\n" +
136+
" export MXNET_ENGINE_TYPE=NaiveEngine\n" +
137+
" export OMP_NUM_THREADS=1\n" +
138+
" export TF_NUM_INTRAOP_THREADS=1\n" +
139+
"fi"
140+
141+
unixScript.text = unixScript.text
142+
.replace(Regex("CLASSPATH=\\\$APP_HOME/lib/.*"), replacement)
143+
.replace("/usr/bin/env sh", "/usr/bin/env bash")
144+
.replace("#!/bin/sh", "#!/bin/bash")
145+
}
146+
}
147+
}

0 commit comments

Comments
 (0)