From 46e36d7043a10f6808559f92524afe455803caf4 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Thu, 23 Oct 2025 12:43:59 -0500 Subject: [PATCH 1/7] adjust for different platforms --- mlos_bench/mlos_bench/tests/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mlos_bench/mlos_bench/tests/__init__.py b/mlos_bench/mlos_bench/tests/__init__.py index 601d066138..a9bf835301 100644 --- a/mlos_bench/mlos_bench/tests/__init__.py +++ b/mlos_bench/mlos_bench/tests/__init__.py @@ -13,6 +13,7 @@ import shutil import socket import stat +import sys from datetime import tzinfo from logging import warning from subprocess import run @@ -43,7 +44,12 @@ DOCKER = shutil.which("docker") if DOCKER: # Gathering info about Github CI docker.sock permissions for debugging purposes. - DOCKER_SOCK_PATH = "/var/run/docker.sock" + DOCKER_SOCK_PATH: str + if sys.platform == "win32": + DOCKER_SOCK_PATH = "//./pipe/docker_engine" + else: + DOCKER_SOCK_PATH = "/var/run/docker.sock" + mode: str | None = None uid: int | None = None gid: int | None = None @@ -58,9 +64,12 @@ except Exception as e: # pylint: disable=broad-except warning(f"Could not stat {DOCKER_SOCK_PATH}: {e}") try: - current_uid = os.getuid() - current_gid = os.getgid() - gids = os.getgroups() + if sys.platform != "win32": + current_uid = os.getuid() + current_gid = os.getgid() + gids = os.getgroups() + if not os.access(DOCKER_SOCK_PATH, os.W_OK): + warning(f"Docker socket {DOCKER_SOCK_PATH} is not writable.") except Exception as e: # pylint: disable=broad-except warning(f"Could not get current user info: {e}") From 5b403b98e8a5c7cdfb0053b78bfb5eb1020b504b Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Thu, 23 Oct 2025 12:44:11 -0500 Subject: [PATCH 2/7] capture stdout/stderr by default --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 1c1cfe1416..6c4116f6a2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,7 @@ minversion = 7.1 # Run all tests to completion on multiple processes. # Run failed and new tests first by default. addopts = - -vv + -s -l --ff --nf -n auto From 6467c2b28a0fa4e55bb4e2d33133e0d66e34d6f4 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Thu, 23 Oct 2025 12:52:23 -0500 Subject: [PATCH 3/7] revert --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 6c4116f6a2..1c1cfe1416 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,7 @@ minversion = 7.1 # Run all tests to completion on multiple processes. # Run failed and new tests first by default. addopts = - -s + -vv -l --ff --nf -n auto From 86b787e92657b81c84c6771c49c2eaf0b016f9f8 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Thu, 23 Oct 2025 12:55:36 -0500 Subject: [PATCH 4/7] testing --- mlos_viz/mlos_viz/tests/conftest.py | 2 ++ mlos_viz/mlos_viz/tests/test_dabl_plot.py | 1 + 2 files changed, 3 insertions(+) diff --git a/mlos_viz/mlos_viz/tests/conftest.py b/mlos_viz/mlos_viz/tests/conftest.py index 955a4f8662..33e6a63eae 100644 --- a/mlos_viz/mlos_viz/tests/conftest.py +++ b/mlos_viz/mlos_viz/tests/conftest.py @@ -22,6 +22,8 @@ tunable_groups_config = tunable_groups_fixtures.tunable_groups_config tunable_groups = tunable_groups_fixtures.tunable_groups +warning("test") + # Workaround for #1004 # See Also: https://github.com/python/cpython/issues/111754 if sys.platform == "win32": diff --git a/mlos_viz/mlos_viz/tests/test_dabl_plot.py b/mlos_viz/mlos_viz/tests/test_dabl_plot.py index 7fcee4dfe9..05d8bf50cb 100644 --- a/mlos_viz/mlos_viz/tests/test_dabl_plot.py +++ b/mlos_viz/mlos_viz/tests/test_dabl_plot.py @@ -22,3 +22,4 @@ def test_dabl_plot(mock_boxplot: Mock, exp_data: ExperimentData) -> None: dabl.ignore_plotter_warnings() dabl.plot(exp_data) assert mock_boxplot.call_count >= 1 + assert False, "Force failure for testing." From 63a33f0484b3a1a4a2f98bc71798ac9b274fdafc Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Thu, 23 Oct 2025 13:07:56 -0500 Subject: [PATCH 5/7] convert to warn instead of warnings so conftest and __init__ messages are captured even though they are prior to individual tests --- mlos_bench/mlos_bench/tests/__init__.py | 27 ++++++++++++++----------- mlos_viz/mlos_viz/tests/conftest.py | 10 ++++----- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/mlos_bench/mlos_bench/tests/__init__.py b/mlos_bench/mlos_bench/tests/__init__.py index a9bf835301..9e6534399d 100644 --- a/mlos_bench/mlos_bench/tests/__init__.py +++ b/mlos_bench/mlos_bench/tests/__init__.py @@ -15,7 +15,7 @@ import stat import sys from datetime import tzinfo -from logging import warning +from warnings import warn from subprocess import run import pytest @@ -62,16 +62,16 @@ uid = st.st_uid gid = st.st_gid except Exception as e: # pylint: disable=broad-except - warning(f"Could not stat {DOCKER_SOCK_PATH}: {e}") + warn(f"Could not stat {DOCKER_SOCK_PATH}: {e}", UserWarning) try: if sys.platform != "win32": current_uid = os.getuid() current_gid = os.getgid() gids = os.getgroups() if not os.access(DOCKER_SOCK_PATH, os.W_OK): - warning(f"Docker socket {DOCKER_SOCK_PATH} is not writable.") + warn(f"Docker socket {DOCKER_SOCK_PATH} is not writable.", UserWarning) except Exception as e: # pylint: disable=broad-except - warning(f"Could not get current user info: {e}") + warn(f"Could not get current user info: {e}", UserWarning) cmd = run( "docker builder inspect default || docker buildx inspect default", @@ -85,16 +85,17 @@ line for line in stdout.splitlines() if "Platform" in line and "linux" in line ): DOCKER = None - warning( + warn( "Docker is available but missing buildx support for targeting linux platform:\n" + f"stdout:\n{stdout}\n" + f"stderr:\n{stderr}\n" + f"sock_path: {DOCKER_SOCK_PATH} sock mode: {mode} sock uid: {uid} gid: {gid}\n" - + f"current_uid: {current_uid} groups: {gids}\n" + + f"current_uid: {current_uid} groups: {gids}\n", + UserWarning, ) if not DOCKER: - warning("Docker is not available on this system. Some tests will be skipped.") + warn("Docker is not available on this system. Some tests will be skipped.", UserWarning) # A decorator for tests that require docker. # Use with @requires_docker above a test_...() function. @@ -107,7 +108,7 @@ # Use with @requires_ssh above a test_...() function. SSH = shutil.which("ssh") if not SSH: - warning("ssh is not available on this system. Some tests will be skipped.") + warn("ssh is not available on this system. Some tests will be skipped.", UserWarning) requires_ssh = pytest.mark.skipif(not SSH, reason="ssh is not available on this system.") # A common seed to use to avoid tracking down race conditions and intermingling @@ -232,14 +233,16 @@ def are_dir_trees_equal(dir1: str, dir2: str) -> bool: or len(dirs_cmp.right_only) > 0 or len(dirs_cmp.funny_files) > 0 ): - warning( - f"Found differences in dir trees {dir1}, {dir2}:\n" - f"{dirs_cmp.diff_files}\n{dirs_cmp.funny_files}" + warn( + UserWarning( + f"Found differences in dir trees {dir1}, {dir2}:\n" + f"{dirs_cmp.diff_files}\n{dirs_cmp.funny_files}" + ) ) return False (_, mismatch, errors) = filecmp.cmpfiles(dir1, dir2, dirs_cmp.common_files, shallow=False) if len(mismatch) > 0 or len(errors) > 0: - warning(f"Found differences in files:\n{mismatch}\n{errors}") + warn(f"Found differences in files:\n{mismatch}\n{errors}", UserWarning) return False for common_dir in dirs_cmp.common_dirs: new_dir1 = os.path.join(dir1, common_dir) diff --git a/mlos_viz/mlos_viz/tests/conftest.py b/mlos_viz/mlos_viz/tests/conftest.py index 33e6a63eae..f0d1099291 100644 --- a/mlos_viz/mlos_viz/tests/conftest.py +++ b/mlos_viz/mlos_viz/tests/conftest.py @@ -7,7 +7,7 @@ import os import sys from glob import glob -from logging import warning +from warnings import warn from pathlib import Path from mlos_bench.tests import tunable_groups_fixtures @@ -22,8 +22,6 @@ tunable_groups_config = tunable_groups_fixtures.tunable_groups_config tunable_groups = tunable_groups_fixtures.tunable_groups -warning("test") - # Workaround for #1004 # See Also: https://github.com/python/cpython/issues/111754 if sys.platform == "win32": @@ -53,6 +51,8 @@ ) ).parent ) - warning(f"""Setting {env_var} to {os.environ[env_var]}""") + warn(f"""Setting {env_var} to {os.environ[env_var]}""", UserWarning) except StopIteration: - warning(f"{env_var} not found, some Tcl/Tk functionality may be limited.") + warn( + UserWarning(f"{env_var} not found, some Tcl/Tk functionality may be limited.") + ) From 9f6619a293e82948f838cbe93f696de941cdd882 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Thu, 23 Oct 2025 13:15:37 -0500 Subject: [PATCH 6/7] revert --- mlos_viz/mlos_viz/tests/test_dabl_plot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mlos_viz/mlos_viz/tests/test_dabl_plot.py b/mlos_viz/mlos_viz/tests/test_dabl_plot.py index 05d8bf50cb..7fcee4dfe9 100644 --- a/mlos_viz/mlos_viz/tests/test_dabl_plot.py +++ b/mlos_viz/mlos_viz/tests/test_dabl_plot.py @@ -22,4 +22,3 @@ def test_dabl_plot(mock_boxplot: Mock, exp_data: ExperimentData) -> None: dabl.ignore_plotter_warnings() dabl.plot(exp_data) assert mock_boxplot.call_count >= 1 - assert False, "Force failure for testing." From 311c2abd164f91c0f65d1b8392d28d8e4fbf8111 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 18:31:03 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mlos_bench/mlos_bench/tests/__init__.py | 2 +- mlos_viz/mlos_viz/tests/conftest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mlos_bench/mlos_bench/tests/__init__.py b/mlos_bench/mlos_bench/tests/__init__.py index 9e6534399d..d723cfa957 100644 --- a/mlos_bench/mlos_bench/tests/__init__.py +++ b/mlos_bench/mlos_bench/tests/__init__.py @@ -15,8 +15,8 @@ import stat import sys from datetime import tzinfo -from warnings import warn from subprocess import run +from warnings import warn import pytest import pytz diff --git a/mlos_viz/mlos_viz/tests/conftest.py b/mlos_viz/mlos_viz/tests/conftest.py index f0d1099291..a2cbb7e5f1 100644 --- a/mlos_viz/mlos_viz/tests/conftest.py +++ b/mlos_viz/mlos_viz/tests/conftest.py @@ -7,8 +7,8 @@ import os import sys from glob import glob -from warnings import warn from pathlib import Path +from warnings import warn from mlos_bench.tests import tunable_groups_fixtures from mlos_bench.tests.storage.sql import fixtures as sql_storage_fixtures