Skip to content

Commit

Permalink
Fix storage API having SMAC as a required dependency (#899)
Browse files Browse the repository at this point in the history
# Pull Request

## Fix storage API having SMAC as a required dependency

---

## Description

Fixes #898 by moving import away from top-level.

---

## Type of Change

- 🛠️ Bug fix

---

## Testing

Ran existing `mlos_core` unit tests, and manually tested in a fresh
python env without optional deps installed.

---

Co-authored-by: Eu Jing Chua <[email protected]>
  • Loading branch information
eujing and Eu Jing Chua authored Dec 12, 2024
1 parent 3faaa56 commit 0d43b2e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import ConfigSpace
import numpy.typing as npt
import pandas as pd
from smac.utils.configspace import convert_configurations_to_array

from mlos_core.data_classes import Observation, Observations, Suggestion
from mlos_core.optimizers.bayesian_optimizers.bayesian_optimizer import (
Expand Down Expand Up @@ -121,6 +120,10 @@ def __init__(
from smac.main.config_selector import ConfigSelector
from smac.random_design.probability_design import ProbabilityRandomDesign
from smac.runhistory import TrialInfo
from smac.utils.configspace import convert_configurations_to_array

# Save util function here as a property for later usage, also to satisfy linter
self._convert_configurations_to_array = convert_configurations_to_array

# Store for TrialInfo instances returned by .ask()
self.trial_info_map: Dict[ConfigSpace.Configuration, TrialInfo] = {}
Expand Down Expand Up @@ -411,7 +414,7 @@ def surrogate_predict(self, suggestion: Suggestion) -> npt.NDArray:
if self.base_optimizer._config_selector._model is None:
raise RuntimeError("Surrogate model is not yet trained")

config_array = convert_configurations_to_array(
config_array = self._convert_configurations_to_array(
[
ConfigSpace.Configuration(
self.optimizer_parameter_space, values=suggestion.config.to_dict()
Expand Down

0 comments on commit 0d43b2e

Please sign in to comment.