-
Notifications
You must be signed in to change notification settings - Fork 909
/
Copy pathbuild.gradle
170 lines (144 loc) · 4.05 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
}
}
plugins {
id "com.palantir.docker" version "0.27.0"
id "com.palantir.docker-run" version "0.27.0"
}
// needed for palantir plugin
task build {
}
// docker & docker run
docker {
name "unit8/darts"
// ./gradlew dockerPushVersion will push image with tag ${version}
// ${version} is property passed from command line during workflow
tag "version", "unit8/darts:${version}"
// ./gradlew dockerPushLatest will push image with tag 'latest'
tag "latest", "unit8/darts:latest"
dockerfile file("${project.rootDir}/Dockerfile")
// needed files for docker and to build library
files "README.md", "setup.py", "setup.cfg"
copySpec.with {
from(".") {
include "examples/**"
into "."
}
from(".") {
include "darts/**"
into "."
}
from(".") {
include "requirements/**"
into "."
}
}
}
dockerRun {
name "unit8_darts"
image "unit8/darts:latest"
ports "8888:8888"
daemonize false
clean true
}
// setup requirements
task setupPip(type: Exec) {
commandLine "python", "-m", "pip", "install", "--upgrade", "pip<22" // <22 is workaround for https://github.com/jazzband/pip-tools/issues/1558
}
task installPipLatest {
dependsOn setupPip
doLast {
exec {
commandLine "pip", "install", "pip-tools"
}
exec {
commandLine "pip-compile", "-o", "requirements-latest.txt"
}
exec {
commandLine "pip", "install", "-r", "requirements-latest.txt"
}
}
}
void createPipInstallTask(String flavour) {
String taskName = "pip_" + flavour;
String taskArgument = "requirements/" + flavour + ".txt";
task (taskName, type: Exec) {
commandLine "pip", "install", "-q", "-r", taskArgument
}
}
String[] flavours = ["core", "prophet", "pmdarima", "dev", "torch", "release"];
for(String flavour : flavours) {
createPipInstallTask(flavour);
}
task installLocally(type:Exec) {
commandLine "pip", "install", "."
}
task pipInstall() {
doFirst {
setupPip
}
dependsOn pip_core, pip_dev, pip_prophet, pip_pmdarima, pip_torch, pip_release
}
task lint(type: Exec) {
dependsOn pip_dev
commandLine "flake8", "--config=setup.cfg", "--exit-zero", "darts"
}
void createPipRelatedTask(String flavour) {
String taskName = "unitTest_" + flavour;
String taskArgument = "pip_" + flavour;
task (taskName, type: Exec) {
dependsOn(taskArgument)
dependsOn pip_core
dependsOn pip_dev
commandLine "pytest", "--durations=50", "--cov=darts", "--cov-config=.coveragerc", "--cov-report=xml", "darts/tests"
}
taskName = "test_" + flavour;
String taskArgument1 = "unitTest_" + flavour;
task (taskName) {
dependsOn(taskArgument1)
dependsOn lint
}
}
flavours = ["core", "prophet", "pmdarima", "torch"];
for(String flavour : flavours) {
createPipRelatedTask(flavour);
}
task unitTest_all(type: Exec) {
dependsOn installPipLatest, pip_dev
doFirst {
installPipLatest
}
commandLine "pytest", "--durations=50", "--cov=darts", "--cov-config=.coveragerc", "--cov-report=xml", "darts/tests"
}
task test_all() {
dependsOn unitTest_all
dependsOn lint
}
def exampleName=project.properties["exampleName"] ?: ""
task checkExample(type: Exec) {
dependsOn pipInstall, installLocally
workingDir "./examples"
// exampleName must be passed with -PexampleName=FFT-examples.ipynb
commandLine "papermill", exampleName, exampleName
doFirst {
exec {
commandLine "jupyter", "nbextension", "enable", "--py", "widgetsnbextension"
}
}
}
// Documentation build
void docSteps() {
exec {
commandLine "make", "--directory", "./docs", "build-all-docs"
}
}
task buildDocs() {
dependsOn pip_core, pip_release, installLocally
// dependsOn cleanDocs
doLast {
docSteps()
}
}