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 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
|
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright 2020- The GROMACS Authors
# and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
# Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# https://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at https://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out https://www.gromacs.org.
"""A utility module to help manage the matrix of configurations for CI testing and build containers.
When called as a stand alone script, prints a Docker image name based on the
command line arguments. The Docker image name is of the form used in the GROMACS
CI pipeline jobs.
Example::
$ python3 -m utility --llvm --doxygen
gromacs/ci-ubuntu-24.04-llvm-14-docs
See Also:
:file:`buildall.sh`
As a module, provides importable argument parser and docker image name generator.
Note that the parser is created with ``add_help=False`` to make it friendly as a
parent parser, but this means that you must derive a new parser from it if you
want to see the full generated command line help.
Example::
import utility.parser
# utility.parser does not support `-h` or `--help`
parser = argparse.ArgumentParser(
description='GROMACS CI image creation script',
parents=[utility.parser])
# ArgumentParser(add_help=True) is default, so parser supports `-h` and `--help`
See Also:
:file:`scripted_gmx_docker_builds.py`
Authors:
* Paul Bauer <paul.bauer.q@gmail.com>
* Eric Irrgang <ericirrgang@gmail.com>
* Joe Jordan <e.jjordan12@gmail.com>
* Mark Abraham <mark.j.abraham@gmail.com>
* Gaurav Garg <gaugarg@nvidia.com>
"""
import argparse
parser = argparse.ArgumentParser(
description="GROMACS CI image slug options.", add_help=False
)
"""A parent parser for tools referencing image parameters.
This argparse parser is defined for convenience and may be used to partially initialize
parsers for tools.
.. warning:: Do not modify this parser.
Instead, inherit from it with the *parents* argument to :py:class:`argparse.ArgumentParser`
"""
parser.add_argument(
"--cmake",
nargs="*",
type=str,
default=["3.28.0", "3.30.3", "4.0.5"],
help="Selection of CMake version to provide to base image. (default: %(default)s)",
)
compiler_group = parser.add_mutually_exclusive_group()
compiler_group.add_argument(
"--gcc",
type=int,
default=11,
help="Select GNU compiler tool chain. (default: %(default)s) "
"Some checking is implemented to avoid incompatible combinations",
)
compiler_group.add_argument(
"--llvm",
type=str,
nargs="?",
const="14",
default=None,
help="Select LLVM compiler tool chain. "
"Some checking is implemented to avoid incompatible combinations",
)
# Note that oneAPI packages don't bump their version numbers every
# version of the umbrella release, so we may need to specify such
# package versions from time to time.
compiler_group.add_argument(
"--oneapi",
type=str,
nargs="?",
const="2024.0.0",
default=None,
help="Select Intel oneAPI package version.",
)
compiler_group.add_argument(
"--intel-llvm",
type=str,
nargs="?",
const="2022-06",
default=None,
help="Select Intel LLVM release (GitHub tag).",
)
linux_group = parser.add_mutually_exclusive_group()
linux_group.add_argument(
"--ubuntu",
type=str,
nargs="?",
const="24.04",
default="24.04",
help="Select Ubuntu Linux base image. (default: %(default)s)",
)
linux_group.add_argument(
"--centos",
type=str,
nargs="?",
const="7",
default=None,
help="Select Centos Linux base image.",
)
parser.add_argument(
"--cuda",
type=str,
nargs="?",
const="12.1",
default=None,
help="Select a CUDA version for a base Linux image from NVIDIA.",
)
parser.add_argument(
"--mpi",
type=str,
nargs="?",
const="openmpi",
default=None,
help="Enable MPI (default disabled) and optionally select distribution (default: openmpi)",
)
parser.add_argument(
"--tsan",
type=str,
nargs="?",
const="llvm",
default=None,
help="Build special compiler versions with TSAN OpenMP support",
)
parser.add_argument(
"--adaptivecpp",
type=str,
nargs="?",
default=None,
help="Select AdaptiveCpp repository tag/commit/branch.",
)
parser.add_argument(
"--rocm",
type=str,
nargs="?",
const="3.5.1",
default=None,
help="Select AMD compute engine version.",
)
parser.add_argument(
"--intel-compute-runtime",
action="store_true",
default=False,
help="Include Intel Compute Runtime.",
)
parser.add_argument(
"--oneapi-plugin-nvidia",
action="store_true",
default=False,
help="Install Codeplay oneAPI NVIDIA plugin.",
)
parser.add_argument(
"--oneapi-plugin-amd",
action="store_true",
default=False,
help="Install Codeplay oneAPI AMD plugin.",
)
parser.add_argument(
"--clfft",
type=str,
nargs="?",
const="master",
default=None,
help="Add external clFFT libraries to the build image",
)
parser.add_argument(
"--heffte",
type=str,
nargs="?",
default=None,
help="Select heffte repository tag/commit/branch.",
)
parser.add_argument(
"--nvhpcsdk",
type=str,
nargs="?",
default=None,
help="Select NVIDIA HPC SDK version.",
)
parser.add_argument(
"--doxygen",
type=str,
nargs="?",
const="1.8.5",
default=None,
help="Add doxygen environment for documentation builds. Also adds other requirements needed for final docs images.",
)
parser.add_argument(
"--cp2k",
type=str,
nargs="?",
const="9.1",
default=None,
help="Add build environment for CP2K QM/MM support",
)
parser.add_argument(
"--hdf5",
action="store_true",
default=False,
help="Install an HDF5 library.",
)
parser.add_argument(
"--plumed",
action="store_true",
default=False,
help="Install PLUMED library.",
)
parser.add_argument(
"--cross",
type=str,
nargs="?",
const="aarch64",
default=None,
choices=["aarch64", "riscv64"],
help="Add cross-compilation support for the specified architecture with QEMU emulation",
)
parser.add_argument(
"--libtorch",
type=str,
nargs="?",
const="2.9.0",
default=None,
help="Add build environment for LibTorch support",
)
# Supported Python versions for maintained branches.
_python_versions = ["3.9.13", "3.12.5"]
parser.add_argument(
"--venvs",
nargs="*",
type=str,
default=_python_versions,
help='List of Python versions ("major.minor.patch") for which to install venvs. (default: %(default)s)',
)
def image_name(configuration: argparse.Namespace) -> str:
"""Generate docker image name.
Image names have the form ``ci-<slug>``, where the configuration slug has the form::
<distro>-<version>-<compiler>-<major version>[-<gpusdk>-<version>][-<use case>]
This function also applies an appropriate Docker image repository prefix.
Arguments:
configuration: Docker image configuration as described by the parsed arguments.
"""
elements = []
for distro in ("centos", "ubuntu"):
version = getattr(configuration, distro, None)
if version is not None:
elements.append(distro + "-" + version)
break
for compiler in ("llvm", "intel_llvm", "oneapi", "gcc"):
version = getattr(configuration, compiler, None)
if version is not None:
version = (
str(version).split(".")[0] if compiler != "oneapi" else str(version)
)
elements.append(compiler + "-" + version)
break
for gpusdk in ("cuda", "adaptivecpp"):
version = getattr(configuration, gpusdk, None)
if version is not None:
elements.append(gpusdk + "-" + version)
if configuration.intel_compute_runtime:
elements.append("intel-compute-runtime")
if configuration.rocm is not None:
elements.append("rocm-" + configuration.rocm)
if configuration.cp2k is not None:
elements.append("cp2k-" + configuration.cp2k)
# Check for special cases
# The following attribute keys indicate the image is built for the named
# special use case.
cases = {"doxygen": "docs", "tsan": "tsan"}
for attr in cases:
value = getattr(configuration, attr, None)
if value is not None:
elements.append(cases[attr])
# Add cross-compilation target if specified
if configuration.cross is not None:
elements.append(f"cross-{configuration.cross}")
slug = "-".join(elements)
# we are using the GitLab container registry to store the images
# to get around issues with pulling them repeatedly from DockerHub
# and running into the image pull limitation there.
return "registry.gitlab.com/gromacs/gromacs/ci-" + slug
if __name__ == "__main__":
args = argparse.ArgumentParser(parents=[parser]).parse_args()
print(image_name(args))
|