Skip to content

Commit

Permalink
Merge branch 'context-manager-type-hints' into trial-runner-abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
bpkroth committed Jan 9, 2025
2 parents 19cfd91 + fabe2db commit 21d50f9
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,9 @@
"--log-level=DEBUG",
"."
],
"python.testing.unittestEnabled": false
"python.testing.unittestEnabled": false,
"debugpy.debugJustMyCode": false,
"python.analysis.autoImportCompletions": true,
"python.analysis.supportRestructuredText": true,
"python.analysis.typeCheckingMode": "standard"
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _template_from_to(self, config_key: str) -> list[tuple[Template, Template]]:
def _expand(
from_to: Iterable[tuple[Template, Template]],
params: Mapping[str, TunableValue],
) -> Generator[tuple[str, str], None, None]:
) -> Generator[tuple[str, str]]:
"""
Substitute $var parameters in from/to path templates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def ssh_test_server(
ssh_test_server_hostname: str,
docker_compose_project_name: str,
locked_docker_services: DockerServices,
) -> Generator[SshTestServerInfo, None, None]:
) -> Generator[SshTestServerInfo]:
"""
Fixture for getting the ssh test server services setup via docker-compose using
pytest-docker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


@contextmanager
def closeable_temp_file(**kwargs: Any) -> Generator[_TemporaryFileWrapper, None, None]:
def closeable_temp_file(**kwargs: Any) -> Generator[_TemporaryFileWrapper]:
"""
Provides a context manager for a temporary file that can be closed and still
unlinked.
Expand Down
6 changes: 3 additions & 3 deletions mlos_bench/mlos_bench/tests/storage/sql/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def storage() -> SqlStorage:
def exp_storage(
storage: SqlStorage,
tunable_groups: TunableGroups,
) -> Generator[SqlStorage.Experiment, None, None]:
) -> Generator[SqlStorage.Experiment]:
"""
Test fixture for Experiment using in-memory SQLite3 storage.
Expand All @@ -65,7 +65,7 @@ def exp_storage(
@pytest.fixture
def exp_no_tunables_storage(
storage: SqlStorage,
) -> Generator[SqlStorage.Experiment, None, None]:
) -> Generator[SqlStorage.Experiment]:
"""
Test fixture for Experiment using in-memory SQLite3 storage.
Expand All @@ -89,7 +89,7 @@ def exp_no_tunables_storage(
def mixed_numerics_exp_storage(
storage: SqlStorage,
mixed_numerics_tunable_groups: TunableGroups,
) -> Generator[SqlStorage.Experiment, None, None]:
) -> Generator[SqlStorage.Experiment]:
"""
Test fixture for an Experiment with mixed numerics tunables using in-memory SQLite3
storage.
Expand Down
4 changes: 2 additions & 2 deletions mlos_bench/mlos_bench/tunables/tunable_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ def __setitem__(
self._index[name][name] = value
return self._index[name][name]

def __iter__(self) -> Generator[tuple[Tunable, CovariantTunableGroup], None, None]:
def __iter__(self) -> Generator[tuple[Tunable, CovariantTunableGroup]]:
"""
An iterator over all tunables in the group.
Returns
-------
[(tunable, group), ...] : Generator[tuple[Tunable, CovariantTunableGroup], None, None]
[(tunable, group), ...] : Generator[tuple[Tunable, CovariantTunableGroup]]
An iterator over all tunables in all groups. Each element is a 2-tuple
of an instance of the Tunable parameter and covariant group it belongs to.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_configspace_quant_repatch() -> None:
new_meta[QUANTIZATION_BINS_META_KEY] = 21
hp.meta = new_meta
monkey_patch_hp_quantization(hp)
samples_set = set(hp.sample_value(100, seed=RandomState(SEED)))
samples_set: set[int] = set(hp.sample_value(100, seed=RandomState(SEED)))
quantized_values_new = set(range(5, 96, 10))
assert samples_set.issubset(set(range(0, 101, 5)))
assert len(samples_set - quantized_values_new) < len(samples_set)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ disable = [
"consider-using-assignment-expr",
"docstring-first-line-empty",
"missing-raises-doc",
"unnecessary-default-type-args", # affects Generator type hints, but we still support python 3.8
]

[tool.pylint.string]
Expand Down

0 comments on commit 21d50f9

Please sign in to comment.