Skip to content

Commit f8fae0f

Browse files
committed
Add tests to ensure that /tmp volume mount works
1 parent 4224bc7 commit f8fae0f

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

.github/workflows/run-tests-action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ jobs:
4545
uv venv --python 3.10
4646
uv pip install -r tests/requirements.txt
4747
48+
- name: Check Docker can write on /tmp
49+
run: |
50+
docker run --rm \
51+
-v /tmp/test-volume:/app/data \
52+
alpine:latest \
53+
/bin/sh -c "echo 'Hello from Docker!' > /app/data/test.txt"
54+
if [ -f /tmp/test-volume/test.txt ]; then
55+
echo "File exists in mounted volume"
56+
cat /tmp/test-volume/test.txt
57+
else
58+
echo "File does not exist in mounted volume"
59+
exit 1
60+
fi
61+
4862
- name: Run Hugging Face DLCs Tests
4963
run: uv run pytest -s tests/
5064
env:

tests/pytorch/training/test_trl.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def test_trl(caplog: pytest.LogCaptureFixture, tmp_path: PosixPath) -> None:
2525
tmp_path.mkdir(exist_ok=True)
2626
tmp_path.chmod(0o775)
2727

28+
# Check that the Docker volume mount can write to the `tmp_path`
29+
with open(tmp_path / "test.txt", "w") as f:
30+
f.write("Hello, World!")
31+
2832
logging.info("Running the container for TRL...")
2933
container = client.containers.run(
3034
os.getenv(
@@ -56,7 +60,7 @@ def test_trl(caplog: pytest.LogCaptureFixture, tmp_path: PosixPath) -> None:
5660
detach=True,
5761
# Mount the volume from the `tmp_path` to the `/opt/huggingface/trained_model`
5862
volumes={
59-
f"{tmp_path}/": {
63+
tmp_path: {
6064
"bind": "/opt/huggingface/trained_model",
6165
"mode": "rw",
6266
}
@@ -91,6 +95,10 @@ def test_trl_peft(caplog: pytest.LogCaptureFixture, tmp_path: PosixPath) -> None
9195
tmp_path.mkdir(exist_ok=True)
9296
tmp_path.chmod(0o775)
9397

98+
# Check that the Docker volume mount can write to the `tmp_path`
99+
with open(tmp_path / "test.txt", "w") as f:
100+
f.write("Hello, World!")
101+
94102
logging.info("Running the container for TRL...")
95103
container = client.containers.run(
96104
os.getenv(
@@ -125,7 +133,7 @@ def test_trl_peft(caplog: pytest.LogCaptureFixture, tmp_path: PosixPath) -> None
125133
detach=True,
126134
# Mount the volume from the `tmp_path` to the `/opt/huggingface/trained_model`
127135
volumes={
128-
f"{tmp_path}/": {
136+
tmp_path: {
129137
"bind": "/opt/huggingface/trained_model",
130138
"mode": "rw",
131139
}

0 commit comments

Comments
 (0)