FLAML icon indicating copy to clipboard operation
FLAML copied to clipboard

Unable to run code

Open gauravdutta-iiitb opened this issue 1 year ago • 11 comments

automl.fit(X_train, y_train, task="regression",metric='rmse',time_budget=3600) [flaml.automl.logger: 07-17 14:34:05] {1693} INFO - task = regression [flaml.automl.logger: 07-17 14:34:05] {1700} INFO - Data split method: uniform [flaml.automl.logger: 07-17 14:34:05] {1703} INFO - Evaluation method: holdout [flaml.automl.logger: 07-17 14:34:05] {1801} INFO - Minimizing error metric: rmse [flaml.automl.logger: 07-17 14:34:06] {1911} INFO - List of ML learners in AutoML Run: ['lgbm', 'rf', 'catboost', 'xgboost', 'extra_tree', 'xgb_limitdepth'] [flaml.automl.logger: 07-17 14:34:06] {2221} INFO - iteration 0, current learner lgbm

AttributeError Traceback (most recent call last) Cell In[36], line 1 ----> 1 automl.fit(X_train, y_train, task="regression",metric='rmse',time_budget=3600)

File /opt/conda/lib/python3.10/site-packages/flaml/automl/automl.py:1939, in AutoML.fit(self, X_train, y_train, dataframe, label, metric, task, n_jobs, log_file_name, estimator_list, time_budget, max_iter, sample, ensemble, eval_method, log_type, model_history, split_ratio, n_splits, log_training_metric, mem_thres, pred_time_limit, train_time_limit, X_val, y_val, sample_weight_val, groups_val, groups, verbose, retrain_full, split_type, learner_selector, hpo_method, starting_points, seed, n_concurrent_trials, keep_search_state, preserve_checkpoint, early_stop, force_cancel, append_log, auto_augment, min_sample_size, use_ray, use_spark, free_mem_ratio, metric_constraints, custom_hp, cv_score_agg_func, skip_transform, mlflow_logging, fit_kwargs_by_estimator, **fit_kwargs) 1937 else: 1938 self._training_log = None -> 1939 self._search() 1940 if self._best_estimator: 1941 logger.info("fit succeeded")

File /opt/conda/lib/python3.10/site-packages/flaml/automl/automl.py:2485, in AutoML._search(self) 2483 state.best_config = state.init_config[0] if state.init_config else {} 2484 elif self._use_ray is False and self._use_spark is False: -> 2485 self._search_sequential() 2486 else: 2487 self._search_parallel()

File /opt/conda/lib/python3.10/site-packages/flaml/automl/automl.py:2321, in AutoML._search_sequential(self) 2315 search_state.search_alg.searcher.set_search_properties( 2316 metric=None, 2317 mode=None, 2318 metric_target=self._state.best_loss, 2319 ) 2320 start_run_time = time.time() -> 2321 analysis = tune.run( 2322 search_state.training_function, 2323 search_alg=search_state.search_alg, 2324 time_budget_s=time_budget_s, 2325 verbose=max(self.verbose - 3, 0), 2326 use_ray=False, 2327 use_spark=False, 2328 ) 2329 time_used = time.time() - start_run_time 2330 better = False

File /opt/conda/lib/python3.10/site-packages/flaml/tune/tune.py:797, in run(evaluation_function, config, low_cost_partial_config, cat_hp_cost, metric, mode, time_budget_s, points_to_evaluate, evaluated_rewards, resource_attr, min_resource, max_resource, reduction_factor, scheduler, search_alg, verbose, local_dir, num_samples, resources_per_trial, config_constraints, metric_constraints, max_failure, use_ray, use_spark, use_incumbent_result_in_evaluation, log_file_name, lexico_objectives, force_cancel, n_concurrent_trials, **ray_args) 795 if num_failures == upperbound_num_failures: 796 logger.warning(f"fail to sample a trial for {max_failure} times in a row, stopping.") --> 797 analysis = ExperimentAnalysis( 798 _runner.get_trials(), 799 metric=metric, 800 mode=mode, 801 lexico_objectives=lexico_objectives, 802 ) 803 return analysis 804 finally: 805 # recover the global variables in case of nested run

File /opt/conda/lib/python3.10/site-packages/flaml/tune/tune.py:45, in ExperimentAnalysis.init(self, trials, metric, mode, lexico_objectives) 43 def init(self, trials, metric, mode, lexico_objectives=None): 44 try: ---> 45 super().init(self, None, trials, metric, mode) 46 self.lexico_objectives = lexico_objectives 47 except (TypeError, ValueError):

