forked from Droxef/darts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
150 lines (129 loc) · 3.03 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
buildscript {
repositories {
gradlePluginPortal()
}
}
plugins {
id "com.palantir.docker" version "0.25.0"
id "com.palantir.docker-run" version "0.25.0"
}
// needed for palantir plugin
task build {
}
// docker & docker run
docker {
name "unit8/darts"
tags version, "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"
}
task pipMain(type: Exec) {
commandLine "pip", "install", "-q", "-r", "requirements/main.txt"
}
task pipDev(type: Exec) {
commandLine "pip", "install", "-q", "-r", "requirements/dev.txt"
}
task pipRelease(type: Exec) {
commandLine "pip", "install", "-q", "-r", "requirements/release.txt"
}
task pipInstall() {
doFirst {
setupPip
}
dependsOn pipMain, pipDev, pipRelease
}
task installLocally(type:Exec) {
dependsOn pipInstall
commandLine "pip", "install", "."
}
// Tests
void coverageTestSteps() {
exec {
commandLine "coverage", "run", "-m", "unittest"
}
exec {
commandLine "coverage", "report", "-m", "--fail-under=80", "--omit='darts/tests*,*__init__.py'"
}
}
task unitTest(type: Exec) {
dependsOn pipMain, pipDev
commandLine "python", "-m", "unittest"
}
task coverageTest() {
dependsOn pipMain, pipDev
doLast {
coverageTestSteps()
}
}
task lint(type: Exec) {
dependsOn pipDev
commandLine "flake8", "--config=setup.cfg", "darts"
}
task test() {
dependsOn unitTest
dependsOn coverageTest
dependsOn lint
}
def exampleName=project.properties["exampleName"] ?: ""
task checkExample(type: Exec) {
dependsOn 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", "copy-examples"
}
exec {
commandLine "make", "--directory", "./docs", "generate"
}
exec {
commandLine "make", "--directory", "./docs", "readme"
}
exec {
commandLine "make", "--directory", "./docs", "html"
}
}
task cleanDocs(type: Exec) {
commandLine "make", "--directory", "./docs", "clean"
}
task buildDocs() {
dependsOn pipInstall
dependsOn cleanDocs
doLast {
docSteps()
}
}