-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
166 lines (149 loc) · 4.96 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
plugins {
id "base"
}
if (project != rootProject) {
project.buildDir = rootProject.buildDir
logger.info("Using root project's buildDir: $buildDir")
}
if (!project.hasProperty('dataDir')) {
def dataDirCandidate = rootProject.file('data/xml')
if (dataDirCandidate.isDirectory())
project.ext.dataDir = dataDirCandidate
else {
throw new FileNotFoundException("Data directory not found. Either put data into $dataDirCandidate, or set the dataDir property.")
}
logger.info("Using data from $dataDirCandidate")
}
project.ext.venv = "$buildDir/envs/macrogen"
repositories {
ivy {
url "https://anaconda.org/conda-forge/"
// url "https://micro.mamba.pm/api/" no HEAD support :(
patternLayout { artifact "[module]/[revision]/download/linux-64/[module]-[revision]-0.[ext]" }
metadataSources { artifact() }
content { includeGroup "micromamba" }
}
}
configurations {
python
}
dependencies {
python group: 'micromamba', name: 'micromamba', version: '2.0.0', ext: 'tar.bz2'
}
task prepareMacrogenOptions {
project.ext.macrogenArgs = []
project.ext.macrogenInputs = project.files()
project.ext.macrogenExecutable = "$venv/bin/macrogen"
project.ext.macrogenPath = "$venv/bin"
if (project.hasProperty('macrogenOptions'))
macrogenArgs.add(project.macrogenOptions)
if (project.rootProject != project) {
project.macrogenArgs.add("--genetic-bar-graph=$buildDir/www/data/genetic_bar_graph.json")
project.macrogenInputs.from(layout.buildDir.file("www/data/genetic_bar_graph.json"))
logger.info("Setup macrogen to use pregenerated data from $buildDir")
project.ext.macrogen_reports = "$buildDir/www/macrogenesis"
} else {
project.ext.macrogen_reports = "$buildDir/macrogenesis"
}
project.macrogenArgs.add("--data=$dataDir")
project.macrogenInputs.from("$dataDir/macrogen")
project.macrogenArgs.add("--report-dir=$macrogen_reports")
project.macrogenArgs.add('--progressbar=false')
}
task installMicromamba(type: Copy) {
description 'Installs MicroMamba to bootstrap Python'
project.ext.anacondaDir = "$buildDir/tools/mamba"
project.ext.conda = "$anacondaDir/bin/micromamba"
from {
configurations.python.collect {
logger.lifecycle("Extracting contrib: ${it.name}");
tarTree(resources.bzip2(it))
}
}
into anacondaDir
include "bin/micromamba"
}
task installMacrogen() {
description 'Installs the macrogenesis tool and its requirements (conda)'
dependsOn 'installMicromamba'
group 'macrogen'
inputs.files("$projectDir/envionment.yaml", "$projectDir/pyproject.toml")
outputs.dir "$buildDir/envs"
// outputs.file "$venv/bin/macrogen"
doLast {
if (new File("$venv").exists()) {
exec {
executable conda
args "--no-rc", "-r", "$anacondaDir", "-p", "$venv", "create", "-f", "$projectDir/environment.yml", "-y"
}
} else {
exec {
executable conda
args "--no-rc", "-r", "$anacondaDir", "-p", "$venv", "create", "-f", "$projectDir/environment.yml", "-y"
}
}
exec {
executable "$venv/bin/pip"
workingDir projectDir
args "install", ".[solver]"
}
}
}
task runMacrogenComplete {
description 'Runs the complete macrogenesis analysis and configuration'
dependsOn installMacrogen, prepareMacrogenOptions
doLast {
project.exec {
environment 'PATH', macrogenPath
environment 'PYTHONDONTWRITEBYTECODE', 'true'
executable macrogenExecutable
args macrogenArgs
inputs.files(project.macrogenInputs)
}
}
}
task runMacrogenAnalysis {
description 'Runs the macrogenesis analysis phase'
group 'macrogen'
dependsOn installMacrogen
dependsOn prepareMacrogenOptions
inputs.files(project.macrogenInputs)
doLast {
project.exec {
environment 'PATH', macrogenPath
environment 'PYTHONDONTWRITEBYTECODE', 'true'
executable macrogenExecutable
args macrogenArgs
args "--skip-reports"
args "-o", "$buildDir/macrogen-graphs.zip"
args "--order", "$buildDir/order.xml"
}
}
outputs.file "$buildDir/macrogen-graphs.zip"
outputs.file "$buildDir/order.xml"
}
task runMacrogenReporting {
description 'Runs the macrogenesis reporting phase'
group 'macrogen'
dependsOn installMacrogen
dependsOn prepareMacrogenOptions
dependsOn runMacrogenAnalysis
inputs.files(project.macrogenInputs)
doLast {
project.exec {
environment 'PATH', macrogenPath
environment 'PYTHONDONTWRITEBYTECODE', 'true'
args "-i", "$buildDir/macrogen-graphs.zip"
args macrogenArgs
executable macrogenExecutable
}
project.copy {
into "$buildDir/www/data"
from "$macrogen_reports"
include "witness-stats.json"
}
}
inputs.file("$buildDir/macrogen-graphs.zip")
outputs.dir("$macrogen_reports")
}
assemble.dependsOn(runMacrogenReporting)