Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8a07c58
start using datetimes with fractional seconds with mysql
bpkroth May 28, 2025
d6fc9e2
adjust tests to also check for fractional time
bpkroth May 28, 2025
65e7f08
Revert "start using datetimes with fractional seconds with mysql"
bpkroth May 28, 2025
b7dad42
Reapply "start using datetimes with fractional seconds with mysql"
bpkroth May 28, 2025
4bf0c5f
apply black on alembic commit
bpkroth May 28, 2025
8088734
preparing to support testing multiple backend engines for schema changes
bpkroth May 28, 2025
a2c3256
refactoring storage tests to check other db engines
bpkroth May 28, 2025
5d3f0d3
change column lengths for mysql
bpkroth May 28, 2025
01b9df4
more refactor of storage tests
bpkroth May 28, 2025
d578176
preparing to support testing multiple backend engines for schema changes
bpkroth May 28, 2025
3b3bf6c
refactoring storage tests to check other db engines
bpkroth May 28, 2025
1c9633c
change column lengths for mysql
bpkroth May 28, 2025
f5b7bf3
fixups
bpkroth May 28, 2025
7fdf06d
fixup
bpkroth May 28, 2025
1bf3c30
fixup
bpkroth May 28, 2025
bd5862f
cleanup
bpkroth May 28, 2025
a5e9c05
Merge branch 'refactor/storage-tests' into feature/mysql-schema-chang…
bpkroth May 28, 2025
67f84ea
fixup
bpkroth May 28, 2025
41199fc
format
bpkroth May 28, 2025
ef33825
Merge branch 'refactor/storage-tests' into feature/mysql-schema-chang…
bpkroth May 28, 2025
ee4a900
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 28, 2025
82220ec
fixup
bpkroth May 28, 2025
aa2621b
fixup
bpkroth May 28, 2025
a84d30b
switch to interprocesslock - already using that
bpkroth May 29, 2025
2341a10
address a lint issue
bpkroth May 29, 2025
45ad11f
restore the original alembic comments - moving to separate PR
bpkroth May 29, 2025
cfa07ea
Merge branch 'refactor/storage-tests' into feature/mysql-schema-chang…
bpkroth May 29, 2025
bbcf689
Revert "restore the original alembic comments - moving to separate PR"
bpkroth May 29, 2025
53ee6e2
more comments
bpkroth May 29, 2025
994a32a
mypy
bpkroth May 29, 2025
2faf643
pylint
bpkroth May 29, 2025
a6b8941
allow retrieving storage url from the environment
bpkroth May 29, 2025
9c5ac14
more alembic tweaks
bpkroth May 29, 2025
988bc90
remove env
bpkroth May 29, 2025
f720d0d
temporarily revert back to something like the original schema
bpkroth May 29, 2025
f250e61
Revert "temporarily revert back to something like the original schema"
bpkroth May 29, 2025
793c2e5
Reapply "temporarily revert back to something like the original schema"
bpkroth May 29, 2025
952fba0
include timezone
bpkroth May 29, 2025
d6617ba
make mysql datetimes support fractional seconds
bpkroth May 29, 2025
2f28d79
log the alembic target engine url
bpkroth May 29, 2025
1b0fb2c
engine no longer optional
bpkroth May 29, 2025
928f491
Revert "make mysql datetimes support fractional seconds"
bpkroth May 29, 2025
4863a5b
Enable alembic to detect datetime precision issues with MySQL
bpkroth Jun 2, 2025
6a697a0
Enable floating point seconds with mysql
bpkroth Jun 2, 2025
f7ccf26
Alembic script to add floating point seconds precision
bpkroth Jun 2, 2025
40374c2
fixup
bpkroth Jun 2, 2025
fe4171a
rework to only apply to mysql
bpkroth Jun 2, 2025
5a42a14
be sure to mark that version as required
bpkroth Jun 2, 2025
f273ea3
add that refactor too
bpkroth Jun 2, 2025
b1b3733
Fixups and refactors to allow two things
bpkroth Jun 2, 2025
c7146e0
Extend storage tests to check multiple backends by default
bpkroth Jun 2, 2025
faeb0e3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 2, 2025
ca0b565
Merge branch 'main' into tests/extend-storage-tests-to-multiple-backends
bpkroth Jun 5, 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
31 changes: 16 additions & 15 deletions mlos_bench/mlos_bench/storage/sql/alembic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This document contains some notes on how to use [`alembic`](https://alembic.sqla
> In the remainder of this document we should some examples for different DB types.
> Pick the one you're targeting and stick with it thru the example.
> You may need to repeat the process several times to test all of them.
>
> - [ ] TODO: Add scripts to automatically do this for several different backend engines all at once.

For instance:
Expand Down Expand Up @@ -63,21 +64,21 @@ This document contains some notes on how to use [`alembic`](https://alembic.sqla
mlos_bench --storage storage/postgresql.jsonc --create-update-storage-schema-only --password=password
```

2. Now, adjust the [`mlos_bench/storage/sql/schema.py`](../schema.py) file to reflect the new desired schema.
1. Now, adjust the [`mlos_bench/storage/sql/schema.py`](../schema.py) file to reflect the new desired schema.

> Keep each change small and atomic.
> For example, if you want to add a new column, do that in one change.
> If you want to rename a column, do that in another change.

3. Generate a new migration script with the following command:
1. Generate a new migration script with the following command:

```sh
alembic revision --autogenerate -m "CHANGEME: Descriptive text about the change."
```

4. Review the generated migration script in the [`mlos_bench/storage/sql/alembic/versions`](./versions/) directory.
1. Review the generated migration script in the [`mlos_bench/storage/sql/alembic/versions`](./versions/) directory.

5. Verify that the migration script works by running the following command:
1. Verify that the migration script works by running the following command:

```sh
# sqlite
Expand Down Expand Up @@ -116,22 +117,22 @@ This document contains some notes on how to use [`alembic`](https://alembic.sqla

> Use different CLI clients for targeting other engines.

6. If the migration script works, commit the changes to the [`mlos_bench/storage/sql/schema.py`](../schema.py) and [`mlos_bench/storage/sql/alembic/versions`](./versions/) files.
1. If the migration script works, commit the changes to the [`mlos_bench/storage/sql/schema.py`](../schema.py) and [`mlos_bench/storage/sql/alembic/versions`](./versions/) files.

> Be sure to update the latest version in the [`test_storage_schemas.py`](../../../tests/storage/test_storage_schemas.py) file as well.

7. Cleanup any server instances you started.
1. Cleanup any server instances you started.

For instance:
For instance:

```sh
rm mlos_bench/storage/sql/mlos_bench.sqlite
```
```sh
rm mlos_bench/storage/sql/mlos_bench.sqlite
```

```sh
docker kill mysql-alembic
```
```sh
docker kill mysql-alembic
```

8. Merge that to the `main` branch.
1. Merge that to the `main` branch.

9. Might be good to cut a new `mlos_bench` release at this point as well.
1. Might be good to cut a new `mlos_bench` release at this point as well.
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pytest_docker.plugin import get_docker_services

from mlos_bench.environments.mock_env import MockEnv
from mlos_bench.tests import SEED, tunable_groups_fixtures, resolve_host_name
from mlos_bench.tests import SEED, resolve_host_name, tunable_groups_fixtures
from mlos_bench.tunables.tunable_groups import TunableGroups

# pylint: disable=redefined-outer-name
Expand Down
4 changes: 2 additions & 2 deletions mlos_bench/mlos_bench/tests/services/remote/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dataclasses import dataclass
from subprocess import run


# The SSH test server port and name.
# See Also: docker-compose.yml
SSH_TEST_SERVER_PORT = 2254
Expand All @@ -18,7 +17,8 @@

@dataclass
class SshTestServerInfo:
"""A data class for SshTestServerInfo.
"""
A data class for SshTestServerInfo.

See Also
--------
Expand Down
4 changes: 2 additions & 2 deletions mlos_bench/mlos_bench/tests/storage/sql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dataclasses import dataclass
from subprocess import run


# The DB servers' names and other connection info.
# See Also: docker-compose.yml

Expand All @@ -20,7 +19,8 @@

@dataclass
class SqlTestServerInfo:
"""A data class for SqlTestServerInfo.
"""
A data class for SqlTestServerInfo.

See Also
--------
Expand Down
16 changes: 6 additions & 10 deletions mlos_bench/mlos_bench/tests/storage/sql/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
#
"""Test fixtures for mlos_bench storage."""

from contextlib import contextmanager
import json
import os
import tempfile
from collections.abc import Generator
from contextlib import contextmanager
from importlib.resources import files
from random import seed as rand_seed

from filelock import FileLock
import pytest
from filelock import FileLock
from pytest_docker.plugin import Services as DockerServices

from mlos_bench.optimizers.mock_optimizer import MockOptimizer
Expand All @@ -23,19 +23,19 @@
from mlos_bench.storage.base_experiment_data import ExperimentData
from mlos_bench.storage.sql.storage import SqlStorage
from mlos_bench.storage.storage_factory import from_config
from mlos_bench.util import path_join
from mlos_bench.tests import SEED, wait_docker_service_healthy
from mlos_bench.tests.storage import (
CONFIG_TRIAL_REPEAT_COUNT,
MAX_TRIALS,
TRIAL_RUNNER_COUNT,
)
from mlos_bench.tests.storage.sql import (
SqlTestServerInfo,
MYSQL_TEST_SERVER_NAME,
PGSQL_TEST_SERVER_NAME,
SqlTestServerInfo,
)
from mlos_bench.tunables.tunable_groups import TunableGroups
from mlos_bench.util import path_join

# pylint: disable=redefined-outer-name

Expand All @@ -48,9 +48,7 @@ def mysql_storage_info(
docker_compose_project_name: str,
locked_docker_services: DockerServices,
) -> SqlTestServerInfo:
"""
Fixture for getting mysql storage connection info.
"""
"""Fixture for getting mysql storage connection info."""
storage_info = SqlTestServerInfo(
compose_project_name=docker_compose_project_name,
service_name=MYSQL_TEST_SERVER_NAME,
Expand All @@ -71,9 +69,7 @@ def postgres_storage_info(
docker_compose_project_name: str,
locked_docker_services: DockerServices,
) -> SqlTestServerInfo:
"""
Fixture for getting postgres storage connection info.
"""
"""Fixture for getting postgres storage connection info."""
storage_info = SqlTestServerInfo(
compose_project_name=docker_compose_project_name,
service_name=PGSQL_TEST_SERVER_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"""Test sql schemas for mlos_bench storage."""

import pytest
from pytest_lazy_fixtures.lazy_fixture import lf as lazy_fixture

from alembic.migration import MigrationContext
from pytest_lazy_fixtures.lazy_fixture import lf as lazy_fixture
from sqlalchemy import inspect

from mlos_bench.storage.sql.storage import SqlStorage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from mlos_bench.environments.status import Status
from mlos_bench.storage.base_storage import Storage
from mlos_bench.tunables.tunable_groups import TunableGroups
from mlos_bench.tests import DOCKER
from mlos_bench.tunables.tunable_groups import TunableGroups

docker_dbms_fixtures = []
if DOCKER:
Expand Down