Skip to content

Commit 1b00a7f

Browse files
committed
removed docker from pytest default
1 parent e22b7ca commit 1b00a7f

3 files changed

Lines changed: 25 additions & 45 deletions

File tree

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ jobs:
107107
git clone --depth 1 https://github.com/openml/server-api.git server-api
108108
sed -i 's|\.\./server-api|./server-api|g' docker-compose.yml
109109
110+
- name: Start Docker Test Environment
111+
if: matrix.os == 'ubuntu-latest'
112+
shell: bash
113+
run: |
114+
sed -i 's/\r$//' docker/update.sh
115+
docker compose up -d
116+
docker wait openml-test-setup-ci
117+
echo "OPENML_TEST_SERVER=local" >> $GITHUB_ENV
118+
110119
- name: Show installed dependencies
111120
run: python -m pip list
112121

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ services:
1111
start_period: 30s
1212
interval: 5s
1313
retries: 10
14+
networks:
15+
default:
16+
aliases:
17+
- openml-test-database
18+
- elasticsearch
1419

1520
database-setup:
1621
image: mysql

tests/conftest.py

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
from __future__ import annotations
2525

2626
import multiprocessing
27-
import sys
28-
29-
import fasteners
3027

3128
multiprocessing.set_start_method("spawn", force=True)
3229

@@ -38,9 +35,6 @@
3835
import pytest
3936
import openml_sklearn
4037

41-
import time
42-
import subprocess
43-
import requests
4438
import openml
4539
from openml.testing import TestBase
4640

@@ -302,46 +296,18 @@ def with_test_cache(test_files_directory, request):
302296
if tmp_cache.exists():
303297
shutil.rmtree(tmp_cache)
304298

305-
def _is_server_responding():
306-
"""Check if the Docker API is already listening."""
307-
try:
308-
requests.get("http://localhost:9001/api/v2/", timeout=1)
309-
return True
310-
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
311-
return False
312-
313-
def _start_docker():
314-
"""Logic to spin up the containers and wait for initialization."""
315-
subprocess.run(["docker", "compose", "up", "-d"], check=True, capture_output=True, text=True)
316-
subprocess.run(["docker", "wait", "openml-test-setup-ci"], check=True)
317-
318-
@pytest.fixture(scope="session", autouse=True)
319-
def openml_docker_stack(tmp_path_factory, worker_id):
320-
# Skip Docker setup in CI on Windows given docker images are for Linux
321-
is_ci = os.environ.get("CI") == "true"
322-
is_windows = sys.platform == "win32" or os.name == "nt"
323-
324-
if is_ci and is_windows:
325-
yield
326-
return
327-
328-
# For local development with single worker
329-
if worker_id == "master":
330-
_start_docker()
331-
yield
332-
subprocess.run(["docker", "compose", "down", "-v"], check=True)
333-
return
334-
335-
# For CI with multiple workers (xdist)
336-
root_tmp_dir = tmp_path_factory.getbasetemp().parent
337-
lock_file = root_tmp_dir / "docker_setup.lock"
299+
@pytest.fixture(scope="session")
300+
def openml_test_config():
301+
"""
302+
Returns the URL for the test server.
303+
"""
304+
if os.environ.get("OPENML_TEST_SERVER") == "local":
305+
return {
306+
"v1": "http://localhost:9002/api/v1/",
307+
"v2": "http://localhost:9001/"
308+
}
338309

339-
lock = fasteners.InterProcessLock(str(lock_file))
340-
with lock:
341-
if not _is_server_responding():
342-
_start_docker()
343-
344-
yield
310+
raise ValueError("Use the environment variable OPENML_TEST_SERVER=local before running docker to run tests against a local OpenML server.")
345311

346312
@pytest.fixture
347313
def static_cache_dir():

0 commit comments

Comments
 (0)