@@ -709,15 +709,11 @@ def fit(
709
709
)
710
710
711
711
# Check the re-sampling strategy
712
- try :
713
- self ._check_resampling_strategy (
714
- X = X ,
715
- y = y ,
716
- task = self ._task ,
717
- )
718
- except Exception as e :
719
- self ._fit_cleanup ()
720
- raise e
712
+ self ._check_resampling_strategy (
713
+ X = X ,
714
+ y = y ,
715
+ task = self ._task ,
716
+ )
721
717
722
718
# Reset learnt stuff
723
719
self .models_ = None
@@ -793,7 +789,6 @@ def fit(
793
789
)
794
790
795
791
if only_return_configuration_space :
796
- self ._fit_cleanup ()
797
792
return self .configuration_space
798
793
799
794
# == Perform dummy predictions
@@ -927,27 +922,21 @@ def fit(
927
922
trials_callback = self ._get_trials_callback ,
928
923
)
929
924
930
- try :
931
- (
932
- self .runhistory_ ,
933
- self .trajectory_ ,
934
- self ._budget_type ,
935
- ) = _proc_smac .run_smbo ()
936
- trajectory_filename = os .path .join (
937
- self ._backend .get_smac_output_directory_for_run (self ._seed ),
938
- "trajectory.json" ,
939
- )
940
- saveable_trajectory = [
941
- list (entry [:2 ])
942
- + [entry [2 ].get_dictionary ()]
943
- + list (entry [3 :])
944
- for entry in self .trajectory_
945
- ]
946
- with open (trajectory_filename , "w" ) as fh :
947
- json .dump (saveable_trajectory , fh )
948
- except Exception as e :
949
- self ._logger .exception (e )
950
- raise
925
+ (
926
+ self .runhistory_ ,
927
+ self .trajectory_ ,
928
+ self ._budget_type ,
929
+ ) = _proc_smac .run_smbo ()
930
+ trajectory_filename = os .path .join (
931
+ self ._backend .get_smac_output_directory_for_run (self ._seed ),
932
+ "trajectory.json" ,
933
+ )
934
+ saveable_trajectory = [
935
+ list (entry [:2 ]) + [entry [2 ].get_dictionary ()] + list (entry [3 :])
936
+ for entry in self .trajectory_
937
+ ]
938
+ with open (trajectory_filename , "w" ) as fh :
939
+ json .dump (saveable_trajectory , fh )
951
940
952
941
self ._logger .info ("Starting shutdown..." )
953
942
# Wait until the ensemble process is finished to avoid shutting down
@@ -984,6 +973,10 @@ def fit(
984
973
# in a try: finally: so that if something goes wrong, we at least close
985
974
# down the logging server, preventing it from hanging and not closing
986
975
# until ctrl+c is pressed
976
+ except Exception as e :
977
+ # This will be called before the _fit_cleanup
978
+ self ._logger .exception (e )
979
+ raise e
987
980
finally :
988
981
self ._fit_cleanup ()
989
982
0 commit comments