11import os
2+ import platform
23import subprocess
34import sys
45from typing import List , Optional , Tuple
56
6- from ci .ray_ci .container import Container
7+ from ci .ray_ci .configs import DEFAULT_ARCHITECTURE , DEFAULT_PYTHON_VERSION
8+ from ci .ray_ci .container import Container , get_docker_image
79
810_DOCKER_CAP_ADD = [
911 "SYS_PTRACE" ,
@@ -18,17 +20,29 @@ def __init__(
1820 docker_tag : str ,
1921 volumes : Optional [List [str ]] = None ,
2022 envs : Optional [List [str ]] = None ,
23+ python_version : Optional [str ] = None ,
2124 tmp_filesystem : Optional [str ] = None ,
25+ architecture : Optional [str ] = None ,
2226 privileged : bool = False ,
2327 ) -> None :
2428 super ().__init__ (docker_tag , volumes , envs )
2529
2630 if tmp_filesystem is not None :
2731 if tmp_filesystem != "tmpfs" :
2832 raise ValueError ("Only tmpfs is supported for tmp filesystem" )
33+
34+ self .python_version = python_version or DEFAULT_PYTHON_VERSION
2935 self .tmp_filesystem = tmp_filesystem
3036 self .privileged = privileged
3137
38+ if architecture is None :
39+ architecture = platform .machine ()
40+ if architecture .lower () == "amd64" :
41+ architecture = "x86_64"
42+ if architecture == "arm64" :
43+ architecture = "aarch64"
44+ self .architecture = architecture
45+
3246 def install_ray (
3347 self , build_type : Optional [str ] = None , mask : Optional [str ] = None
3448 ) -> List [str ]:
@@ -50,13 +64,21 @@ def install_ray(
5064 "--build-arg" ,
5165 f"BUILDKITE_CACHE_READONLY={ cache_readonly } " ,
5266 ]
67+
68+ if not build_type or build_type == "optimized" :
69+ python_version = self .python_version
70+ core_image_tag = f"ray-core-py{ python_version } "
71+ if self .architecture != DEFAULT_ARCHITECTURE :
72+ core_image_tag += f"-{ self .architecture } "
73+ ray_core_image = get_docker_image (core_image_tag )
74+ build_cmd += ["--build-arg" , f"RAY_CORE_IMAGE={ ray_core_image } " ]
75+ ray_dashboard_image = get_docker_image ("ray-dashboard" )
76+ build_cmd += ["--build-arg" , f"RAY_DASHBOARD_IMAGE={ ray_dashboard_image } " ]
77+
5378 if mask :
5479 build_cmd += ["--build-arg" , "RAY_INSTALL_MASK=" + mask ]
55- build_cmd += [
56- "-f" ,
57- "/ray/ci/ray_ci/tests.env.Dockerfile" ,
58- "/ray" ,
59- ]
80+
81+ build_cmd += ["-f" , "ci/ray_ci/tests.env.Dockerfile" , "/ray" ]
6082 subprocess .check_call (
6183 build_cmd ,
6284 env = env ,
0 commit comments