Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0678f96
Accept the terms of service for conda repos
bpkroth Jul 17, 2025
a3a82f7
Make conda output easier for debugging
bpkroth Jul 17, 2025
fcbfc49
more output adjustments
bpkroth Jul 17, 2025
c666915
Revert "more output adjustments"
bpkroth Jul 17, 2025
2dcfa42
Revert "Make conda output easier for debugging"
bpkroth Jul 17, 2025
9965602
try a suggestion
bpkroth Jul 17, 2025
57b673a
fixups
bpkroth Jul 17, 2025
2084a08
Merge branch 'main' into ci-fixups
bpkroth Jul 17, 2025
ecebe33
type fixups
bpkroth Sep 18, 2025
e7f524d
type checking fixups
bpkroth Sep 18, 2025
1b490ae
use conda by default
bpkroth Sep 18, 2025
9ad7794
small pyright fixups
bpkroth Sep 22, 2025
3c0aa23
Install pre-built pyrfr from conda to workaround build error.
bpkroth Sep 22, 2025
a8d9ccd
ignore a deprecation warning in matplotlib
bpkroth Sep 22, 2025
1862037
fixups
bpkroth Sep 22, 2025
b2530a3
ignore more warnings
bpkroth Sep 22, 2025
d914bcc
Avoid Debian trixie for now since there's no azure-cli package yet. …
bpkroth Sep 22, 2025
b6b5561
Moby has also been removed from Debian Trixie
bpkroth Sep 22, 2025
b059ac3
add more debug logging for missing docker support
bpkroth Sep 23, 2025
021f451
more debugging
bpkroth Sep 23, 2025
ac57951
comments
bpkroth Sep 23, 2025
4462cdf
fixup for local testing
bpkroth Sep 23, 2025
74d94cf
log docker missing warnings
bpkroth Sep 23, 2025
797ac40
comments and revert to moby
bpkroth Sep 23, 2025
72aec7b
upload the coverage.xml file regardless
bpkroth Sep 23, 2025
9fd6843
comments and port forwarding for doc viewing
bpkroth Sep 23, 2025
6fbd25b
revert
bpkroth Sep 23, 2025
382ab78
revertme: temporarily make docker required to see what the issue is i…
bpkroth Sep 23, 2025
496fba8
more debugging
bpkroth Sep 24, 2025
6298fa4
more debug info
bpkroth Oct 21, 2025
2f7c010
trying to print some extra info about the docker env while in the git…
bpkroth Oct 21, 2025
06d4d8d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 21, 2025
3621506
more debugging
bpkroth Oct 21, 2025
751028e
more debugging
bpkroth Oct 21, 2025
d4fc3ba
mypy
bpkroth Oct 21, 2025
5ef8132
fix debugging output
bpkroth Oct 21, 2025
74c30f8
add some more debug info
bpkroth Oct 21, 2025
4b090c6
improved debug checks
bpkroth Oct 21, 2025
fd61c79
cleanup
bpkroth Oct 21, 2025
5b28210
cleanup
bpkroth Oct 21, 2025
2c8668f
cleanup
bpkroth Oct 21, 2025
5088cae
comments and sync
bpkroth Oct 21, 2025
167c91f
lint fixups
bpkroth Oct 21, 2025
315da34
skip grp module
bpkroth Oct 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

FROM mcr.microsoft.com/vscode/devcontainers/base AS base
# TODO: FIXME: Temporarily pin to bookworm until latest (trixie) base image is fully supported.
# See Also:
# - <https://github.com/microsoft/MLOS/issues/1002>
# - .devcontainer/devcontainer.json
FROM mcr.microsoft.com/vscode/devcontainers/base:bookworm AS base