File /opt/conda/lib/python3.10/site-packages/ray/tune/analysis/experiment_analysis.py:97, in ExperimentAnalysis.init(self, experiment_checkpoint_path, trials, default_metric, default_mode, remote_storage_path, sync_config) 92 self._remote_experiment_path: Optional[str] = None 94 # If the user passes in a remote checkpoint path, 95 # Set the remote experiment path to this path, and set 96 # the local experiment path to a temp directory. ---> 97 if not is_local_path(experiment_checkpoint_path): 98 self._remote_experiment_path = experiment_checkpoint_path 100 # Create a temp directory to store downloaded checkpoint files if 101 # they are pulled from a remote experiment_checkpoint_path.

File /opt/conda/lib/python3.10/site-packages/ray/air/_internal/remote_storage.py:167, in is_local_path(path) 164 if sys.platform == "win32": 165 return _is_local_windows_path(path) --> 167 scheme = urllib.parse.urlparse(path).scheme 168 return scheme in ("", "file")

File /opt/conda/lib/python3.10/urllib/parse.py:399, in urlparse(url, scheme, allow_fragments) 379 def urlparse(url, scheme='', allow_fragments=True): 380 """Parse a URL into 6 components: 381 :///;?# 382 (...) 397 Note that % escapes are not expanded. 398 """ --> 399 url, scheme, _coerce_result = _coerce_args(url, scheme) 400 splitresult = urlsplit(url, scheme, allow_fragments) 401 scheme, netloc, url, query, fragment = splitresult

File /opt/conda/lib/python3.10/urllib/parse.py:136, in _coerce_args(*args) 134 if str_input: 135 return args + (_noop,) --> 136 return _decode_args(args) + (_encode_result,)

File /opt/conda/lib/python3.10/urllib/parse.py:120, in _decode_args(args, encoding, errors) 118 def _decode_args(args, encoding=_implicit_encoding, 119 errors=_implicit_errors): --> 120 return tuple(x.decode(encoding, errors) if x else '' for x in args)

File /opt/conda/lib/python3.10/urllib/parse.py:120, in (.0) 118 def _decode_args(args, encoding=_implicit_encoding, 119 errors=_implicit_errors): --> 120 return tuple(x.decode(encoding, errors) if x else '' for x in args)

AttributeError: 'ExperimentAnalysis' object has no attribute 'decode'

gauravdutta-iiitb avatar Jul 17 '23 14:07 gauravdutta-iiitb

This appears an issue in ray. Could you try pip install "ray[tune]<2.5.0"? It passed the test in GitHub actions.

sonichi avatar Jul 17 '23 20:07 sonichi

It worked, Issue was in Kaggle env. Locally I never had that issue

gauravdutta-iiitb avatar Jul 18 '23 04:07 gauravdutta-iiitb

i try the above step but still it is showing same error

AbhinavGaur147 avatar Aug 14 '23 11:08 AbhinavGaur147

Same issue, AttributeError: 'ExperimentAnalysis' object has no attribute 'decode'

xiaoyaoyang avatar Aug 22 '23 20:08 xiaoyaoyang

@AbhinavGaur147 @xiaoyaoyang what's the version of ray in your env?

sonichi avatar Aug 22 '23 21:08 sonichi

This appears an issue in ray. Could you try pip install "ray[tune]<2.5.0"? It passed the test in GitHub actions.

@sonichi thanks for reply, it was ray==2.6.1. Tried change the version and it works, but I also got another strange error prefer=default(None) is not a valid backend hint, expected one of ('processes', 'threads', None) .solve that by joblib with older version also I think

do we have dependency files for each release? figure I could just grab that and install.. ( I could upload mine for 2.0.0)

xiaoyaoyang avatar Aug 23 '23 16:08 xiaoyaoyang

This appears an issue in ray. Could you try pip install "ray[tune]<2.5.0"? It passed the test in GitHub actions.

@sonichi thanks for reply, it was ray==2.6.1. Tried change the version and it works, but I also got another strange error prefer=default(None) is not a valid backend hint, expected one of ('processes', 'threads', None) .solve that by joblib with older version also I think

do we have dependency files for each release? figure I could just grab that and install.. ( I could upload mine for 2.0.0)

The optional dependencies are specified in setup.py and documented in https://microsoft.github.io/FLAML/docs/Installation. For example, the [ray] option specifies the ray versions needed if ray is needed.

sonichi avatar Aug 24 '23 03:08 sonichi

This problem still persists as I use Kaggle Notebook. Can someone help with the right configuration here after testing in Kaggle?

sumantabasak avatar Sep 20 '23 12:09 sumantabasak

