@@ -2604,11 +2604,12 @@ def cv_score_agg_func(val_loss_folds, log_metrics_folds):
2604
2604
min_sample_size = min_sample_size or self ._settings .get ("min_sample_size" )
2605
2605
use_ray = self ._settings .get ("use_ray" ) if use_ray is None else use_ray
2606
2606
use_spark = self ._settings .get ("use_spark" ) if use_spark is None else use_spark
2607
- spark_available , spark_error_msg = check_spark ()
2608
2607
if use_spark and use_ray is not False :
2609
2608
raise ValueError ("use_spark and use_ray cannot be both True." )
2610
- elif use_spark and not spark_available :
2611
- raise spark_error_msg
2609
+ elif use_spark :
2610
+ spark_available , spark_error_msg = check_spark ()
2611
+ if not spark_available :
2612
+ raise spark_error_msg
2612
2613
2613
2614
old_level = logger .getEffectiveLevel ()
2614
2615
self .verbose = verbose
@@ -2626,18 +2627,20 @@ def cv_score_agg_func(val_loss_folds, log_metrics_folds):
2626
2627
"Ray installed, setting use_ray to True. If you want to use Spark, set use_spark to True."
2627
2628
)
2628
2629
use_ray = True
2629
- elif spark_available :
2630
- logger .warning (
2631
- "n_concurrent_trials > 1 is only supported when using Ray or Spark. "
2632
- "Spark installed, setting use_spark to True. If you want to use Ray, set use_ray to True."
2633
- )
2634
- use_spark = True
2635
2630
else :
2636
- logger .warning (
2637
- "n_concurrent_trials > 1 is only supported when using Ray or Spark. "
2638
- "Neither Ray nor Spark installed, setting n_concurrent_trials to 1."
2639
- )
2640
- n_concurrent_trials = 1
2631
+ spark_available , _ = check_spark ()
2632
+ if spark_available :
2633
+ logger .warning (
2634
+ "n_concurrent_trials > 1 is only supported when using Ray or Spark. "
2635
+ "Spark installed, setting use_spark to True. If you want to use Ray, set use_ray to True."
2636
+ )
2637
+ use_spark = True
2638
+ else :
2639
+ logger .warning (
2640
+ "n_concurrent_trials > 1 is only supported when using Ray or Spark. "
2641
+ "Neither Ray nor Spark installed, setting n_concurrent_trials to 1."
2642
+ )
2643
+ n_concurrent_trials = 1
2641
2644
2642
2645
self ._state .n_jobs = n_jobs
2643
2646
self ._n_concurrent_trials = n_concurrent_trials
0 commit comments