# Add some additional packages for the devcontainer terminal environment.
USER root
Expand Down Expand Up @@ -80,6 +84,8 @@ RUN echo "Setup miniconda" \
&& /opt/conda/bin/conda init \
&& /opt/conda/bin/conda config --set channel_priority strict \
&& /opt/conda/bin/conda info \
&& /opt/conda/bin/conda config --show \
Comment thread
bpkroth marked this conversation as resolved.
&& /opt/conda/bin/conda tos accept --override-channels --channel defaults \
&& /opt/conda/bin/conda update -v -y -n base -c conda-forge -c defaults --all \
&& /opt/conda/bin/conda list -n base \
&& /opt/conda/bin/conda install -v -y -n base -c conda-forge -c defaults conda-libmamba-solver \
Expand Down
13 changes: 12 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,22 @@
"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {},
//"ghcr.io/devcontainers/features/conda:1": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
// Note: this may be required when moving to Debian Trixie base image.
// See Also:
// - <https://github.com/microsoft/MLOS/issues/1002>
// - .devcontainer/Dockerfile
//"moby": false
},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/stuartleeks/dev-container-features/azure-cli-persistence:0": {},
"ghcr.io/stuartleeks/dev-container-features/shell-history:0": {}
},
"forwardPorts": [
// Make the nginx instance started as a part of `make doc` available to view
// the coverage results.
8080
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "python --version",
// Configure tool-specific properties.
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/scripts/run-devcontainer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ docker run -it --rm \
--env http_proxy="${http_proxy:-}" \
--env https_proxy="${https_proxy:-}" \
--env no_proxy="${no_proxy:-}" \
--add-host host.docker.internal:host-gateway \
Comment thread
bpkroth marked this conversation as resolved.
mlos-devcontainer \
$*
46 changes: 42 additions & 4 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,18 @@ jobs:
timeout-minutes: 3
run: |
set -x
gid=`id -g`
docker_sock_gid=`stat -c '%g' /var/run/docker.sock`
docker_gid=`getent group docker | cut -d: -f3 || echo 999`
if [ -n "$docker_sock_gid" ]; then
docker_gid=$docker_sock_gid
echo "Using docker gid: $docker_gid"
fi
if [ "$docker_sock_gid" != "$docker_gid" ] && [ -n "$docker_sock_gid" != "$gid" ] && [ "$docker_sock_gid" != 0 ]; then
echo "WARNING: docker.sock gid ($docker_sock_gid) does not match host docker group gid ($docker_gid) or user gid ($gid)." >&2
fi
docker run -d --rm --user root \
--group-add $docker_sock_gid \
--volume /var/run/docker.sock:/var/run/docker.sock \
--env DOCKER_BUILDKIT=$DOCKER_BUILDKIT \
--volume $(pwd):/workspaces/MLOS \
Expand All @@ -129,6 +140,28 @@ jobs:
- name: Print some debug info from inside the container
run: |
docker exec --user vscode --env USER=vscode mlos-devcontainer printenv
docker exec --user vscode --env USER=vscode mlos-devcontainer id
docker exec --user vscode --env USER=vscode mlos-devcontainer ls -l /var/run/docker.sock
docker exec --user vscode --env USER=vscode mlos-devcontainer stat /var/run/docker.sock

- name: Check that docker is usable inside the devcontainer
timeout-minutes: 2
run: |
set -x
docker_sock_gid=`stat -c '%g' /var/run/docker.sock`
if ! [ -w /var/run/docker.sock ] \
|| ! docker exec --user vscode --env USER=vscode mlos-devcontainer id -G | sed 's/ /\n/' | grep -q -w $docker_sock_gid
then
echo "ERROR: vscode user in container does not have access to docker.sock group (gid: $docker_sock_gid)" >&2
exit 1
fi
docker exec --user vscode --env USER=vscode mlos-devcontainer docker version
docker exec --user vscode --env USER=vscode mlos-devcontainer docker info
docker exec --user vscode --env USER=vscode mlos-devcontainer docker buildx version
if ! docker exec --user vscode --env USER=vscode mlos-devcontainer docker buildx ls | grep linux/; then
echo "ERROR: docker buildx does not have linux builder available" >&2
exit 1
fi

- name: Check that github.com is in the ssh known_hosts file
run: |
Expand Down Expand Up @@ -170,21 +203,26 @@ jobs:
test_count=$(docker exec --user vscode --env USER=vscode mlos-devcontainer \
conda run -n mlos python -m pytest -svxl -n auto --collect-only --rootdir /workspaces/MLOS -s --cache-clear \
| grep -c '<Function ')
if [ "${test_count:-0}" -lt 725 ]; then echo "Expected at least 725 tests, got '$test_count'" >&2; exit 1; fi
# if [ "${test_count:-0}" -lt 800 ]; then echo "Expected at least 800 tests, got '$test_count'" >&2; exit 1; fi

# Now actually run the tests.
docker exec --user vscode --env USER=vscode mlos-devcontainer make CONDA_INFO_LEVEL=-v test

- name: Upload coverage report as build artifact
if: always() # ensures it runs even if tests fail
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml

- name: Generate and test binary distribution files
timeout-minutes: 10
run: |
set -x
docker exec --user vscode --env USER=vscode mlos-devcontainer make CONDA_INFO_LEVEL=-v dist dist-test

- name: Test rebuilding the devcontainer in the devcontainer
# FIXME:
# timeout-minutes: 3
timeout-minutes: 10
timeout-minutes: 5
run: |
set -x
git --no-pager diff --exit-code
Expand Down
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,17 @@
"githubPullRequests.experimental.chat": true,
"github.copilot.chat.codesearch.enabled": true,
"github.copilot.chat.copilotDebugCommand.enabled": true,
"github.copilot.chat.reviewSelection.enabled": true
"github.copilot.chat.reviewSelection.enabled": true,
"python-envs.defaultEnvManager": "ms-python.python:conda",
"python-envs.defaultPackageManager": "ms-python.python:conda",
// Make the nginx instance started as a part of `make doc` available to view
// the coverage results.
"remote.localPortHost": "localhost",
"remote.SSH.defaultForwardedPorts": [
{
"name": "nginx for doc viewing",
"localPort": 8080,
"remotePort": 8080
}
]
}
5 changes: 4 additions & 1 deletion conda-envs/mlos-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ dependencies:
- python=3.10
# See comments in mlos.yml.
#- gcc_linux-64
# Install an SMAC requirement pre-compiled from conda-forge.
# See Also: https://github.com/microsoft/MLOS/issues/1001
- pyrfr>=0.9.0
- pip:
- bump2version
- check-jsonschema
Expand All @@ -30,7 +33,7 @@ dependencies:
- pylint==3.3.7
- tomlkit
- mypy==1.15.0
- pyright==1.1.400
- pyright==1.1.406
- pandas-stubs
- types-beautifulsoup4
- types-colorama
Expand Down
5 changes: 4 additions & 1 deletion conda-envs/mlos-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ dependencies:
- python=3.11
# See comments in mlos.yml.
#- gcc_linux-64
# Install an SMAC requirement pre-compiled from conda-forge.
# See Also: https://github.com/microsoft/MLOS/issues/1001
- pyrfr>=0.9.0
- pip:
- bump2version
- check-jsonschema
Expand All @@ -30,7 +33,7 @@ dependencies:
- pylint==3.3.7
- tomlkit
- mypy==1.15.0
- pyright==1.1.400
- pyright==1.1.406
- pandas-stubs
- types-beautifulsoup4
- types-colorama
Expand Down
5 changes: 4 additions & 1 deletion conda-envs/mlos-3.12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ dependencies:
- python=3.12
# See comments in mlos.yml.
#- gcc_linux-64
# Install an SMAC requirement pre-compiled from conda-forge.
# See Also: https://github.com/microsoft/MLOS/issues/1001
- pyrfr>=0.9.0
- pip:
- bump2version
- check-jsonschema
Expand All @@ -32,7 +35,7 @@ dependencies:
- pylint==3.3.7
- tomlkit
- mypy==1.15.0
- pyright==1.1.400
- pyright==1.1.406
- pandas-stubs
- types-beautifulsoup4
- types-colorama
Expand Down
5 changes: 4 additions & 1 deletion conda-envs/mlos-3.13.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ dependencies:
- python=3.13
# See comments in mlos.yml.
#- gcc_linux-64
# Install an SMAC requirement pre-compiled from conda-forge.
# See Also: https://github.com/microsoft/MLOS/issues/1001
- pyrfr>=0.9.0
- pip:
- bump2version
- check-jsonschema
Expand All @@ -32,7 +35,7 @@ dependencies:
- pylint==3.3.7
- tomlkit
- mypy==1.15.0
- pyright==1.1.400
- pyright==1.1.406
- pandas-stubs
- types-beautifulsoup4
- types-colorama
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/mlos-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies:
- pylint==3.3.7
- tomlkit
- mypy==1.15.0
- pyright==1.1.400
- pyright==1.1.406
- pandas-stubs
- types-beautifulsoup4
- types-colorama
Expand Down
5 changes: 4 additions & 1 deletion conda-envs/mlos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ dependencies:
# FIXME: Temporarily avoid broken libpq that's missing client headers.
- libpq<17.0
- python
# Install an SMAC requirement pre-compiled from conda-forge.
# See Also: https://github.com/microsoft/MLOS/issues/1001
- pyrfr>=0.9.0
- pip:
- bump2version
- check-jsonschema
Expand All @@ -28,7 +31,7 @@ dependencies:
- pylint==3.3.7
- tomlkit
- mypy==1.15.0
- pyright==1.1.400
- pyright==1.1.406
- pandas-stubs
- types-beautifulsoup4
- types-colorama
Expand Down
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def bulk_register(

if status is not None:
# Select only the completed trials, set scores for failed trials to +inf.
df_status = pd.Series(status)
df_status = pd.Series(list(status), dtype=object)
# TODO: Be more flexible with values used for failed trials (not just +inf).
# Issue: https://github.com/microsoft/MLOS/issues/523
df_scores[df_status != Status.SUCCEEDED] = float("inf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def _mysql_datetime(*, with_fsp: bool = False) -> mysql.DATETIME:
See <https://github.com/sqlalchemy/sqlalchemy/pull/12164> for details.
"""
if with_fsp:
return mysql.DATETIME(fsp=6) # type: ignore[no-untyped-call]
return mysql.DATETIME() # type: ignore[no-untyped-call]
return mysql.DATETIME(fsp=6)
return mysql.DATETIME()


def upgrade() -> None:
Expand Down
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/storage/sql/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _mysql_datetime_with_fsp() -> mysql.DATETIME:
Split out to allow single mypy ignore.
See <https://github.com/sqlalchemy/sqlalchemy/pull/12164> for details.
"""
return mysql.DATETIME(fsp=6) # type: ignore[no-untyped-call]
return mysql.DATETIME(fsp=6)


class _DDL:
Expand Down
49 changes: 43 additions & 6 deletions mlos_bench/mlos_bench/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import os
import shutil
import socket
import stat
from datetime import tzinfo
from logging import debug, warning
from logging import warning
from subprocess import run

import pytest
Expand All @@ -38,22 +39,56 @@
"trial_runner_id": None,
}

# A decorator for tests that require docker.
# Use with @requires_docker above a test_...() function.

DOCKER = shutil.which("docker")
if DOCKER:
# Gathering info about Github CI docker.sock permissions for debugging purposes.
DOCKER_SOCK_PATH = "/var/run/docker.sock"
mode: str | None = None
uid: int | None = None
gid: int | None = None
current_uid: int | None = None
current_gid: int | None = None
gids: list[int] | None = None
try:
st = os.stat(DOCKER_SOCK_PATH)
mode = stat.filemode(st.st_mode)
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}")
try:
current_uid = os.getuid()
current_gid = os.getgid()
gids = os.getgroups()
except Exception as e: # pylint: disable=broad-except
warning(f"Could not get current user info: {e}")