In the Python environment on Kaggle, you can solve the problem using the following code:

!pip install flaml
!pip install ray[tune]==2.4.0

lizhuoq avatar Sep 27 '23 09:09 lizhuoq

Attach my error log for ref, confirmed that swtich to ray==2.7.1 solve the issue, but you have to restart the kernel/ clear cache somehow.. Otherwise below error..

with training_log_writer(log_file_name, append_log) as save_helper:
   1924         self._training_log = save_helper
-> 1925         self._search()
   1926 else:
   1927     self._training_log = None

File /opt/conda/lib/python3.10/site-packages/flaml/automl/automl.py:2482, in AutoML._search(self)
   2480     state.best_config = state.init_config[0] if state.init_config else {}
   2481 elif self._use_ray is False and self._use_spark is False:
-> 2482     self._search_sequential()
   2483 else:
   2484     self._search_parallel()

File /opt/conda/lib/python3.10/site-packages/flaml/automl/automl.py:2271, in AutoML._search_sequential(self)
   2267 time_budget_s = (
   2268     min(budget_left, self._state.train_time_limit or np.inf) if self._state.time_budget >= 0 else None
   2269 )
   2270 if self._hpo_method in ("bs", "cfo", "grid", "cfocat", "random"):
-> 2271     algo = SearchAlgo(
   2272         metric="val_loss",
   2273         mode="min",
   2274         space=search_space,
   2275         points_to_evaluate=points_to_evaluate,
   2276         low_cost_partial_config=low_cost_partial_config,
   2277         cat_hp_cost=search_state.cat_hp_cost,
   2278         resource_attr=resource_attr,
   2279         min_resource=min_resource,
   2280         max_resource=max_resource,
   2281         config_constraints=[(learner_class.size, "<=", self._mem_thres)],
   2282         metric_constraints=self.metric_constraints,
   2283         seed=self._seed,
   2284         allow_empty_config=True,
   2285         time_budget_s=time_budget_s,
   2286         num_samples=self._max_iter,
   2287     )
   2288 else:
   2289     # if self._hpo_method is optuna, sometimes the search space and the initial config dimension do not match
   2290     # need to remove the extra keys from the search space to be consistent with the initial config
   2291     converted_space = SearchAlgo.convert_search_space(search_space)

File /opt/conda/lib/python3.10/site-packages/flaml/tune/searcher/blendsearch.py:203, in BlendSearch.__init__(self, metric, mode, space, low_cost_partial_config, cat_hp_cost, points_to_evaluate, evaluated_rewards, time_budget_s, num_samples, resource_attr, min_resource, max_resource, reduction_factor, global_search_alg, config_constraints, metric_constraints, seed, cost_attr, cost_budget, experimental, lexico_objectives, use_incumbent_result_in_evaluation, allow_empty_config)
    201 if space:
    202     add_cost_to_space(space, init_config, self._cat_hp_cost)
--> 203 self._ls = self.LocalSearch(
    204     init_config,


File /opt/conda/lib/python3.10/site-packages/flaml/tune/searcher/flow2.py:109, in FLOW2.__init__(self, init_config, metric, mode, space, resource_attr, min_resource, max_resource, resource_multiple_factor, cost_attr, seed, lexico_objectives)
    106 else:
    107     mode = "min"
--> 109 super(FLOW2, self).__init__(metric=metric, mode=mode)
    110 # internally minimizes, so "max" => -1
    111 if mode == "max":

File /opt/conda/lib/python3.10/site-packages/ray/tune/search/searcher.py:83, in Searcher.__init__(self, metric, mode)
     78 def __init__(
     79     self,
     80     metric: Optional[str] = None,
     81     mode: Optional[str] = None,
     82 ):
---> 83     tag_searcher(self)
     84     self._metric = metric
     85     self._mode = mode

File /opt/conda/lib/python3.10/site-packages/ray/air/_internal/usage.py:122, in tag_searcher(searcher)
    120     record_extra_usage_tag(TagKey.TUNE_SEARCHER, searcher_name)
    121 else:
--> 122     assert False, (
    123         "Not expecting a non-BasicVariantGenerator, "
    124         "non-Searcher type passed in for `tag_searcher`."
    125     )

AssertionError: Not expecting a non-BasicVariantGenerator, non-Searcher type passed in for `tag_searcher`.

xiaoyaoyang avatar Oct 19 '23 04:10 xiaoyaoyang

Same issue, AttributeError: 'ExperimentAnalysis' object has no attribute 'decode'

thank you! it is normal working. i update [ray]

731315163 avatar Feb 12 '24 10:02 731315163