Skip to content

Commit

Permalink
[ci] support artifact mount for all containers
Browse files Browse the repository at this point in the history
Signed-off-by: can <can@anyscale.com>
  • Loading branch information
can-anyscale committed Jan 5, 2024
1 parent 7b67dfa commit 60f8835
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 10 deletions.
1 change: 1 addition & 0 deletions .buildkite/build.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ steps:
- python
- core_cpp
job_env: WINDOWS
mount_windows_artifacts: true
instance_type: windows
commands:
- export BUILD_ONE_PYTHON_ONLY={{matrix}}
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/core.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ steps:
- label: ":ray: core: :windows: python tests"
tags: python
job_env: WINDOWS
mount_windows_artifacts: true
instance_type: windows
parallelism: 5
commands:
Expand Down Expand Up @@ -260,6 +261,7 @@ steps:
- label: ":ray: core: :windows: cpp tests"
tags: core_cpp
job_env: WINDOWS
mount_windows_artifacts: true
instance_type: windows
commands:
- bash ci/ray_ci/windows/install_tools.sh
Expand Down
11 changes: 9 additions & 2 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ if [ -d "/tmp/artifacts" ]; then
find /tmp/artifacts -print || true
fi

echo "Creating var/ artifact directory..."
docker run --rm -v /tmp/artifacts:/artifact-mount alpine:latest /bin/sh -c 'chown -R 2000 /artifact-mount/' || true
echo "Creating artifact directory..."
if [[ "${OSTYPE}" == linux* ]]; then
docker run --rm -v /tmp/artifacts:/artifact-mount alpine:latest /bin/sh -c 'chown -R 2000 /artifact-mount/' || true
elif [[ "${OSTYPE}" == msys ]]; then
if [[ -d "/c/tmp/artifacts" ]]; then
rm -rf /c/tmp/artifacts/*
fi
mkdir -p /c/tmp/artifacts
fi


RAYCI_CHECKOUT_DIR="$(pwd)"
Expand Down
1 change: 1 addition & 0 deletions .buildkite/ml.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ steps:
tags:
- train
job_env: WINDOWS
mount_windows_artifacts: true
instance_type: windows
commands:
- bash ci/ray_ci/windows/install_tools.sh
Expand Down
1 change: 1 addition & 0 deletions .buildkite/others.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ steps:
- label: "flaky :windows: tests"
tags: skip-on-premerge
job_env: WINDOWS
mount_windows_artifacts: true
instance_type: windows
commands:
- bash ci/ray_ci/windows/install_tools.sh
Expand Down
1 change: 1 addition & 0 deletions .buildkite/serve.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ steps:
- label: ":ray-serve: serve: :windows: tests"
tags: serve
job_env: WINDOWS
mount_windows_artifacts: true
instance_type: windows
parallelism: 2
commands:
Expand Down
1 change: 1 addition & 0 deletions .buildkite/serverless.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ steps:
- label: ":serverless: serverless: :windows: tests"
tags: python
job_env: WINDOWS
mount_windows_artifacts: true
instance_type: windows
commands:
- bash ci/ray_ci/windows/install_tools.sh
Expand Down
19 changes: 17 additions & 2 deletions ci/ray_ci/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess
import sys

from typing import List, Optional
from typing import List, Tuple, Optional

_DOCKER_ECR_REPO = os.environ.get(
"RAYCI_WORK_REPO",
Expand Down Expand Up @@ -76,7 +76,15 @@ def get_run_command(
:param script: script to run in container
:param gpu_ids: ids of gpus on the host machine
"""
command = ["docker", "run", "-i", "--rm"]
artifact_mount_host, artifact_mount_container = self.get_artifact_mount()
command = [
"docker",
"run",
"-i",
"--rm",
"--volume",
f"{artifact_mount_host}:{artifact_mount_container}",
]
for env in self.envs:
command += ["--env", env]
if network:
Expand All @@ -99,3 +107,10 @@ def get_run_command_extra_args(
gpu_ids: Optional[List[int]] = None,
) -> List[str]:
pass

@abc.abstractmethod
def get_artifact_mount(self) -> Tuple[str, str]:
"""
Get artifact mount path on host and container
"""
pass
5 changes: 4 additions & 1 deletion ci/ray_ci/linux_container.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import subprocess
import sys
from typing import List, Optional
from typing import List, Tuple, Optional

from ci.ray_ci.container import Container

Expand Down Expand Up @@ -73,3 +73,6 @@ def get_run_command_extra_args(
]

return extra_args

def get_artifact_mount(self) -> Tuple[str, str]:
return ("/tmp/artifacts", "/artifact-mount")
7 changes: 5 additions & 2 deletions ci/ray_ci/test_windows_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def _mock_subprocess(inputs: List[str], stdout, stderr) -> None:
"-t",
image,
"-f",
"c:\\workdir\\ci\\ray_ci\\windows\\tests.env.Dockerfile",
"c:\\workdir",
"C:\\workdir\\ci\\ray_ci\\windows\\tests.env.Dockerfile",
"C:\\workdir",
]


Expand All @@ -41,11 +41,14 @@ def test_get_run_command() -> None:
for env in _DOCKER_ENV:
envs.extend(["--env", env])

artifact_mount_host, artifact_mount_container = container.get_artifact_mount()
assert container.get_run_command(["hi", "hello"]) == [
"docker",
"run",
"-i",
"--rm",
"--volume",
f"{artifact_mount_host}:" f"{artifact_mount_container}",
] + envs + [
"029272617770.dkr.ecr.us-west-2.amazonaws.com/rayproject/citemp:unknown-test",
"bash",
Expand Down
9 changes: 6 additions & 3 deletions ci/ray_ci/windows_container.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import subprocess
import sys
from typing import List, Optional
from typing import List, Tuple, Optional

from ci.ray_ci.container import Container

Expand All @@ -21,8 +21,8 @@ def install_ray(self, build_type: Optional[str] = None) -> List[str]:
"-t",
self._get_docker_image(),
"-f",
"c:\\workdir\\ci\\ray_ci\\windows\\tests.env.Dockerfile",
"c:\\workdir",
"C:\\workdir\\ci\\ray_ci\\windows\\tests.env.Dockerfile",
"C:\\workdir",
],
stdout=sys.stdout,
stderr=sys.stderr,
Expand All @@ -37,3 +37,6 @@ def get_run_command_extra_args(
) -> List[str]:
assert not gpu_ids, "Windows does not support gpu ids"
return []

def get_artifact_mount(self) -> Tuple[str, str]:
return ("C:\\tmp\\artifacts", "C:\\artifact-mount")

0 comments on commit 60f8835

Please sign in to comment.