cmd = run(
"docker builder inspect default || docker buildx inspect default",
shell=True,
check=False,
capture_output=True,
)
stdout = cmd.stdout.decode()
stderr = cmd.stderr.decode()
if cmd.returncode != 0 or not any(
line for line in stdout.splitlines() if "Platform" in line and "linux" in line
):
debug("Docker is available but missing support for targeting linux platform.")
DOCKER = None
warning(
"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"
)

if not DOCKER:
warning("Docker is not available on this system. Some tests will be skipped.")

# A decorator for tests that require docker.
# Use with @requires_docker above a test_...() function.
requires_docker = pytest.mark.skipif(
not DOCKER,
reason="Docker with Linux support is not available on this system.",
Expand All @@ -62,6 +97,8 @@
# A decorator for tests that require ssh.
# 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.")
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
Expand Down Expand Up @@ -112,7 +149,7 @@ def wait_docker_service_healthy(
docker_services: DockerServices,
project_name: str,
service_name: str,
timeout: float = 30.0,
timeout: float = 60.0,
) -> None:
"""Wait until a docker service is healthy."""
docker_services.wait_until_responsive(
Expand All @@ -126,7 +163,7 @@ def wait_docker_service_socket(docker_services: DockerServices, hostname: str, p
"""Wait until a docker service is ready."""
docker_services.wait_until_responsive(
check=lambda: check_socket(hostname, port),
timeout=30.0,
timeout=60.0,
pause=0.5,
)

Expand Down
2 changes: 2 additions & 0 deletions mlos_bench/mlos_bench/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def docker_compose_file(pytestconfig: pytest.Config) -> list[str]:
Path to the docker-compose file.
"""
_ = pytestconfig # unused
# TODO: move this closer to the necessary submodules so that different
# docker tests can run independently.
Comment thread
bpkroth marked this conversation as resolved.
return [
os.path.join(os.path.dirname(__file__), "services", "remote", "ssh", "docker-compose.yml"),
os.path.join(os.path.dirname(__file__), "storage", "sql", "docker-compose.yml"),
Expand Down
Loading
Loading