Skip to content

Commit

Permalink
chore(deps): update dependency rocker-org/rocker-versioned2 to v4.4.2…
Browse files Browse the repository at this point in the history
… - 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 <[email protected]>
  • Loading branch information
renovate[bot] and avouacr authored Nov 26, 2024
1 parent 8a41367 commit a564fb4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 39 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
78 changes: 48 additions & 30 deletions dev/build-chain.py
Original file line number Diff line number Diff line change
@@ -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"],
Expand All @@ -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)

0 comments on commit a564fb4

Please sign in to comment.