From fb34cd255396bc35bf76e4b668e869cfa9502bdf Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Mon, 20 May 2024 22:41:19 +0000 Subject: [PATCH 01/15] Update setuptools_scm to fix CI dependency problem https://github.com/pypa/setuptools_scm/issues/1038 --- conda-envs/mlos-3.10.yml | 2 +- conda-envs/mlos-3.11.yml | 2 +- conda-envs/mlos-3.8.yml | 2 +- conda-envs/mlos-3.9.yml | 2 +- conda-envs/mlos-windows.yml | 2 +- conda-envs/mlos.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conda-envs/mlos-3.10.yml b/conda-envs/mlos-3.10.yml index 085bed0012..4ebcc1e16f 100644 --- a/conda-envs/mlos-3.10.yml +++ b/conda-envs/mlos-3.10.yml @@ -10,7 +10,6 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm - jupyter - ipykernel - nb_conda_kernels @@ -26,6 +25,7 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version + - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos-3.11.yml b/conda-envs/mlos-3.11.yml index f425deac4d..f990b082b5 100644 --- a/conda-envs/mlos-3.11.yml +++ b/conda-envs/mlos-3.11.yml @@ -10,7 +10,6 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm - jupyter - ipykernel - nb_conda_kernels @@ -26,6 +25,7 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version + - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos-3.8.yml b/conda-envs/mlos-3.8.yml index 770e2279f9..5535c4ab03 100644 --- a/conda-envs/mlos-3.8.yml +++ b/conda-envs/mlos-3.8.yml @@ -10,7 +10,6 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm - jupyter - ipykernel - nb_conda_kernels @@ -26,6 +25,7 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version + - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos-3.9.yml b/conda-envs/mlos-3.9.yml index 95c0315ea5..5fa2b71995 100644 --- a/conda-envs/mlos-3.9.yml +++ b/conda-envs/mlos-3.9.yml @@ -10,7 +10,6 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm - jupyter - ipykernel - nb_conda_kernels @@ -26,6 +25,7 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version + - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos-windows.yml b/conda-envs/mlos-windows.yml index 4bc4e7b7d9..b582fece69 100644 --- a/conda-envs/mlos-windows.yml +++ b/conda-envs/mlos-windows.yml @@ -13,7 +13,6 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm - jupyter - ipykernel - nb_conda_kernels @@ -30,6 +29,7 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version + - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos.yml b/conda-envs/mlos.yml index a9890f845e..de668cb324 100644 --- a/conda-envs/mlos.yml +++ b/conda-envs/mlos.yml @@ -10,7 +10,6 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm - jupyter - ipykernel - nb_conda_kernels @@ -24,6 +23,7 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version + - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy From f3438c2418461f905b95b47d69ce06734d90fbc4 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Mon, 20 May 2024 23:02:51 +0000 Subject: [PATCH 02/15] try again from conda --- conda-envs/mlos-3.10.yml | 2 +- conda-envs/mlos-3.11.yml | 2 +- conda-envs/mlos-3.8.yml | 2 +- conda-envs/mlos-3.9.yml | 2 +- conda-envs/mlos-windows.yml | 2 +- conda-envs/mlos.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conda-envs/mlos-3.10.yml b/conda-envs/mlos-3.10.yml index 4ebcc1e16f..50e329f991 100644 --- a/conda-envs/mlos-3.10.yml +++ b/conda-envs/mlos-3.10.yml @@ -10,6 +10,7 @@ dependencies: - pydocstyle - flake8 - setuptools + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels @@ -25,7 +26,6 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version - - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos-3.11.yml b/conda-envs/mlos-3.11.yml index f990b082b5..0fe332cf9a 100644 --- a/conda-envs/mlos-3.11.yml +++ b/conda-envs/mlos-3.11.yml @@ -10,6 +10,7 @@ dependencies: - pydocstyle - flake8 - setuptools + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels @@ -25,7 +26,6 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version - - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos-3.8.yml b/conda-envs/mlos-3.8.yml index 5535c4ab03..53b6204894 100644 --- a/conda-envs/mlos-3.8.yml +++ b/conda-envs/mlos-3.8.yml @@ -10,6 +10,7 @@ dependencies: - pydocstyle - flake8 - setuptools + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels @@ -25,7 +26,6 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version - - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos-3.9.yml b/conda-envs/mlos-3.9.yml index 5fa2b71995..dffdc1490f 100644 --- a/conda-envs/mlos-3.9.yml +++ b/conda-envs/mlos-3.9.yml @@ -10,6 +10,7 @@ dependencies: - pydocstyle - flake8 - setuptools + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels @@ -25,7 +26,6 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version - - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos-windows.yml b/conda-envs/mlos-windows.yml index b582fece69..962878b2fb 100644 --- a/conda-envs/mlos-windows.yml +++ b/conda-envs/mlos-windows.yml @@ -13,6 +13,7 @@ dependencies: - pydocstyle - flake8 - setuptools + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels @@ -29,7 +30,6 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version - - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy diff --git a/conda-envs/mlos.yml b/conda-envs/mlos.yml index de668cb324..245e16cad6 100644 --- a/conda-envs/mlos.yml +++ b/conda-envs/mlos.yml @@ -10,6 +10,7 @@ dependencies: - pydocstyle - flake8 - setuptools + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels @@ -23,7 +24,6 @@ dependencies: - pip: - autopep8>=1.7.0 - bump2version - - setuptools-scm>=8.1.0 - check-jsonschema - licenseheaders - mypy From 6cd905a5d54bae994e2a5bdc4b11684d6af1d395 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Mon, 20 May 2024 23:08:33 +0000 Subject: [PATCH 03/15] allow use of conda-forge --- conda-envs/mlos-3.10.yml | 2 +- conda-envs/mlos-3.11.yml | 3 ++- conda-envs/mlos-3.8.yml | 3 ++- conda-envs/mlos-3.9.yml | 3 ++- conda-envs/mlos-windows.yml | 2 +- conda-envs/mlos.yml | 3 ++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/conda-envs/mlos-3.10.yml b/conda-envs/mlos-3.10.yml index 50e329f991..4a52641eb5 100644 --- a/conda-envs/mlos-3.10.yml +++ b/conda-envs/mlos-3.10.yml @@ -10,7 +10,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm>=8.1.0 + - conda-forge::setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos-3.11.yml b/conda-envs/mlos-3.11.yml index 0fe332cf9a..f4d3b9f103 100644 --- a/conda-envs/mlos-3.11.yml +++ b/conda-envs/mlos-3.11.yml @@ -1,6 +1,7 @@ name: mlos-3.11 channels: - defaults + - conda-forge dependencies: # Basic dev environment packages. # All other dependencies for the mlos modules come from pip. @@ -10,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm>=8.1.0 + - conda-forge::setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos-3.8.yml b/conda-envs/mlos-3.8.yml index 53b6204894..046efae68b 100644 --- a/conda-envs/mlos-3.8.yml +++ b/conda-envs/mlos-3.8.yml @@ -1,6 +1,7 @@ name: mlos-3.8 channels: - defaults + - conda-forge dependencies: # Basic dev environment packages. # All other dependencies for the mlos modules come from pip. @@ -10,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm>=8.1.0 + - conda-forge::setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos-3.9.yml b/conda-envs/mlos-3.9.yml index dffdc1490f..22a2942bae 100644 --- a/conda-envs/mlos-3.9.yml +++ b/conda-envs/mlos-3.9.yml @@ -1,6 +1,7 @@ name: mlos-3.9 channels: - defaults + - conda-forge dependencies: # Basic dev environment packages. # All other dependencies for the mlos modules come from pip. @@ -10,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm>=8.1.0 + - conda-forge::setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos-windows.yml b/conda-envs/mlos-windows.yml index 962878b2fb..f2e378bc16 100644 --- a/conda-envs/mlos-windows.yml +++ b/conda-envs/mlos-windows.yml @@ -13,7 +13,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm>=8.1.0 + - conda-forge::setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos.yml b/conda-envs/mlos.yml index 245e16cad6..6740d7890e 100644 --- a/conda-envs/mlos.yml +++ b/conda-envs/mlos.yml @@ -1,6 +1,7 @@ name: mlos channels: - defaults + - conda-forge dependencies: # Basic dev environment packages. # All other dependencies for the mlos modules come from pip. @@ -10,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - setuptools-scm>=8.1.0 + - conda-forge::setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels From f921731b3224b23230662c36e61db11c979479a3 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Mon, 20 May 2024 23:14:20 +0000 Subject: [PATCH 04/15] reverse the channel priority order --- conda-envs/mlos-3.10.yml | 1 + conda-envs/mlos-3.11.yml | 2 +- conda-envs/mlos-3.8.yml | 2 +- conda-envs/mlos-3.9.yml | 2 +- conda-envs/mlos-windows.yml | 1 - conda-envs/mlos.yml | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conda-envs/mlos-3.10.yml b/conda-envs/mlos-3.10.yml index 4a52641eb5..748c9eefa0 100644 --- a/conda-envs/mlos-3.10.yml +++ b/conda-envs/mlos-3.10.yml @@ -1,5 +1,6 @@ name: mlos-3.10 channels: + - conda-forge - defaults dependencies: # Basic dev environment packages. diff --git a/conda-envs/mlos-3.11.yml b/conda-envs/mlos-3.11.yml index f4d3b9f103..1ae49e6ca2 100644 --- a/conda-envs/mlos-3.11.yml +++ b/conda-envs/mlos-3.11.yml @@ -1,7 +1,7 @@ name: mlos-3.11 channels: - - defaults - conda-forge + - defaults dependencies: # Basic dev environment packages. # All other dependencies for the mlos modules come from pip. diff --git a/conda-envs/mlos-3.8.yml b/conda-envs/mlos-3.8.yml index 046efae68b..923eafccd3 100644 --- a/conda-envs/mlos-3.8.yml +++ b/conda-envs/mlos-3.8.yml @@ -1,7 +1,7 @@ name: mlos-3.8 channels: - - defaults - conda-forge + - defaults dependencies: # Basic dev environment packages. # All other dependencies for the mlos modules come from pip. diff --git a/conda-envs/mlos-3.9.yml b/conda-envs/mlos-3.9.yml index 22a2942bae..ac2f07f54c 100644 --- a/conda-envs/mlos-3.9.yml +++ b/conda-envs/mlos-3.9.yml @@ -1,7 +1,7 @@ name: mlos-3.9 channels: - - defaults - conda-forge + - defaults dependencies: # Basic dev environment packages. # All other dependencies for the mlos modules come from pip. diff --git a/conda-envs/mlos-windows.yml b/conda-envs/mlos-windows.yml index f2e378bc16..681d2bc154 100644 --- a/conda-envs/mlos-windows.yml +++ b/conda-envs/mlos-windows.yml @@ -1,7 +1,6 @@ name: mlos channels: # Note: we have to reverse the channel priority for Windows to accomodate strict channel_priority setups. - # Hence, additional dependencies may differ from the Linux setup. - conda-forge - defaults dependencies: diff --git a/conda-envs/mlos.yml b/conda-envs/mlos.yml index 6740d7890e..c100d59f8e 100644 --- a/conda-envs/mlos.yml +++ b/conda-envs/mlos.yml @@ -1,7 +1,7 @@ name: mlos channels: - - defaults - conda-forge + - defaults dependencies: # Basic dev environment packages. # All other dependencies for the mlos modules come from pip. From 5bd722858e3b23b7d73f6079010f61513b6113bb Mon Sep 17 00:00:00 2001 From: Sergiy Matusevych Date: Mon, 20 May 2024 17:22:03 -0700 Subject: [PATCH 05/15] pycodestyle fixes --- mlos_viz/mlos_viz/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlos_viz/mlos_viz/base.py b/mlos_viz/mlos_viz/base.py index ffe6bd0bc5..787315313a 100644 --- a/mlos_viz/mlos_viz/base.py +++ b/mlos_viz/mlos_viz/base.py @@ -180,7 +180,7 @@ def compute_zscore_for_group_agg( compute_zscore_for_group_agg(results_groups_perf, stats_df, result_col, "var") quantiles = [0.50, 0.75, 0.90, 0.95, 0.99] for quantile in quantiles: # TODO: can we do this in one pass? - quantile_col = result_col + f".p{int(quantile*100)}" + quantile_col = f"{result_col}.p{int(quantile * 100)}" stats_df[quantile_col] = results_groups_perf.transform("quantile", quantile) augmented_results_df = pandas.concat([augmented_results_df, stats_df], axis=1) return augmented_results_df From 37e1e6b78b87a7979270b183e57ea3258e4388e7 Mon Sep 17 00:00:00 2001 From: Sergiy Matusevych Date: Mon, 20 May 2024 17:43:12 -0700 Subject: [PATCH 06/15] temporarily limit builds to python < 3.12 --- conda-envs/mlos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-envs/mlos.yml b/conda-envs/mlos.yml index c100d59f8e..4b12136864 100644 --- a/conda-envs/mlos.yml +++ b/conda-envs/mlos.yml @@ -21,7 +21,7 @@ dependencies: - pyarrow - swig - libpq - - python + - python<3.12 - pip: - autopep8>=1.7.0 - bump2version From 1da2f62d3946779f48d5fb44bf32e40e830cae55 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:11:31 +0000 Subject: [PATCH 07/15] pylint fixups --- .../optimizers/bayesian_optimizers/smac_optimizer.py | 4 ++-- mlos_core/mlos_core/optimizers/flaml_optimizer.py | 2 +- mlos_core/mlos_core/spaces/adapters/llamatune.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py b/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py index aedbb31d29..2e58a8e057 100644 --- a/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py +++ b/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py @@ -27,7 +27,7 @@ class SmacOptimizer(BaseBayesianOptimizer): Wrapper class for SMAC based Bayesian optimization. """ - def __init__(self, *, # pylint: disable=too-many-locals + def __init__(self, *, # pylint: disable=too-many-locals,too-many-arguments parameter_space: ConfigSpace.ConfigurationSpace, optimization_targets: List[str], space_adapter: Optional[BaseSpaceAdapter] = None, @@ -283,7 +283,7 @@ def _suggest(self, context: Optional[pd.DataFrame] = None) -> pd.DataFrame: Pandas dataframe with a single row. Column names are the parameter names. """ if TYPE_CHECKING: - from smac.runhistory import TrialInfo # pylint: disable=import-outside-toplevel + from smac.runhistory import TrialInfo # pylint: disable=import-outside-toplevel,unused-import if context is not None: warn(f"Not Implemented: Ignoring context {list(context.columns)}", UserWarning) diff --git a/mlos_core/mlos_core/optimizers/flaml_optimizer.py b/mlos_core/mlos_core/optimizers/flaml_optimizer.py index 59d6439f38..14b4433f6c 100644 --- a/mlos_core/mlos_core/optimizers/flaml_optimizer.py +++ b/mlos_core/mlos_core/optimizers/flaml_optimizer.py @@ -30,7 +30,7 @@ class FlamlOptimizer(BaseOptimizer): Wrapper class for FLAML Optimizer: A fast library for AutoML and tuning. """ - def __init__(self, *, + def __init__(self, *, # pylint: disable=too-many-arguments parameter_space: ConfigSpace.ConfigurationSpace, optimization_targets: List[str], space_adapter: Optional[BaseSpaceAdapter] = None, diff --git a/mlos_core/mlos_core/spaces/adapters/llamatune.py b/mlos_core/mlos_core/spaces/adapters/llamatune.py index 3d18d774f2..6d87ca749e 100644 --- a/mlos_core/mlos_core/spaces/adapters/llamatune.py +++ b/mlos_core/mlos_core/spaces/adapters/llamatune.py @@ -222,7 +222,7 @@ def _transform(self, configuration: dict) -> dict: index = max(0, min(len(param.choices) - 1, index)) # NOTE: potential rounding here would be unfair to first & last values orig_value = param.choices[index] - elif isinstance(param, ConfigSpace.hyperparameters.NumericalHyperparameter): + elif isinstance(param, NumericalHyperparameter): if param.name in self._special_param_values_dict: value = self._special_param_value_scaler(param, value) From 1b913aeeea452126e4b7186ef968fffbbb2abd1b Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:11:59 +0000 Subject: [PATCH 08/15] more --- mlos_core/mlos_core/spaces/adapters/llamatune.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mlos_core/mlos_core/spaces/adapters/llamatune.py b/mlos_core/mlos_core/spaces/adapters/llamatune.py index 6d87ca749e..554b1169f5 100644 --- a/mlos_core/mlos_core/spaces/adapters/llamatune.py +++ b/mlos_core/mlos_core/spaces/adapters/llamatune.py @@ -9,6 +9,7 @@ from warnings import warn import ConfigSpace +from ConfigSpace.hyperparameters import NumericalHyperparameter import numpy as np import numpy.typing as npt import pandas as pd From dc14d71879a49402e7a487fd7a3df17e39943e04 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:16:27 +0000 Subject: [PATCH 09/15] pylint tweaks --- .../mlos_core/spaces/converters/flaml.py | 21 +++++++++++-------- .../mlos_core/tests/spaces/spaces_test.py | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mlos_core/mlos_core/spaces/converters/flaml.py b/mlos_core/mlos_core/spaces/converters/flaml.py index dc6b10703b..146fbbad8b 100644 --- a/mlos_core/mlos_core/spaces/converters/flaml.py +++ b/mlos_core/mlos_core/spaces/converters/flaml.py @@ -6,7 +6,7 @@ Contains space converters for FLAML. """ -from typing import Dict +from typing import Dict, TYPE_CHECKING import sys @@ -16,17 +16,20 @@ import flaml.tune import flaml.tune.sample -if sys.version_info >= (3, 10): - from typing import TypeAlias -else: - from typing_extensions import TypeAlias +if TYPE_CHECKING: + if sys.version_info >= (3, 10): + from typing import TypeAlias + else: + from typing_extensions import TypeAlias -FlamlDomain: TypeAlias = flaml.tune.sample.Domain -FlamlSpace: TypeAlias = Dict[str, flaml.tune.sample.Domain] + from ConfigSpace.hyperparameters import Hyperparameter + FlamlDomain: TypeAlias = flaml.tune.sample.Domain + FlamlSpace: TypeAlias = Dict[str, flaml.tune.sample.Domain] -def configspace_to_flaml_space(config_space: ConfigSpace.ConfigurationSpace) -> Dict[str, FlamlDomain]: + +def configspace_to_flaml_space(config_space: ConfigSpace.ConfigurationSpace) -> Dict[str, "FlamlDomain"]: """Converts a ConfigSpace.ConfigurationSpace to dict. Parameters @@ -46,7 +49,7 @@ def configspace_to_flaml_space(config_space: ConfigSpace.ConfigurationSpace) -> (ConfigSpace.UniformFloatHyperparameter, True): flaml.tune.loguniform, } - def _one_parameter_convert(parameter: ConfigSpace.hyperparameters.Hyperparameter) -> FlamlDomain: + def _one_parameter_convert(parameter: "Hyperparameter") -> "FlamlDomain": if isinstance(parameter, ConfigSpace.UniformFloatHyperparameter): # FIXME: upper isn't included in the range return flaml_numeric_type[(type(parameter), parameter.log)](parameter.lower, parameter.upper) diff --git a/mlos_core/mlos_core/tests/spaces/spaces_test.py b/mlos_core/mlos_core/tests/spaces/spaces_test.py index 9e15ee0d4b..f77852594e 100644 --- a/mlos_core/mlos_core/tests/spaces/spaces_test.py +++ b/mlos_core/mlos_core/tests/spaces/spaces_test.py @@ -18,7 +18,7 @@ import scipy import ConfigSpace as CS -from ConfigSpace.hyperparameters import NormalIntegerHyperparameter +from ConfigSpace.hyperparameters import Hyperparameter, NormalIntegerHyperparameter import flaml.tune.sample @@ -26,7 +26,7 @@ OptimizerSpace = Union[FlamlSpace, CS.ConfigurationSpace] -OptimizerParam = Union[FlamlDomain, CS.hyperparameters.Hyperparameter] +OptimizerParam = Union[FlamlDomain, Hyperparameter] def assert_is_uniform(arr: npt.NDArray) -> None: From 4f453154d1cd69f3f841e10e772bb09f9a34ad90 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:16:56 +0000 Subject: [PATCH 10/15] tweak the Dockerfile to more closely match the environment files --- .devcontainer/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3d471c6047..69446cc736 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -42,9 +42,9 @@ USER vscode:conda RUN umask 0002 \ && /opt/conda/bin/conda config --set channel_priority strict \ && /opt/conda/bin/conda info \ - && /opt/conda/bin/conda update -v -y -n base -c defaults --all \ + && /opt/conda/bin/conda update -v -y -n base -c conda-forge --all \ && /opt/conda/bin/conda list -n base \ - && /opt/conda/bin/conda install -v -y -n base conda-libmamba-solver \ + && /opt/conda/bin/conda install -v -y -n base -c conda-forge conda-libmamba-solver \ && /opt/conda/bin/conda config --set solver libmamba \ && /opt/conda/bin/conda list -n base \ && /opt/conda/bin/conda clean -v -y -a @@ -52,8 +52,8 @@ RUN umask 0002 \ # Update the base. This helps save space by making sure the same version # python is used for both the base env and mlos env. RUN umask 0002 \ - && /opt/conda/bin/conda update -v -y -n base -c defaults --all \ - && /opt/conda/bin/conda update -v -y -n base -c defaults conda python \ + && /opt/conda/bin/conda update -v -y -n base -c conda-forge --all \ + && /opt/conda/bin/conda update -v -y -n base -c conda-forge conda 'python<3.12' \ && /opt/conda/bin/conda clean -v -y -a \ && /opt/conda/bin/conda run -n base pip cache purge From 7e2155d397fac10aaafc7744c04844c840e1bc6d Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:24:40 +0000 Subject: [PATCH 11/15] fixup --- .../mlos_core/spaces/converters/flaml.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mlos_core/mlos_core/spaces/converters/flaml.py b/mlos_core/mlos_core/spaces/converters/flaml.py index 146fbbad8b..3935dbef6c 100644 --- a/mlos_core/mlos_core/spaces/converters/flaml.py +++ b/mlos_core/mlos_core/spaces/converters/flaml.py @@ -16,20 +16,20 @@ import flaml.tune import flaml.tune.sample - if TYPE_CHECKING: - if sys.version_info >= (3, 10): - from typing import TypeAlias - else: - from typing_extensions import TypeAlias - from ConfigSpace.hyperparameters import Hyperparameter - FlamlDomain: TypeAlias = flaml.tune.sample.Domain - FlamlSpace: TypeAlias = Dict[str, flaml.tune.sample.Domain] +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias + + +FlamlDomain: TypeAlias = flaml.tune.sample.Domain +FlamlSpace: TypeAlias = Dict[str, flaml.tune.sample.Domain] -def configspace_to_flaml_space(config_space: ConfigSpace.ConfigurationSpace) -> Dict[str, "FlamlDomain"]: +def configspace_to_flaml_space(config_space: ConfigSpace.ConfigurationSpace) -> Dict[str, FlamlDomain]: """Converts a ConfigSpace.ConfigurationSpace to dict. Parameters @@ -49,7 +49,7 @@ def configspace_to_flaml_space(config_space: ConfigSpace.ConfigurationSpace) -> (ConfigSpace.UniformFloatHyperparameter, True): flaml.tune.loguniform, } - def _one_parameter_convert(parameter: "Hyperparameter") -> "FlamlDomain": + def _one_parameter_convert(parameter: "Hyperparameter") -> FlamlDomain: if isinstance(parameter, ConfigSpace.UniformFloatHyperparameter): # FIXME: upper isn't included in the range return flaml_numeric_type[(type(parameter), parameter.log)](parameter.lower, parameter.upper) From 737c593155cd4207b5cdec3ac7b5137c673af2d4 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:27:46 +0000 Subject: [PATCH 12/15] minor maintenance cleanup - we use conda-forge now, so we can drop the explicit specifier, should make it easier to switch back in the future --- conda-envs/mlos-3.10.yml | 2 +- conda-envs/mlos-3.11.yml | 2 +- conda-envs/mlos-3.8.yml | 2 +- conda-envs/mlos-3.9.yml | 2 +- conda-envs/mlos-windows.yml | 4 ++-- conda-envs/mlos.yml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conda-envs/mlos-3.10.yml b/conda-envs/mlos-3.10.yml index 748c9eefa0..35fcd2169a 100644 --- a/conda-envs/mlos-3.10.yml +++ b/conda-envs/mlos-3.10.yml @@ -11,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - conda-forge::setuptools-scm>=8.1.0 + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos-3.11.yml b/conda-envs/mlos-3.11.yml index 1ae49e6ca2..11160cfab4 100644 --- a/conda-envs/mlos-3.11.yml +++ b/conda-envs/mlos-3.11.yml @@ -11,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - conda-forge::setuptools-scm>=8.1.0 + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos-3.8.yml b/conda-envs/mlos-3.8.yml index 923eafccd3..047989adf7 100644 --- a/conda-envs/mlos-3.8.yml +++ b/conda-envs/mlos-3.8.yml @@ -11,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - conda-forge::setuptools-scm>=8.1.0 + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos-3.9.yml b/conda-envs/mlos-3.9.yml index ac2f07f54c..e3ed5df862 100644 --- a/conda-envs/mlos-3.9.yml +++ b/conda-envs/mlos-3.9.yml @@ -11,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - conda-forge::setuptools-scm>=8.1.0 + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels diff --git a/conda-envs/mlos-windows.yml b/conda-envs/mlos-windows.yml index 681d2bc154..7cc9d3190b 100644 --- a/conda-envs/mlos-windows.yml +++ b/conda-envs/mlos-windows.yml @@ -12,7 +12,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - conda-forge::setuptools-scm>=8.1.0 + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels @@ -25,7 +25,7 @@ dependencies: - python=3.11 # Install an SMAC requirement pre-compiled from conda-forge. # This also requires a more recent vs2015_runtime from conda-forge. - - conda-forge::pyrfr>=0.9.0 + - pyrfr>=0.9.0 - pip: - autopep8>=1.7.0 - bump2version diff --git a/conda-envs/mlos.yml b/conda-envs/mlos.yml index 4b12136864..bdc8b4c953 100644 --- a/conda-envs/mlos.yml +++ b/conda-envs/mlos.yml @@ -11,7 +11,7 @@ dependencies: - pydocstyle - flake8 - setuptools - - conda-forge::setuptools-scm>=8.1.0 + - setuptools-scm>=8.1.0 - jupyter - ipykernel - nb_conda_kernels From edda6a676d07c1b584839f44fc3fa28c3815720b Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:36:27 +0000 Subject: [PATCH 13/15] fixup --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 69446cc736..d2a09cd1f2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -53,7 +53,7 @@ RUN umask 0002 \ # python is used for both the base env and mlos env. RUN umask 0002 \ && /opt/conda/bin/conda update -v -y -n base -c conda-forge --all \ - && /opt/conda/bin/conda update -v -y -n base -c conda-forge conda 'python<3.12' \ + && /opt/conda/bin/conda update -v -y -n base -c conda-forge conda python \ && /opt/conda/bin/conda clean -v -y -a \ && /opt/conda/bin/conda run -n base pip cache purge From 9f3f98ccc070901b8467a95aa33c9536eb3a230c Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:52:36 +0000 Subject: [PATCH 14/15] Backout some optimization attempts --- .devcontainer/Dockerfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d2a09cd1f2..cf4b37aca9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -42,21 +42,23 @@ USER vscode:conda RUN umask 0002 \ && /opt/conda/bin/conda config --set channel_priority strict \ && /opt/conda/bin/conda info \ - && /opt/conda/bin/conda update -v -y -n base -c conda-forge --all \ + && /opt/conda/bin/conda update -v -y -n base -c defaults --all \ && /opt/conda/bin/conda list -n base \ - && /opt/conda/bin/conda install -v -y -n base -c conda-forge conda-libmamba-solver \ + && /opt/conda/bin/conda install -v -y -n base conda-libmamba-solver \ && /opt/conda/bin/conda config --set solver libmamba \ && /opt/conda/bin/conda list -n base \ - && /opt/conda/bin/conda clean -v -y -a - -# Update the base. This helps save space by making sure the same version -# python is used for both the base env and mlos env. -RUN umask 0002 \ - && /opt/conda/bin/conda update -v -y -n base -c conda-forge --all \ - && /opt/conda/bin/conda update -v -y -n base -c conda-forge conda python \ && /opt/conda/bin/conda clean -v -y -a \ && /opt/conda/bin/conda run -n base pip cache purge +# No longer relevant since we're using conda-forge in the environment files by default now. +## Update the base. This helps save space by making sure the same version +## python is used for both the base env and mlos env. +#RUN umask 0002 \ +# && /opt/conda/bin/conda update -v -y -n base -c defaults --all \ +# && /opt/conda/bin/conda update -v -y -n base -c defaults conda python \ +# && /opt/conda/bin/conda clean -v -y -a \ +# && /opt/conda/bin/conda run -n base pip cache purge + # Install some additional editor packages for the base environment. RUN umask 0002 \ && /opt/conda/bin/conda run -n base pip install --no-cache-dir -U pynvim From 83192d75d13c55c0e5e608322d8aec434f5dd43b Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 21 May 2024 18:54:57 +0000 Subject: [PATCH 15/15] comments --- conda-envs/mlos-windows.yml | 3 ++- conda-envs/mlos.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/conda-envs/mlos-windows.yml b/conda-envs/mlos-windows.yml index 7cc9d3190b..9636f626da 100644 --- a/conda-envs/mlos-windows.yml +++ b/conda-envs/mlos-windows.yml @@ -22,7 +22,8 @@ dependencies: - pyarrow - swig - libpq - - python=3.11 + # FIXME: https://github.com/microsoft/MLOS/issues/727 + - python<3.12 # Install an SMAC requirement pre-compiled from conda-forge. # This also requires a more recent vs2015_runtime from conda-forge. - pyrfr>=0.9.0 diff --git a/conda-envs/mlos.yml b/conda-envs/mlos.yml index bdc8b4c953..0ee6242f25 100644 --- a/conda-envs/mlos.yml +++ b/conda-envs/mlos.yml @@ -21,6 +21,7 @@ dependencies: - pyarrow - swig - libpq + # FIXME: https://github.com/microsoft/MLOS/issues/727 - python<3.12 - pip: - autopep8>=1.7.0