-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathfremake.py
More file actions
222 lines (213 loc) · 8.71 KB
/
fremake.py
File metadata and controls
222 lines (213 loc) · 8.71 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import click
from fre.make import create_checkout_script
from fre.make import create_makefile_script
from fre.make import create_compile_script
from fre.make import create_docker_script
from fre.make import run_fremake_script
YAMLFILE_OPT_HELP = """Experiment yaml compile FILE
"""
EXPERIMENT_OPT_HELP = """Name of experiment"""
PLATFORM_OPT_HELP = """Hardware and software FRE platform string.
This sets platform-specific data and instructions
"""
TARGET_OPT_HELP = """String that defines compilation settings and
linkage directives for experiments. Predefined targets refer to groups of directives that exist in
the mkmf template file (referenced in buildDocker.py). Possible predefined targets include 'prod',
'openmp', 'repro', 'debug, 'hdf5'; however 'prod', 'repro', and 'debug' are mutually exclusive
(cannot not use more than one of these in the target list). Any number of targets can be used.
"""
PARALLEL_OPT_HELP = """Number of concurrent model compiles (default 1)
"""
JOBS_OPT_HELP = """Number of jobs to run simultaneously; default=4. Used for make -jJOBS (parallelism with make) and git clone recursive --njobs=JOBS (# of submodules fetched simultaneously)
"""
NO_PARALLEL_CHECKOUT_OPT_HELP = """Use this option if you do not want a parallel checkout.
The default is to have parallel checkouts.
"""
VERBOSE_OPT_HELP = """Get verbose messages (repeat the option to increase verbosity level)
"""
@click.group(help=click.style(" - make subcommands", fg=(57,139,210)))
def make_cli():
pass
@make_cli.command()
@click.option("-y",
"--yamlfile",
type = str,
help = YAMLFILE_OPT_HELP,
required = True) # use click.option() over click.argument(), we want help statements
@click.option("-p",
"--platform",
multiple = True, # replaces nargs = -1, since click.option()
type = str,
help = PLATFORM_OPT_HELP, required = True)
@click.option("-t", "--target",
multiple = True,
type = str,
help = TARGET_OPT_HELP,
required = True)
@click.option("-n",
"--nparallel",
type = int,
metavar = '',
default = 1,
help = PARALLEL_OPT_HELP)
@click.option("-j",
"--njobs",
type = int,
metavar = '',
default = 4,
help = JOBS_OPT_HELP)
@click.option("-npc",
"--no-parallel-checkout",
is_flag = True,
help = NO_PARALLEL_CHECKOUT_OPT_HELP)
@click.option("-nft",
"--no-format-transfer",
is_flag = True,
default = False,
help = "Use this to skip the container format conversion to a .sif file.")
@click.option("-e",
"--execute",
is_flag = True,
default = False,
help = "Use this to run the created compilation script.")
@click.option("--force-checkout",
is_flag = True,
help = "Re-create the checkout script in case the source directory exists.")
@click.option("--force-compile",
is_flag = True,
help = "Re-create the compile script in case it exists already.")
@click.option("-v",
"--verbose",
is_flag = True,
help = VERBOSE_OPT_HELP)
def all(yamlfile, platform, target, nparallel, njobs, no_parallel_checkout, no_format_transfer, execute, verbose, force_checkout, force_compile):
""" - Perform all fre make functions; run checkout and compile scripts to create model executable or container"""
run_fremake_script.fremake_run(
yamlfile, platform, target, nparallel, njobs, no_parallel_checkout, no_format_transfer, execute, verbose, force_checkout, force_compile)
@make_cli.command()
@click.option("-y",
"--yamlfile",
type = str,
help = YAMLFILE_OPT_HELP,
required = True) # use click.option() over click.argument(), we want help statements
@click.option("-p",
"--platform",
multiple = True, # replaces nargs = -1, since click.option()
type = str,
help = PLATFORM_OPT_HELP,
required = True)
@click.option("-t", "--target",
multiple = True, # replaces nargs = -1, since click.option()
type = str,
help = TARGET_OPT_HELP,
required = True)
@click.option("-j",
"--njobs",
type = int,
metavar = '',
default = 4,
help = JOBS_OPT_HELP)
@click.option("-npc",
"--no-parallel-checkout",
is_flag = True,
help = NO_PARALLEL_CHECKOUT_OPT_HELP)
@click.option("--execute",
is_flag = True,
default = False,
help = "Use this to run the created checkout script.")
@click.option("--force-checkout",
is_flag = True,
help = "Force checkout in case the source directory exists.")
def checkout_script(yamlfile, platform, target, no_parallel_checkout, njobs, execute, force_checkout):
""" - Write the checkout script """
create_checkout_script.checkout_create(
yamlfile, platform, target, no_parallel_checkout, njobs, execute, force_checkout)
@make_cli.command
@click.option("-y",
"--yamlfile",
type = str,
help = YAMLFILE_OPT_HELP,
required = True) # use click.option() over click.argument(), we want help statements
@click.option("-p",
"--platform",
multiple = True, # replaces nargs = -1, since click.option()
type = str,
help = PLATFORM_OPT_HELP, required = True)
@click.option("-t", "--target",
multiple = True, # replaces nargs = -1, since click.option()
type = str,
help = TARGET_OPT_HELP,
required = True)
def makefile(yamlfile, platform, target):
""" - Write the makefile """
create_makefile_script.makefile_create(yamlfile, platform, target)
@make_cli.command
@click.option("-y",
"--yamlfile",
type = str,
help = YAMLFILE_OPT_HELP,
required = True) # use click.option() over click.argument(), we want help statements
@click.option("-p",
"--platform",
multiple = True, # replaces nargs = -1, since click.option()
type = str,
help = PLATFORM_OPT_HELP, required = True)
@click.option("-t", "--target",
multiple = True, # replaces nargs = -1, since click.option()
type = str,
help = TARGET_OPT_HELP,
required = True)
@click.option("-j",
"--njobs",
type = int,
metavar = '',
default = 4,
help = JOBS_OPT_HELP)
@click.option("-n",
"--nparallel",
type = int,
metavar = '', default = 1,
help = PARALLEL_OPT_HELP)
@click.option("--execute",
is_flag = True,
default = False,
help = "Use this to run the created checkout script.")
@click.option("--force-compile",
is_flag = True,
help = "Re-create the compile script in case it exists already.")
@click.option("-v",
"--verbose",
is_flag = True,
help = VERBOSE_OPT_HELP)
def compile_script(yamlfile, platform, target, njobs, nparallel, execute, verbose, force_compile):
""" - Write the compile script """
create_compile_script.compile_create(
yamlfile, platform, target, njobs, nparallel, execute, verbose, force_compile)
@make_cli.command
@click.option("-y",
"--yamlfile",
type = str,
help = YAMLFILE_OPT_HELP,
required = True)
@click.option("-p",
"--platform",
multiple = True, # replaces nargs = -1, since click.option()
type = str,
help = PLATFORM_OPT_HELP, required = True)
@click.option("-t", "--target",
multiple = True,
type = str,
help = TARGET_OPT_HELP,
required = True)
@click.option("-nft",
"--no-format-transfer",
is_flag = True,
default = False,
help = "Use this to skip the container format conversion to a .sif file.")
@click.option("--execute",
is_flag = True,
default = False,
help = "Build Dockerfile that has been generated by create-docker.")
def dockerfile(yamlfile, platform, target, no_format_transfer, execute):
""" - Write the dockerfile """
create_docker_script.dockerfile_create(yamlfile, platform, target, no_format_transfer, execute)