move import position (#102)

* move import position
This commit is contained in:
Chi Wang
2021-06-05 11:36:26 -07:00
committed by GitHub
parent c0be2eefe8
commit 682cb49654
2 changed files with 7 additions and 4 deletions

View File

@@ -270,8 +270,6 @@ class VowpalWabbitTrial(BaseOnlineTrial):
- Namespace vs features:
https://stackoverflow.com/questions/28586225/in-vowpal-wabbit-what-is-the-difference-between-a-namespace-and-feature
"""
from vowpalwabbit import pyvw
MODEL_CLASS = pyvw.vw
cost_unit = 1.0
interactions_config_key = 'interactions'
MIN_RES_CONST = 5
@@ -299,6 +297,11 @@ class VowpalWabbitTrial(BaseOnlineTrial):
trial_id (str): id of the trial (if None, it will be generated in the constructor)
"""
try:
from vowpalwabbit import pyvw
except ImportError:
raise ImportError(
'To use AutoVW, please run pip install flaml[vw] to install vowpalwabbit')
# attributes
self.trial_id = self._config_to_id(config) if trial_id is None else trial_id
logger.info('Create trial with trial_id: %s', self.trial_id)
@@ -306,7 +309,7 @@ class VowpalWabbitTrial(BaseOnlineTrial):
custom_trial_name, self.trial_id)
self.model = None # model is None until the config is scheduled to run
self.result = None
self.trainable_class = self.MODEL_CLASS
self.trainable_class = pyvw.vw
# variables that are needed during online training
self._metric = metric
self._y_min_observed = None

View File

@@ -1 +1 @@
__version__ = "0.5.0"
__version__ = "0.5.1"