From a564fb4b279504c10936695dcd2c7fee7b7b1f2a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:30:22 +0100 Subject: [PATCH] chore(deps): update dependency rocker-org/rocker-versioned2 to v4.4.2 - abandoned (#229) * chore(deps): update dependency rocker-org/rocker-versioned2 to v4.4.2 * bump R in CI * actual CLI args for build script --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: avouacr --- .github/workflows/main-workflow.yml | 18 +++---- dev/build-chain.py | 78 ++++++++++++++++++----------- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/.github/workflows/main-workflow.yml b/.github/workflows/main-workflow.yml index 55763e0..751fb21 100644 --- a/.github/workflows/main-workflow.yml +++ b/.github/workflows/main-workflow.yml @@ -61,7 +61,7 @@ jobs: image: r-minimal context: r-minimal base_image: base - r_version_1: 4.4.1 + r_version_1: 4.4.2 r_version_2: 4.3.3 secrets: inherit r-datascience: @@ -71,7 +71,7 @@ jobs: image: r-datascience context: r-datascience base_image: r-minimal - r_version_1: 4.4.1 + r_version_1: 4.4.2 r_version_2: 4.3.3 secrets: inherit jupyter-python: @@ -177,7 +177,7 @@ jobs: image: rstudio context: rstudio base_image: r-datascience - r_version_1: 4.4.1 + r_version_1: 4.4.2 r_version_2: 4.3.3 secrets: inherit sparkr: @@ -187,7 +187,7 @@ jobs: image: sparkr context: spark base_image: r-minimal - r_version_1: 4.4.1 + r_version_1: 4.4.2 r_version_2: 4.3.3 spark_version: 3.5.3 build_gpu: false @@ -199,7 +199,7 @@ jobs: image: rstudio-sparkr context: rstudio base_image: sparkr - r_version_1: 4.4.1 + r_version_1: 4.4.2 r_version_2: 4.3.3 spark_version: 3.5.3 build_gpu: false @@ -211,7 +211,7 @@ jobs: image: jupyter-r context: jupyter base_image: r-datascience - r_version_1: 4.4.1 + r_version_1: 4.4.2 r_version_2: 4.3.3 build_gpu: false secrets: inherit @@ -222,7 +222,7 @@ jobs: image: r-python-julia context: r-python-julia base_image: r-minimal - r_version_1: 4.4.1 + r_version_1: 4.4.2 build_gpu: false secrets: inherit vscode-r-python-julia: @@ -232,7 +232,7 @@ jobs: image: vscode-r-python-julia context: vscode base_image: r-python-julia - r_version_1: 4.4.1 + r_version_1: 4.4.2 build_gpu: false secrets: inherit vscode-r: @@ -242,7 +242,7 @@ jobs: image: vscode-r context: vscode base_image: r-datascience - r_version_1: 4.4.1 + r_version_1: 4.4.2 r_version_2: 4.3.3 build_gpu: false secrets: inherit diff --git a/dev/build-chain.py b/dev/build-chain.py index ff76a62..4ee0b3c 100644 --- a/dev/build-chain.py +++ b/dev/build-chain.py @@ -1,8 +1,7 @@ +import argparse import subprocess -import sys import shutil - chains = { "rstudio": ["base", "r-minimal", "r-datascience", "rstudio"], "rstudio-sparkr": ["base", "r-minimal", "spark", "rstudio"], @@ -24,42 +23,61 @@ "vscode-python-minimal": ["base", "python-minimal", "vscode"], "r-python-julia": ["base", "r-minimal", "r-python-julia"], "vscode-r-python-julia": ["base", "r-minimal", "r-python-julia", "vscode"], - "vscode-r": ["base", "r-minimal", "r-datascience", "vscode"] + "vscode-r": ["base", "r-minimal", "r-datascience", "vscode"], } -chain_name = sys.argv[1] -chain = chains[chain_name] -# GPU build if third argument says so -GPU = len(sys.argv) >= 3 and sys.argv[2] == "gpu" +# CLI configuration +parser = argparse.ArgumentParser(description="Build a Docker image chain.") +parser.add_argument( + "--chain", + required=True, + choices=chains.keys(), + help="The name of the chain to build (e.g., 'rstudio', 'python-datascience').", +) +parser.add_argument( + "--gpu", + action="store_true", + help="Whether to build with GPU support." +) +parser.add_argument( + "--version", + help="Specify a version for R or Python." +) + -# Specific R/Python version specified in fourth argument -version = sys.argv[3] if len(sys.argv) >= 4 else None -language_key = "PYTHON_VERSION" if "python-minimal" in chain else "R_VERSION" +if __name__ == "__main__": -for i, image in enumerate(chain): + # Parse build configuration from CLI args + args = parser.parse_args() + chain_name = args.chain + chain = chains[chain_name] + gpu = args.gpu + version = args.version + language_key = "PYTHON_VERSION" if "python-minimal" in chain else "R_VERSION" - if image == "base": - shutil.copytree("scripts", "base/scripts", dirs_exist_ok=True) - if GPU: - previous_image = "nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04" + # Build chain + for i, image in enumerate(chain): + if image == "base": + shutil.copytree("scripts", "base/scripts", dirs_exist_ok=True) + previous_image = "nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04" if gpu else "ubuntu:22.04" else: - previous_image = "ubuntu:22.04" - else: - previous_image = chain[i-1] + previous_image = chain[i - 1] - device_suffix = "-gpu" if GPU else "" + device_suffix = "-gpu" if gpu else "" - if i < len(chain) - 1: - tag = image - else: - tag = f"inseefrlab/onyxia-{chain_name}:dev" + if i < len(chain) - 1: + tag = image + else: + tag = f"inseefrlab/onyxia-{chain_name}:dev" - cmd = ["docker", "build", "--progress=plain", image, "-t", tag, - "--build-arg", f"BASE_IMAGE={previous_image}", - "--build-arg", f"DEVICE_SUFFIX={device_suffix}"] - if version: - cmd.extend(["--build-arg", f"{language_key}={version}"]) + cmd = [ + "docker", "build", "--progress=plain", image, "-t", tag, + "--build-arg", f"BASE_IMAGE={previous_image}", + "--build-arg", f"DEVICE_SUFFIX={device_suffix}" + ] + if version: + cmd.extend(["--build-arg", f"{language_key}={version}"]) - print(" ".join(cmd)) - subprocess.run(cmd) + print(" ".join(cmd)) + subprocess.run(cmd)